Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
| 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-70B-Instruct
|
| 7 |
+
tags:
|
| 8 |
+
- function-calling
|
| 9 |
+
- tool-use
|
| 10 |
+
- llama
|
| 11 |
+
- bfcl
|
| 12 |
+
---
|
| 13 |
+
# watt-tool-8B
|
| 14 |
+
|
| 15 |
+
watt-tool-70B is a fine-tuned language model based on LLaMa-3.1-70B-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 |
+
* **Based on LLaMa-3.1-70B-Instruct:** Inherits the strong language understanding and generation capabilities of the base model.
|
| 27 |
+
|
| 28 |
+
## Training Methodology
|
| 29 |
+
|
| 30 |
+
watt-tool-70B 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.
|
| 31 |
+
|
| 32 |
+
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).
|
| 33 |
+
We use SFT and DMPO to further enhance the model's performance in multi-turn agent tasks.
|
| 34 |
+
|
| 35 |
+
## How to Use
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 39 |
+
|
| 40 |
+
model_id = "watt-ai/watt-tool-70B"
|
| 41 |
+
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 43 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype='auto', device_map="auto")
|
| 44 |
+
|
| 45 |
+
# Example usage (adapt as needed for your specific tool usage scenario)
|
| 46 |
+
"""You are an expert in composing functions. You are given a question and a set of possible functions. Based on the question, you will need to make one or more function/tool calls to achieve the purpose.
|
| 47 |
+
If none of the function can be used, point it out. If the given question lacks the parameters required by the function, also point it out.
|
| 48 |
+
You should only return the function call in tools call sections.
|
| 49 |
+
|
| 50 |
+
If you decide to invoke any of the function(s), you MUST put it in the format of [func_name1(params_name1=params_value1, params_name2=params_value2...), func_name2(params)]
|
| 51 |
+
You SHOULD NOT include any other text in the response.
|
| 52 |
+
Here is a list of functions in JSON format that you can invoke.\n{functions}\n
|
| 53 |
+
"""
|
| 54 |
+
# User query
|
| 55 |
+
query = "Find me the sales growth rate for company XYZ for the last 3 years and also the interest coverage ratio for the same duration."
|
| 56 |
+
|
| 57 |
+
tools = [
|
| 58 |
+
{
|
| 59 |
+
"name": "financial_ratios.interest_coverage", "description": "Calculate a company's interest coverage ratio given the company name and duration",
|
| 60 |
+
"arguments": {
|
| 61 |
+
"type": "dict",
|
| 62 |
+
"properties": {
|
| 63 |
+
"company_name": {
|
| 64 |
+
"type": "string",
|
| 65 |
+
"description": "The name of the company."
|
| 66 |
+
},
|
| 67 |
+
"years": {
|
| 68 |
+
"type": "integer",
|
| 69 |
+
"description": "Number of past years to calculate the ratio."
|
| 70 |
+
}
|
| 71 |
+
},
|
| 72 |
+
"required": ["company_name", "years"]
|
| 73 |
+
}
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"name": "sales_growth.calculate",
|
| 77 |
+
"description": "Calculate a company's sales growth rate given the company name and duration",
|
| 78 |
+
"arguments": {
|
| 79 |
+
"type": "dict",
|
| 80 |
+
"properties": {
|
| 81 |
+
"company": {
|
| 82 |
+
"type": "string",
|
| 83 |
+
"description": "The company that you want to get the sales growth rate for."
|
| 84 |
+
},
|
| 85 |
+
"years": {
|
| 86 |
+
"type": "integer",
|
| 87 |
+
"description": "Number of past years for which to calculate the sales growth rate."
|
| 88 |
+
}
|
| 89 |
+
},
|
| 90 |
+
"required": ["company", "years"]
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"name": "weather_forecast",
|
| 95 |
+
"description": "Retrieve a weather forecast for a specific location and time frame.",
|
| 96 |
+
"arguments": {
|
| 97 |
+
"type": "dict",
|
| 98 |
+
"properties": {
|
| 99 |
+
"location": {
|
| 100 |
+
"type": "string",
|
| 101 |
+
"description": "The city that you want to get the weather for."
|
| 102 |
+
},
|
| 103 |
+
"days": {
|
| 104 |
+
"type": "integer",
|
| 105 |
+
"description": "Number of days for the forecast."
|
| 106 |
+
}
|
| 107 |
+
},
|
| 108 |
+
"required": ["location", "days"]
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
]
|
| 112 |
+
|
| 113 |
+
messages = [
|
| 114 |
+
{'role': 'system', 'content': system_prompt.format(functions=tools)},
|
| 115 |
+
{'role': 'user', 'content': query}
|
| 116 |
+
]
|
| 117 |
+
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
| 118 |
+
|
| 119 |
+
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
|
| 120 |
+
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
|