Views
No views yet
Qwen2.5-0.5B-Instruct that takes a user query plus a set of available tool/function schemas and outputs the correct function call(s) as clean, parseable JSON — no prose, no markdown fences. Trained as a cheap, accurate "router" model: given a natural-language request and a list of tools, it picks the right tool and fills in arguments correctly, so you don't need to call a much larger model on every turn.unsloth/Qwen2.5-0.5B-InstructSalesforce/xlam-function-calling-60k — 60k function-calling examples, each verified through format checking, real function execution, and semantic verification{"name": ..., "arguments": ...} objects, and only thatxLAM-1b-fc-r already showed that a sub-2B model can place competitively on the Berkeley Function-Calling Leaderboard (BFCL), outperforming several much larger general-purpose models. This model explores the same idea at an even smaller scale (0.5B), using Unsloth for fast LoRA fine-tuning.Salesforce/xLAM-1b-fc-r or against larger zero-shot baselines (e.g. Qwen2.5-7B-Instruct) on the real BFCL harness. Numbers below will be filled in once that's run — treat any claims of "matching" or "beating" larger models as not yet verified until this section is updated.| Model | BFCL category | Accuracy |
|---|---|---|
nakue/qwen2.5-0.5b-funccall (this model) | simple, multiple | pending |
Qwen2.5-7B-Instruct (zero-shot) | simple, multiple | pending |
Salesforce/xLAM-1b-fc-r | simple, multiple | pending |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch, json
3
4def build_xlam_system_prompt(tools_xlam_format):
5 """
6 tools_xlam_format: a list of tool dicts already in xLAM-native shape, e.g.
7
8 [
9 {
10 "name": "get_weather",
11 "description": "Get current weather for a location",
12 "parameters": {
13 "location": {
14 "description": "The city to get weather for",
15 "type": "str"
16 }
17 }
18 }
19 ]
20 """
21 return (
22 "You are a function-calling assistant. Given a user query and a list of "
23 "available tools, respond with ONLY a JSON array of the function call(s) "
24 "needed to fulfill the query. Each item must have 'name' and 'arguments' "
25 "keys. Do not include any explanation, markdown formatting, or text other "
26 f"than the raw JSON array.\n\nAvailable tools:\n{json.dumps(tools_xlam_format, indent=2)}"
27 )
28
29
30# Example usage with your weather tool, written directly in xLAM format:
31tools = [
32 {
33 "name": "get_weather",
34 "description": "Get current weather for a location",
35 "parameters": {
36 "location": {
37 "description": "The city to get weather for",
38 "type": "str"
39 }
40 }
41 }
42]
43
44system_msg = build_xlam_system_prompt(tools)
45
46messages = [
47 {"role": "system", "content": system_msg},
48 {"role": "user", "content": "What's the weather like in Harare right now?"},
49]
50
51inputs = tokenizer.apply_chat_template(
52 messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
53).to(model.device)
54
55out = model.generate(
56 **inputs,
57 max_new_tokens=256,
58 do_sample=False,
59 pad_token_id=tokenizer.eos_token_id,
60)
61response = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
62print(response)simple and multiple-style single-turn function calling. Not trained or tested on multi-turn conversations, parallel calls, or queries with no matching tool (irrelevance detection).r=16, lora_alpha=16, targeting attention and MLP projection layers), 2 epochs, cosine LR schedule, on a held-out-respecting split of xlam-function-calling-60k (500 examples reserved for test, 300 for validation, remainder for training).@misc{xlam,
title={xLAM: A Family of Large Action Models to Empower AI Agent Systems},
author={Salesforce AI Research},
year={2024}
}