christlurker commited on
Commit
6cef789
·
verified ·
1 Parent(s): a60029a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -3
README.md CHANGED
@@ -1,3 +1,111 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - meta-llama/Llama-3.1-8B-Instruct
7
+ tags:
8
+ - function-calling
9
+ - tool-use
10
+ - llama
11
+ - bfcl
12
+ ---
13
+ # watt-tool-8B
14
+
15
+ watt-tool-8B is a fine-tuned language model based on LLaMa-3.1-8B-Instruct, optimized for tool usage and multi-turn dialogue. It achieves state-of-the-art performance on the Berkeley Function-Calling Leaderboard (BFCL).
16
+
17
+ ## Model Description
18
+
19
+ This model is specifically designed to excel at complex tool usage scenarios that require multi-turn interactions. By leveraging a carefully curated and optimized dataset, watt-tool-8B demonstrates superior capabilities in understanding user requests, selecting appropriate tools, and effectively utilizing them across multiple turns of conversation.
20
+
21
+ ## Key Features
22
+
23
+ * **Enhanced Tool Usage:** Fine-tuned for precise and efficient tool selection and execution.
24
+ * **Multi-Turn Dialogue:** Optimized for maintaining context and effectively utilizing tools across multiple turns of conversation, enabling more complex task completion.
25
+ * **State-of-the-Art Performance:** Achieves top performance on the BFCL, demonstrating its capabilities in function calling and tool usage.
26
+
27
+ ## Training Methodology
28
+
29
+ watt-tool-8B is trained using supervised fine-tuning on a specialized dataset designed for tool usage and multi-turn dialogue. We use CoT techniques to synthesize high-quality multi-turn dialogue data.
30
+
31
+ The training process is inspired by the principles outlined in the paper: ["Direct Multi-Turn Preference Optimization for Language Agents"](https://arxiv.org/abs/2406.14868).
32
+ We use SFT and DMPO to further enhance the model's performance in multi-turn agent tasks.
33
+
34
+ ## How to Use
35
+
36
+ ```python
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+
39
+ model_id = "watt-ai/watt-tool-8B"
40
+
41
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
42
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype='auto', device_map="auto")
43
+
44
+ # Example usage (adapt as needed for your specific tool usage scenario)
45
+ system_prompt = "You are an AI assistant for function calling.
46
+ For politically sensitive questions, security and privacy issues, you will refuse to answer.\n"
47
+ user_prompt = "Please find the weather in London and then book a table at a restaurant nearby."
48
+ tools = [
49
+ {
50
+ "name": "financial_ratios.interest_coverage", "description": "Calculate a company's interest coverage ratio given the company name and duration",
51
+ "arguments": {
52
+ "type": "dict",
53
+ "properties": {
54
+ "company_name": {
55
+ "type": "string",
56
+ "description": "The name of the company."
57
+ },
58
+ "years": {
59
+ "type": "integer",
60
+ "description": "Number of past years to calculate the ratio."
61
+ }
62
+ },
63
+ "required": ["company_name", "years"]
64
+ }
65
+ },
66
+ {
67
+ "name": "sales_growth.calculate",
68
+ "description": "Calculate a company's sales growth rate given the company name and duration",
69
+ "arguments": {
70
+ "type": "dict",
71
+ "properties": {
72
+ "company": {
73
+ "type": "string",
74
+ "description": "The company that you want to get the sales growth rate for."
75
+ },
76
+ "years": {
77
+ "type": "integer",
78
+ "description": "Number of past years for which to calculate the sales growth rate."
79
+ }
80
+ },
81
+ "required": ["company", "years"]
82
+ }
83
+ },
84
+ {
85
+ "name": "weather_forecast",
86
+ "description": "Retrieve a weather forecast for a specific location and time frame.",
87
+ "arguments": {
88
+ "type": "dict",
89
+ "properties": {
90
+ "location": {
91
+ "type": "string",
92
+ "description": "The city that you want to get the weather for."
93
+ },
94
+ "days": {
95
+ "type": "integer",
96
+ "description": "Number of days for the forecast."
97
+ }
98
+ },
99
+ "required": ["location", "days"]
100
+ }
101
+ }
102
+ ]
103
+
104
+ messages = [
105
+ {'role': 'system', 'content': system_prompt.format(functions=tools)},
106
+ {'role': 'user', 'content': query}
107
+ ]
108
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
109
+
110
+ outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
111
+ print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))