Views
No views yet
| Metric | Base | Fine-tuned | Δ |
|---|---|---|---|
| JSON validity | 74.5% | 99.4% | +24.9% |
| Function-name accuracy | 43.5% | 98.4% | +54.9% |
| Exact-match (AST) | 31.1% | 78.8% | +47.7% |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import json
4
5base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct", device_map="auto")
6model = PeftModel.from_pretrained(base, "Arunark/qwen2.5-1.5b-function-calling-lora")
7tok = AutoTokenizer.from_pretrained("Arunark/qwen2.5-1.5b-function-calling-lora")
8
9SYS = ('You are a function-calling assistant. Given the available tools, respond with '
10 'ONLY a JSON list of calls, each {"name": <tool>, "arguments": {<args>}}. '
11 'If nothing applies, respond with []. Tools:\n')
12
13tools = [{"name": "get_weather", "parameters": {"city": {"type": "string"}}}]
14messages = [{"role": "system", "content": SYS + json.dumps(tools)},
15 {"role": "user", "content": "What is the weather in Paris?"}]
16
17prompt = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
18enc = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
19out = model.generate(**enc, max_new_tokens=200, do_sample=False)
20print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))Salesforce/xlam-function-calling-60k, 3 epochs, effective batch 16, lr 0.0002, max_length 1024wrong_arg_values: 63 (59% of misses)wrong_arg_keys: 33 (31% of misses)wrong_function_name: 4 (4% of misses)invalid_json: 3 (3% of misses)other: 2 (2% of misses)wrong_call_count: 1 (1% of misses)Qwen/Qwen2.5-1.5B-Instruct (Apache-2.0). Training data: Salesforce/xlam-function-calling-60k (research/non-commercial). Adapter released under CC-BY-NC-4.0 to respect the dataset's terms.