dwetzel commited on
Commit
7616293
·
verified ·
1 Parent(s): d23a2c4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +178 -182
README.md CHANGED
@@ -1,199 +1,195 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
 
 
 
 
35
 
36
- ## Uses
 
 
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
39
 
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - meta-llama/Llama-3.3-70B-Instruct
7
+ tags:
8
+ - function-calling
9
+ - tool-use
10
+ - llama
11
+ - bfcl
12
  ---
13
 
14
+ # QUANTIZATION INFORMATION
15
 
16
+ This model was quantized using the [llm-compressor](https://github.com/vllm-project/llm-compressor) library from the vLLM team.
17
 
18
+ The calibration dataset was [ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) with a sequence length of `4096` and a sample size of `1024`
19
 
20
+ The quantiation scheme is `W4A16` with the `lm_head` ignored.
21
 
22
+ Further Parameters were the llm-compressor defaults.
23
 
 
24
 
25
+ ## QUANTIZATION CODE
26
 
27
+ The following code was used to quantize this model:
28
 
29
+ #### LOADING THE MODEL:
 
 
 
 
 
 
30
 
31
+ ```python
32
+ from transformers import AutoTokenizer, AutoModelForCausalLM
33
+ import torch
34
 
35
+ MODEL_ID = "watt-ai/watt-tool-70B"
36
 
37
+ # Load model with better memory management
38
+ model = AutoModelForCausalLM.from_pretrained(
39
+ MODEL_ID,
40
+ device_map="auto",
41
+ torch_dtype=torch.bfloat16,
42
+ )
43
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
44
+ ```
45
 
46
+ #### LOADING THE DATASET:
47
+ ```python
48
+ from datasets import load_dataset
49
 
50
+ NUM_CALIBRATION_SAMPLES=1024
51
+ MAX_SEQUENCE_LENGTH=4096
52
 
53
+ # Load dataset.
54
+ ds = load_dataset("HuggingFaceH4/ultrachat_200k", split="train_sft")
55
+ ds = ds.shuffle(seed=42).select(range(NUM_CALIBRATION_SAMPLES))
56
+
57
+ # Preprocess the data into the format the model is trained with.
58
+ def preprocess(example):
59
+ return {"text": tokenizer.apply_chat_template(example["messages"], tokenize=False,)}
60
+ ds = ds.map(preprocess)
61
+
62
+ # Tokenize the data (be careful with bos tokens - we need add_special_tokens=False since the chat_template already added it).
63
+ def tokenize(sample):
64
+ return tokenizer(sample["text"], padding=False, max_length=MAX_SEQUENCE_LENGTH, truncation=True, add_special_tokens=False)
65
+ ds = ds.map(tokenize, remove_columns=ds.column_names)
66
+ ```
67
+
68
+ #### QUANTIZING THE MODEL:
69
+ ```python
70
+ from llmcompressor.transformers import oneshot
71
+ from llmcompressor.modifiers.quantization import GPTQModifier
72
+
73
+ # Configure the quantization algorithm to run.
74
+ recipe = GPTQModifier(targets="Linear", scheme="W4A16", ignore=["lm_head"], dampening_frac=0.1)
75
+
76
+ # Apply quantization.
77
+ oneshot(
78
+ model=model, dataset=ds,
79
+ recipe=recipe,
80
+ max_seq_length=MAX_SEQUENCE_LENGTH,
81
+ num_calibration_samples=NUM_CALIBRATION_SAMPLES,
82
+ )
83
+
84
+ # Save to disk compressed.
85
+ SAVE_DIR = "models/" + MODEL_ID.split("/")[1] + "-GPTQ-INT4"
86
+ model.save_pretrained(SAVE_DIR, max_shard_size="4GB")
87
+ tokenizer.save_pretrained(SAVE_DIR)
88
+ ```
89
+
90
+ ------
91
+
92
+
93
+ # watt-tool-70B
94
+
95
+ watt-tool-70B is a fine-tuned language model based on LLaMa-3.3-70B-Instruct, optimized for tool usage and multi-turn dialogue. It achieves state-of-the-art performance on the Berkeley Function-Calling Leaderboard (BFCL).
96
+
97
+ ## Model Description
98
+
99
+ This model is specifically designed to excel at complex tool usage scenarios that require multi-turn interactions, making it ideal for empowering platforms like [Lupan](https://lupan.watt.chat), an AI-powered workflow building tool. By leveraging a carefully curated and optimized dataset, watt-tool-70B demonstrates superior capabilities in understanding user requests, selecting appropriate tools, and effectively utilizing them across multiple turns of conversation.
100
+
101
+ Target Application: AI Workflow Building as in [https://lupan.watt.chat/](https://lupan.watt.chat/) and [Coze](https://www.coze.com/).
102
+
103
+ ## Key Features
104
+
105
+ * **Enhanced Tool Usage:** Fine-tuned for precise and efficient tool selection and execution.
106
+ * **Multi-Turn Dialogue:** Optimized for maintaining context and effectively utilizing tools across multiple turns of conversation, enabling more complex task completion.
107
+ * **State-of-the-Art Performance:** Achieves top performance on the BFCL, demonstrating its capabilities in function calling and tool usage.
108
+ * **Based on LLaMa-3.1-70B-Instruct:** Inherits the strong language understanding and generation capabilities of the base model.
109
+
110
+ ## Training Methodology
111
+
112
+ 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.
113
+
114
+ 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).
115
+ We use SFT and DMPO to further enhance the model's performance in multi-turn agent tasks.
116
+
117
+ ## How to Use
118
+
119
+ ```python
120
+ from transformers import AutoModelForCausalLM, AutoTokenizer
121
+ model_id = "watt-ai/watt-tool-70B"
122
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
123
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype='auto', device_map="auto")
124
+ # Example usage (adapt as needed for your specific tool usage scenario)
125
+ """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.
126
+ 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.
127
+ You should only return the function call in tools call sections.
128
+ 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)]
129
+ You SHOULD NOT include any other text in the response.
130
+ Here is a list of functions in JSON format that you can invoke.\n{functions}\n
131
+ """
132
+ # User query
133
+ 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."
134
+ tools = [
135
+ {
136
+ "name": "financial_ratios.interest_coverage", "description": "Calculate a company's interest coverage ratio given the company name and duration",
137
+ "arguments": {
138
+ "type": "dict",
139
+ "properties": {
140
+ "company_name": {
141
+ "type": "string",
142
+ "description": "The name of the company."
143
+ },
144
+ "years": {
145
+ "type": "integer",
146
+ "description": "Number of past years to calculate the ratio."
147
+ }
148
+ },
149
+ "required": ["company_name", "years"]
150
+ }
151
+ },
152
+ {
153
+ "name": "sales_growth.calculate",
154
+ "description": "Calculate a company's sales growth rate given the company name and duration",
155
+ "arguments": {
156
+ "type": "dict",
157
+ "properties": {
158
+ "company": {
159
+ "type": "string",
160
+ "description": "The company that you want to get the sales growth rate for."
161
+ },
162
+ "years": {
163
+ "type": "integer",
164
+ "description": "Number of past years for which to calculate the sales growth rate."
165
+ }
166
+ },
167
+ "required": ["company", "years"]
168
+ }
169
+ },
170
+ {
171
+ "name": "weather_forecast",
172
+ "description": "Retrieve a weather forecast for a specific location and time frame.",
173
+ "arguments": {
174
+ "type": "dict",
175
+ "properties": {
176
+ "location": {
177
+ "type": "string",
178
+ "description": "The city that you want to get the weather for."
179
+ },
180
+ "days": {
181
+ "type": "integer",
182
+ "description": "Number of days for the forecast."
183
+ }
184
+ },
185
+ "required": ["location", "days"]
186
+ }
187
+ }
188
+ ]
189
+ messages = [
190
+ {'role': 'system', 'content': system_prompt.format(functions=tools)},
191
+ {'role': 'user', 'content': query}
192
+ ]
193
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
194
+ outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
195
+ print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))