Salesforce/APIGen-MT-5k
Viewer • Updated • 5k • 3.33k • 109
How to use canbingol/qwen2.5-3B-Instruct-conversational-tool-call with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-3B-Instruct")
model = PeftModel.from_pretrained(base_model, "canbingol/qwen2.5-3B-Instruct-conversational-tool-call")How to use canbingol/qwen2.5-3B-Instruct-conversational-tool-call with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="canbingol/qwen2.5-3B-Instruct-conversational-tool-call")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("canbingol/qwen2.5-3B-Instruct-conversational-tool-call", device_map="auto")How to use canbingol/qwen2.5-3B-Instruct-conversational-tool-call with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "canbingol/qwen2.5-3B-Instruct-conversational-tool-call"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "canbingol/qwen2.5-3B-Instruct-conversational-tool-call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/canbingol/qwen2.5-3B-Instruct-conversational-tool-call
How to use canbingol/qwen2.5-3B-Instruct-conversational-tool-call with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "canbingol/qwen2.5-3B-Instruct-conversational-tool-call" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "canbingol/qwen2.5-3B-Instruct-conversational-tool-call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "canbingol/qwen2.5-3B-Instruct-conversational-tool-call" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "canbingol/qwen2.5-3B-Instruct-conversational-tool-call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use canbingol/qwen2.5-3B-Instruct-conversational-tool-call with Docker Model Runner:
docker model run hf.co/canbingol/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.
Evaluation across standard tool-calling benchmark categories compared against the base model:
| Model | simple_python | multiple | parallel | parallel_multiple | irrelevance |
|---|---|---|---|---|---|
| Qwen2.5-3B-Instruct (Base) | 92.00% | 88.50% | 79.00% | 75.50% | 72.08% |
| canbingol/qwen2.5-3B-Instruct-conversational-tool-call | 93.75% | 92.50% | 82.50% | 77.50% | 81.25% |
Key Takeaways:
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))