Downloads · 30 days
26
9% of all-time downloads
silvermete0r/qwen2.5-nano-function-master
qwen2.5-nano-function-master is a text generation model from silvermete0r. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
A lightweight, fast function-calling model fine-tuned from Qwen/Qwen2.5-0.5B-Instruct on the Salesforce/xlam-function-calling-60k dataset.
Downloads · 30 days
26
9% of all-time downloads
All-time downloads
298
Public
Parameters
494M
4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors988 MB · 99%
From the Hugging Face model README
A lightweight, fast function-calling model fine-tuned from Qwen/Qwen2.5-0.5B-Instruct on the Salesforce/xlam-function-calling-60k dataset.
Part of the Fast Nano SLMs project - optimizing inference and memory efficiency for function-calling tasks in private/resource-constrained environments.
Project repository: silvermete0r/nano-slms-for-local-function-calling-assistance
| Hyperparameter | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| LoRA dropout | 0.05 |
| Training samples | 9,000 |
| Eval samples | 1,000 |
| Max steps | 600 |
| Effective batch size | 16 (4 × 4 grad accumulation) |
| Learning rate | 2e-4 |
| LR scheduler | Cosine with 50 warmup steps |
| Optimizer | AdamW (fused) |
| Weight decay | 0.01 |
| Gradient clipping | 1.0 |
| Max sequence length | 1024 |
| Packing | ❌ disabled |
| Dataset | Salesforce/xlam-function-calling-60k |
Evaluated on 1,000 held-out samples from xlam-function-calling-60k:
Before fine-tuning | After fine-tuning ~ Results
Metric Before After Delta
--------------------------------------------------------------
json_valid_pct 45.4 98.7 +53.3
name_match_pct 15.0 93.3 +78.3
args_keys_match_pct 11.8 81.0 +69.2
args_exact_pct 8.9 69.1 +60.2
Estimated during the final evaluation inference stage of the fine-tuned model.
| Metric | Value |
|---|---|
| Average TTFT (s) | 0.0475 |
| Average Tokens per Second | 154.0545 |
| Average Tokens Generated | 51.199 |
| Average VRAM Delta (MB) | 0.0094 |
| Peak VRAM Reserved (MB) | 3120.0 |
| Average RAM Delta (MB) | -0.0666 |
| Average CPU Usage (%) | 69.2192 |
| Throughput (samples/s) | 2.06 |
| Estimated CO₂ Emissions (g CO₂eq) | 5.4236 |
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch, json
model_id = "silvermete0r/qwen2.5-nano-function-master"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id, torch_dtype=torch.float16, device_map="auto")
tools = [
{
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"location": {"type": "string", "description": "City name"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
}
}
]
messages = [
{
"role": "system",
"content": (
"You are a helpful assistant with access to the following functions. "
f"Use them if required:\n{json.dumps(tools)}\n\n"
"Respond strictly with a JSON array of function calls."
)
},
{"role": "user", "content": "What's the weather in Aktobe?"},
]
inputs = tokenizer.apply_chat_template(
messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
outputs = model.generate(inputs, max_new_tokens=128, do_sample=False)
response = tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)
print(json.loads(response))
# → [{"name": "get_weather", "arguments": {"location": "Aktobe", "unit": "celsius"}}]
tokenizer.padding_side = "left"
tokenizer.pad_token = tokenizer.eos_token
prompts = [
tokenizer.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
for msgs in list_of_message_lists
]
inputs = tokenizer(prompts, return_tensors="pt", padding=True, truncation=True,
max_length=1024).to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=False,
pad_token_id=tokenizer.pad_token_id)
responses = [
tokenizer.decode(out[inputs["input_ids"].shape[1]:], skip_special_tokens=True)
for out in outputs
]
@misc{qwen2.5,
title = {Qwen2.5: A Party of Foundation Models},
url = {https://qwenlm.github.io/blog/qwen2.5/},
author = {Qwen Team},
month = {September},
year = {2024}
}
@article{qwen2,
title={Qwen2 Technical Report},
author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
journal={arXiv preprint arXiv:2407.10671},
year={2024}
}
@article{liu2024apigen,
title={APIGen: Automated Pipeline for Generating Verifiable and Diverse Function-Calling Datasets},
author={Liu, Zuxin and Hoang, Thai and Zhang, Jianguo and Zhu, Ming and Lan, Tian and Kokane, Shirley and Tan, Juntao and Yao, Weiran and Liu, Zhiwei and Feng, Yihao and others},
journal={arXiv preprint arXiv:2406.18518},
year={2024}
}