ToolTuned: Qwen2.5-1.5B-Instruct fine-tuned for function calling
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.
Results
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:
- Tool calling (the first 4 categories, 1,000 questions): this model got 61 questions right that the base model missed, and 38 the other way (p = 0.027).
- Irrelevance (240 questions): 18 the other way round, against 53 (p < 0.001).
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.
Training data
The training data was built from Salesforce/xlam-function-calling-60k in four steps:
- Verify. Each of the 60,000 rows was checked against its own tool definitions: the function exists, the parameters exist, required parameters are present, and the values match the declared types. 58,485 rows passed. 1,515 were rejected: 1,241 for a type mismatch and 274 for a missing required parameter.
- Add no-tool examples. 6,498 examples were generated by pairing a request with the tools of a different row. Those tools were chosen to be clearly unrelated, and the reply politely declines to call them.
- Remove overlap with BFCL. Training rows too similar to any of the 1,240 BFCL test questions were removed. The method compares normalized text, then character 8-grams, and removes a row if more than 50% of the shorter text's 8-grams match. This removed 6 exact and 4,030 near-duplicate tool-call rows, and 400 near-duplicate no-tool rows.
- Sample (seed 42). The training set has 10,000 rows: 9,000 tool-call and 1,000 no-tool. The validation set has 500 rows: 450 tool-call and 50 no-tool.
Rows longer than 1,072 tokens were dropped, not cut short, so no answer was cut off.
Training settings
| 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.
Usage
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.
Limitations
- Calls tools too eagerly. On BFCL
irrelevancethe 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. - Other common errors. In a labelled sample of 20 failures, after near-miss calls came wrong argument values (4 of 20) and the wrong number of calls (3 of 20). It also sometimes drops the namespace prefix of dotted function names, such as
electromagnetism.biot_savart_law. - Narrow evaluation. It was evaluated on 5 single-turn BFCL categories only. Multi-turn, live and agentic categories, and other programming languages, were not tested.
- Small model. At 1.5B parameters, it can get multi-step arithmetic wrong when one call's arguments depend on another call's result.
- Single training run. Each result comes from one training run, so differences of a few points between training variants may partly be training luck.
License
- Model weights: Apache 2.0, the same as the base model
Qwen/Qwen2.5-1.5B-Instruct. - Training data: derived from
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.