Qwen2.5-1.5B-Instruct, tool calling with abstention (v6)
Improved using Qwen. Fine-tuned from Qwen/Qwen2.5-1.5B-Instruct with QLoRA, then the adapter was merged into the weights.
Contents of this repo: merged fp16 model (root), 4-bit MLX version (mlx/, for Apple silicon with mlx-lm), and the LoRA adapter (adapter/). Code, evaluation and agent pipeline: https://github.com/siva-0104/toolcall-slm
Qwen2.5-Instruct (0.5B, 1.5B, 3B) fine-tuned with QLoRA for tool calling with abstention.
What it does
Given a user request and a list of tool schemas (JSON), the model either emits <tool_call>{"name": ..., "arguments": {...}}</tool_call> (one or several calls), asks for missing information, or says that no listed tool applies. Intended use: small local agents, with tools retrieved from a larger library (top 5 by embedding similarity) and calls validated against the schema before execution (see agent/).
Training data (all public, leak-gated)
xLAM function-calling 60k (CC-BY-4.0, gated; cite APIGen / xLAM), Glaive function-calling v2 (Apache-2.0; filler replies merged with the call that follows), Hermes function-calling v1 (Apache-2.0), ToolACE (Apache-2.0), plus synthetic mismatched-tool negatives. About 49% of call rows carry 1 to 4 look-alike distractor tools retrieved from the training tool library. 8,559 rows (8,366 after the 1,024-token limit); 24% are no-call rows. No When2Call and no BFCL rows. Splits are disjoint by tool name; leak_check.py passes (0 BFCL query matches, no test tool name in training). Disclosure: 13 of 9,314 BFCL function definitions are identical (name and description) to a training tool, an information-only overlap with different queries.
Training
QLoRA, 4-bit NF4, LoRA r=16 alpha=32, lr 2e-4 cosine, effective batch 16, 1 epoch, loss on the reply only, free Kaggle T4 (0.5B 44 min, 1.5B 100 min, 3B 169 min).
Results (own scorer, not the official BFCL checker; one seed; BFCL report-only)
| 0.5B | 1.5B | 3B | |
|---|---|---|---|
| BFCL simple, exact match | 79.3 | 83.7 | 89.7 |
| BFCL irrelevance, abstained | 75.8 | 84.2 | 87.1 |
| BFCL live simple / live irrelevance | 44.6 / 71.7 | 56.6 / 77.0 | 66.3 / 77.0 |
| xLAM / Hermes / ToolACE exact (leak-free tests) | 68.0 / 48.0 / 44.3 | 71.7 / 53.3 / 49.0 | 77.3 / 59.3 / 53.7 |
| Mismatched tools, abstained | 99.7 | 99.7 | 100 |
| Agent over MCP, 49 queries, 10 tools: call success | 80.6% | 93.5% | 93.5% |
Comparison with the base model
| Set | 1.5B base -> v6 |
|---|---|
| BFCL simple, exact | 62.7 -> 83.7 |
| BFCL live simple, exact | 26.0 -> 56.6 |
| BFCL irrelevance, abstained | 96.7 -> 84.2 |
| BFCL live irrelevance, abstained | 92.0 -> 77.0 |
| xLAM, exact | 24.7 -> 71.7 |
| Hermes, exact | 19.3 -> 53.3 |
| ToolACE, exact | 18.7 -> 49.0 |
| Glaive, decision accuracy | 49.3 -> 96.3 |
| Mismatched tools, abstained | 99.3 -> 99.7 |
Reading it: the base 1.5B model calls on 77% of BFCL simple prompts and gets 63% exact; after fine-tuning it calls on 99% and gets 84%. Its high base abstention (92-97%) again partly reflects not calling. The biggest gains are on the multi-call sets (xLAM 25 to 72, Hermes 19 to 53, ToolACE 19 to 49).
Base = the untouched Qwen2.5-Instruct model with the same prompt and scorer. Base rows use the first 150 items per set (BFCL from results_v2, other sets from results_v4); v6 rows use up to 300, so base numbers are noisier (about ±8 points). A fresh same-size rerun was not possible (free GPU quota exhausted).
Limitations
- Weak on missing information: the 1.5B model often calls with an invented value instead of asking (4 of 6 test queries; 3B: 3 of 6).
- Abstention is imperfect (BFCL irrelevance 76 to 84%); a similarity gate adds a few points at a cost on valid calls.
- With thousands of tools the retriever is a bottleneck: right tool in the top 5 for 70% of queries at 12,641 tools (94% at 100), and "no tool fits" handling falls from 93-100% at 10 tools to 15-19% when the top 5 come from the full library (laptop sample, n = 100 per condition). Putting 100 tools in the prompt is worse still (exact match 6% at 0.5B, 29% at 1.5B).
- Schema-constrained decoding (lm-format-enforcer) gave 100% parsed and schema-valid calls and no invented tool names on xLAM, BFCL simple and live simple at 0.5B and 1.5B (100 items per set; plain decoding is 90% and 97% valid on live simple). It does not make arguments correct. The 3B model was not tested with it (memory).
- Hand-written agent evaluation is small (49 queries); differences under about 10 points are noise.
- English only; not safety-tuned beyond the base model; tool outputs should be treated as untrusted.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer
m='siva-0104/qwen2.5-1.5b-toolcall-abstain-v6'
tok=AutoTokenizer.from_pretrained(m); model=AutoModelForCausalLM.from_pretrained(m, torch_dtype='auto')
Prompt with the Qwen chat template and your tool list in the system message; the model answers with <tool_call>{...}</tool_call>, a clarifying question, or a statement that no tool applies. See the GitHub repo for the exact prompt format (tc_eval_lib.py) and the validating agent loop.
Licence
Apache-2.0 (the base model Qwen/Qwen2.5-1.5B-Instruct is Apache-2.0). Training data licences as above (CC-BY-4.0 attribution for xLAM). Improved using Qwen.