--- license: apache-2.0 base_model: Qwen/Qwen2.5-0.5B-Instruct tags: - function-calling - tool-use - peft - lora - qwen2.5 datasets: - Salesforce/xlam-function-calling-60k language: - en --- # Qwen2.5-0.5B Function Calling (Fine-tuned) A lightweight function-calling model fine-tuned from [Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) on the [Salesforce/xlam-function-calling-60k](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k) dataset. Designed for precise, structured JSON function call generation in resource-constrained environments. ## Training details - **Base model**: Qwen2.5-0.5B-Instruct - **Method**: LoRA (r=16, alpha=32) - **Target modules**: q_proj, v_proj, k_proj, o_proj - **Training samples**: 1500 - **Steps**: 150 - **Precision**: fp16 ## Usage ```python from transformers import AutoTokenizer, AutoModelForCausalLM import torch, json model_id = "silvermete0r/qwen2.5-nano-function-master" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto") tools = [{"name": "get_weather", "description": "Get weather", "parameters": {"location": {"type": "string"}}}] messages = [ {"role": "system", "content": f"You have access to:\n{json.dumps(tools)}\nRespond strictly with a JSON array of function calls."}, {"role": "user", "content": "What's the weather in Paris?"}, ] inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device) outputs = model.generate(inputs, max_new_tokens=128, do_sample=False) print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)) ``` ## Benchmark results (100-sample (random) test split) ``` Metric Before After Delta --------------------------------------------------------- json_valid % 41.0 96.0 +55.0 name_match % 24.0 94.0 +70.0 args_keys_match % 14.0 79.0 +65.0 args_exact % 10.0 69.0 +59.0 ```