Instructions to use silvermete0r/qwen2.5-nano-function-master with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use silvermete0r/qwen2.5-nano-function-master with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="silvermete0r/qwen2.5-nano-function-master") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("silvermete0r/qwen2.5-nano-function-master") model = AutoModelForCausalLM.from_pretrained("silvermete0r/qwen2.5-nano-function-master") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use silvermete0r/qwen2.5-nano-function-master with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use silvermete0r/qwen2.5-nano-function-master with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "silvermete0r/qwen2.5-nano-function-master" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "silvermete0r/qwen2.5-nano-function-master", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/silvermete0r/qwen2.5-nano-function-master
- SGLang
How to use silvermete0r/qwen2.5-nano-function-master with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "silvermete0r/qwen2.5-nano-function-master" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "silvermete0r/qwen2.5-nano-function-master", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "silvermete0r/qwen2.5-nano-function-master" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "silvermete0r/qwen2.5-nano-function-master", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use silvermete0r/qwen2.5-nano-function-master with Docker Model Runner:
docker model run hf.co/silvermete0r/qwen2.5-nano-function-master
Qwen2.5-0.5B - Nano Function Master
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
Training Details
| 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 |
Benchmark Results
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 |
Usage
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"}}]
Batched inference (faster)
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
]
Intended Use
- ✅ Local function-calling assistants (offline / air-gapped)
- ✅ Edge deployment (laptops, Raspberry Pi 5, Jetson Nano)
- ✅ Privacy-sensitive environments (no API calls)
- ✅ Structured JSON output generation
- ❌ Not intended for open-ended conversational use
References
@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}
}
- Downloads last month
- 192