CoolFace
Modelpublic

canbingol/qwen2.5-3B-Instruct-conversational-tool-call

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes17downloads
Model Card

qwen2.5-3B-Instruct-conversational-tool-call

This repository provides a LoRA fine-tuned adapter for Qwen/Qwen2.5-3B-Instruct, optimized specifically for multi-turn conversational tool-calling and function-execution accuracy.

Benchmark Results

Evaluation across standard tool-calling benchmark categories compared against the base model:

Modelsimple_pythonmultipleparallelparallel_multipleirrelevance
Qwen2.5-3B-Instruct (Base)92.00%88.50%79.00%75.50%72.08%
canbingol/qwen2.5-3B-Instruct-conversational-tool-call93.75%92.50%82.50%77.50%81.25%

Key Takeaways:

  • —Consistent improvements across single, multiple, and parallel tool calling scenarios.
  • —Significant reduction in false tool triggers with 81.25% accuracy on irrelevance detection (+9.17% over base).

Dataset

  • —Dataset: Salesforce/APIGen-MT-5k
  • —Preprocessing: Formatted via the model's native chat template and filtered to a maximum sequence length of 8,500 tokens.
  • —Splits:
  • —Train: 4,291 samples
  • —Test: 469 samples

Training Details

  • —Method: LoRA (PEFT)
  • —Epochs: 1 (67 steps)
  • —Effective Batch Size: 64 (Batch size per device: 2, Gradient Accumulation Steps: 32)
  • —Learning Rate: 2e-4 (Linear schedule)
  • —Optimizer: AdamW Torch Fused
  • —Final Validation Loss: 0.2295

Quickstart

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_id = "Qwen/Qwen2.5-3B-Instruct"
adapter_id = "canbingol/qwen2.5-3B-Instruct-conversational-tool-call"

tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
model = PeftModel.from_pretrained(base_model, adapter_id)

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_weather",
            "description": "Get the current weather for a given location.",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City and state/country"}
                },
                "required": ["location"]
            }
        }
    }
]

messages = [{"role": "user", "content": "What's the weather like in Istanbul right now?"}]
prompt = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False)

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))