This model is Qwen/Qwen2.5-1.5B-Instruct fine-tuned with QLoRA to call functions (tools) more accurately. Given a user request and a list of tools, it answers with one or more <tool_call> blocks in Qwen's own format. If none of the tools fit, it answers in plain text instead. The LoRA adapter has been merged into the base weights, so the model loads like any other transformers model.
Code, data pipeline and full results: github.com/arsheen2244/tooltuned.
Measured on 5 categories of the Berkeley Function Calling Leaderboard (BFCL), 1,240 questions in total, with bfcl-eval 2026.3.23 and vLLM on a T4 GPU in fp16. BFCL has no built-in Qwen2.5 entry, so the model is registered with a custom handler that builds prompts with Qwen's chat template. These are not official leaderboard results.
| Category | Questions | Base model | This model | Change |
|---|---|---|---|---|
simple_python |
400 | 86.50% | 87.50% | +1.0 |
multiple |
200 | 84.00% | 87.00% | +3.0 |
parallel |
200 | 74.50% | 78.00% | +3.5 |
parallel_multiple |
200 | 72.50% | 75.50% | +3.0 |
irrelevance |
240 | 72.50% | 57.92% | −14.6 |
The two models answered the same questions, so the comparison is paired. An exact McNemar test counts the questions only one of the two models got right, and asks how likely a split that uneven would be by chance:
Both differences are real. Fine-tuning made the model better at calling tools and clearly worse at noticing when no tool fits.
Ablation. The same recipe trained on data that skipped the verification step scored higher on tool calling. It got 36 questions right that this model missed, against 16 the other way (p = 0.008). The two did not differ beyond chance on irrelevance (12 vs 5, p = 0.143). In this experiment, verifying the training data did not help. Each model was trained once, so training luck is not ruled out.
The training data was built from Salesforce/xlam-function-calling-60k in four steps:
Rows longer than 1,072 tokens were dropped, not cut short, so no answer was cut off.
| Setting | Value |
|---|---|
| Method | QLoRA: base weights in 4-bit NF4, LoRA adapter on all linear layers |
| LoRA | r = 16, alpha = 32, dropout = 0.05 |
| Optimisation | learning rate 2e-4, cosine schedule, 3% warmup, 2 epochs |
| Batch | 4 per step × 4 gradient-accumulation steps = 16 |
| Precision | fp16, with gradient checkpointing (the T4 has no bf16 support) |
| Max sequence length | 1,072 tokens |
| Loss | on the assistant's answer only |
| Hardware | 1 × NVIDIA T4 (free Kaggle notebook) |
| Seed | 42 |
Training ran for 1,226 updates. Validation loss fell from 0.02396 at step 200 to 0.01906 at the end and stayed flat over the last 400 updates.
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "asheeee24/tooltuned-qwen2.5-1.5b"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.float16, device_map="auto")
tools = [{
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {"city": {"description": "City name.", "type": "str"}},
}]
messages = [{"role": "user", "content": "What's the weather like in Paris right now?"}]
prompt = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
output = model.generate(**inputs, max_new_tokens=128, do_sample=False)
answer = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(answer)
# <tool_call>
# {"name": "get_weather", "arguments": {"city": "Paris"}}
# </tool_call>
calls = [json.loads(block.split("</tool_call>")[0]) for block in answer.split("<tool_call>")[1:]]
The model was trained with tools written as in xLAM, as above: each parameter has a description and a Python-style type. BFCL passes JSON-schema tools, and the scores above were measured that way, so both formats work.
irrelevance the model is 14.6 points worse than the base model. If a tool is on the same topic as the request, it tends to call it even when the tool can't answer, for example a route planner for "where is the nearest pharmacy?". The training data's no-tool examples only used clearly unrelated tools, so it never learned to turn down near misses. Check its calls before running them.electromagnetism.biot_savart_law.Qwen/Qwen2.5-1.5B-Instruct.Salesforce/xlam-function-calling-60k, licensed CC-BY-4.0. Credit goes to Salesforce for the original dataset; see its dataset card for its terms of use.有文件?提交种子。
发布种子