tool-call-ft β€” Qwen2.5-3B-Instruct QLoRA adapter for function/tool calling

A QLoRA LoRA adapter that teaches Qwen/Qwen2.5-3B-Instruct to emit reliable, schema-correct tool calls in the compact {"name": ..., "arguments": {...}} format.

Code, training staircase, and eval harness: https://github.com/balaguhanesh/tool-call-ft

Results

Base vs. this adapter on 300 held-out examples (greedy decoding, strict exact-match grader):

Metric Base Fine-tuned Ξ”
JSON-valid rate 51.7% 100.0% +48.3
Function-name accuracy 1.0% 100.0% +99.0
Argument match (exact) 0.3% 95.0% +94.7

The grader is strict: unparseable output fails all three axes, function name is exact/case-sensitive, and arguments require exact dict equality ("5" != 5, any extra/missing key fails the row). Fine-tuning here teaches format compliance and schema discipline, not reasoning.

Training

  • Method: QLoRA β€” 4-bit NF4 base (bitsandbytes), LoRA via peft (r=16, Ξ±=32, all attention + MLP projections; ~30M trainable params, 0.96%)
  • Trainer: trl.SFTTrainer (supervised fine-tuning)
  • Data: glaiveai/glaive-function-calling-v2 β†’ 2000 train / 300 eval
  • Compute: single Kaggle T4, fp16, 1 epoch (~21 min), final train loss β‰ˆ 0.13

Usage

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base = "Qwen/Qwen2.5-3B-Instruct"
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, device_map="auto")
model = PeftModel.from_pretrained(model, "Balaguhanesh/tool-call-ft")

messages = [
    {"role": "system", "content": "You are a helpful assistant with access to the following functions. Use them if required -\n{...function schema...}"},
    {"role": "user", "content": "What's the weather in Paris?"},
]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Downloads last month
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for balaguhanesh/tool-call-ft

Base model

Qwen/Qwen2.5-3B
Adapter
(1279)
this model

Dataset used to train balaguhanesh/tool-call-ft