Views
No views yet
| 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% |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5base_model_id = "Qwen/Qwen2.5-3B-Instruct"
6adapter_id = "canbingol/qwen2.5-3B-Instruct-conversational-tool-call"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id)
9base_model = AutoModelForCausalLM.from_pretrained(
10 base_model_id,
11 torch_dtype=torch.bfloat16,
12 device_map="auto"
13)
14model = PeftModel.from_pretrained(base_model, adapter_id)
15
16tools = [
17 {
18 "type": "function",
19 "function": {
20 "name": "get_current_weather",
21 "description": "Get the current weather for a given location.",
22 "parameters": {
23 "type": "object",
24 "properties": {
25 "location": {"type": "string", "description": "City and state/country"}
26 },
27 "required": ["location"]
28 }
29 }
30 }
31]
32
33messages = [{"role": "user", "content": "What's the weather like in Istanbul right now?"}]
34prompt = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False)
35
36inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
37outputs = model.generate(**inputs, max_new_tokens=256)
38print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))