Text Generation
GGUF
English
Qwen2.5-Coder-3B
Inference Endpoints
conversational
Melvin56 commited on
Commit
248acc4
·
verified ·
1 Parent(s): 632c52a

Upload model via Google Colab

Browse files
.gitattributes CHANGED
@@ -33,3 +33,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ hammer2.1-3b-Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
37
+ hammer2.1-3b-Q2_K_S.gguf filter=lfs diff=lfs merge=lfs -text
38
+ hammer2.1-3b-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
39
+ hammer2.1-3b-Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
40
+ hammer2.1-3b-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
41
+ hammer2.1-3b-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
42
+ hammer2.1-3b-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
43
+ hammer2.1-3b-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
44
+ hammer2.1-3b-f16.gguf filter=lfs diff=lfs merge=lfs -text
45
+ imatrix.dat filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: qwen-research
4
+ license_link: https://huggingface.co/MadeAgents/Hammer2.1-3b/blob/main/LICENSE
5
+ datasets:
6
+ - Salesforce/xlam-function-calling-60k
7
+ - MadeAgents/xlam-irrelevance-7.5k
8
+ base_model:
9
+ - Qwen/Qwen2.5-Coder-3B-Instruct
10
+ ---
11
+ # Hammer2.1-3b Function Calling Model
12
+
13
+ ## Introduction
14
+
15
+ Hammer refers to a series of lightweight Large Action Models. Currently, we are releasing Hammer 2.1 models ([0.5B](https://huggingface.co/MadeAgents/Hammer2.1-0.5b), [1.5B](https://huggingface.co/MadeAgents/Hammer2.1-1.5b), [3B](https://huggingface.co/MadeAgents/Hammer2.1-3b), and [7B](https://huggingface.co/MadeAgents/Hammer2.1-7b)) with strong function calling capability. These models are based on the Qwen 2.5 coder series and utilize [function masking techniques](https://arxiv.org/abs/2410.04587) and other advanced technologies. Hammer 2.1 series bring significant enhancements, while still maintaining the basic functionality of Hammer 2.0's Single-Turn interaction and further strengthening other capabilities.
16
+
17
+ ## Model Details
18
+ The Hammer 2.1 models, fine-tuned from the Qwen 2.5 coder series, inherit Hammer 2.0's advantages and are enhanced as follows:
19
+ - <span style="color: red;">Multi-Step Function Calling:</span> The assistant can perform multiple internal function calls to handle a single user request, actively planning and gathering information to fulfill complex tasks.
20
+ - <span style="color: red;">Multi-Turn Function Calling:</span> Enables continuous and context-aware interactions over multiple exchanges, with each turn potentially containing multiple steps, for a more natural conversation experience.
21
+ - Enhanced Irrelevant Information Inspection: Better at identifying when provided functions are irrelevant to a user query, by providing a non-function call response.
22
+
23
+ ## Evaluation
24
+ The evaluation results of Hammer 2.1 models on the Berkeley Function-Calling Leaderboard (BFCL-v3) are presented in the following table:
25
+ <div style="text-align: center;">
26
+ <img src="v2_figures/bfcl.png" alt="overview" width="1000" style="margin: auto;">
27
+ </div>
28
+
29
+ Our Hammer 2.1 series consistently achieves corresponding best performance at comparable scales. The 7B/3B/1.5B model outperform most function calling enchanced models.
30
+
31
+ In addition, we evaluated the Hammer 2.1 models on other academic benchmarks to further demonstrate the generalization ability of our models.
32
+
33
+ <div style="text-align: center;">
34
+ <img src="v2_figures/others-v2.png" alt="overview" width="1000" style="margin: auto;">
35
+ </div>
36
+
37
+ Hammer 2.1 models showcase highly stable performance, suggesting the robustness of Hammer 2.1 series. In contrast, the baseline approaches display varying levels of effectiveness.
38
+
39
+
40
+
41
+ ## Requiements
42
+ The code of Hammer 2.1 models have been in the latest Hugging face transformers and we advise you to install `transformers>=4.47.0`.
43
+
44
+ ## How to Use
45
+ Hammer models offer flexibility in deployment and usage, fully supporting both **vLLM** deployment and **Hugging Face Transformers** tool calling. Below are the specifics on how to make use of these features:
46
+
47
+ ### Using vLLM
48
+ #### Option 1: Using Hammer client (Recommended)
49
+
50
+ Before using vLLM, first clone the Hammer code repository and change directory to the 'Hammer':
51
+ ```
52
+ git clone https://github.com/MadeAgents/Hammer.git
53
+ cd Hammer
54
+ ```
55
+
56
+ vLLM offers efficient serving with lower latency. To serve the model with vLLM:
57
+ ```
58
+ vllm serve MadeAgents/Hammer2.1-3b --host 0.0.0.0 --port 8000 --tensor-parallel-size 1
59
+ ```
60
+ Once the model is served, you can use the following Hammer client to interact with it for function calling:
61
+ ~~~
62
+ from client import HammerChatCompletion,HammerConfig
63
+ config = HammerConfig(base_url="http://localhost:8000/v1/", model="MadeAgents/Hammer2.1-3b")
64
+ llm = HammerChatCompletion.from_config(config)
65
+
66
+ # Example conversation
67
+ messages = [
68
+ {"role": "user", "content": "What's the weather like in New York?"},
69
+ {"role": "assistant","content": '```\n{"name": "get_weather", "arguments": {"location": "New York, NY ", "unit": "celsius"}\n```'},
70
+ {"role": "tool", "name": "get_weather", "content": '{"temperature": 72, "description": "Partly cloudy"}'},
71
+ {"role": "user", "content": "Now, search for the weather in San Francisco."}
72
+ ]
73
+
74
+ # Example function definition (optional)
75
+ tools = [
76
+ {
77
+ "name": "get_weather",
78
+ "description": "Get the current weather for a location",
79
+ "parameters": {
80
+ "type": "object",
81
+ "properties": {
82
+ "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
83
+ "unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to return"}
84
+ },
85
+ "required": ["location"]
86
+ }
87
+ },
88
+ {
89
+ "name": "respond",
90
+ "description": "When you are ready to respond, use this function. This function allows the assistant to formulate and deliver appropriate replies based on the input message and the context of the conversation. Generate a concise response for simple questions, and a more detailed response for complex questions.",
91
+ "parameters": {
92
+ "type": "object",
93
+ "properties": {
94
+ "message": {"type": "string", "description": "The content of the message to respond to."}
95
+ },
96
+ "required": ["message"]
97
+ }
98
+ }
99
+ ]
100
+
101
+ response = llm.completion(messages, tools=tools)
102
+ print(response)
103
+ ~~~
104
+
105
+
106
+ #### Option 2: Using vLLM’s built-in tool calling
107
+ Hammer2.1 supports vllm’s built-in tool calling. This functionality requires vllm>=0.6. If you want to enable this functionality, please start vllm’s OpenAI-compatible service with:
108
+ ~~~
109
+ vllm serve MadeAgents/Hammer2.1-3b --enable-auto-tool-choice --tool-call-parser hermes
110
+ ~~~
111
+ And then use it in the same way you use GPT’s tool calling:
112
+ ~~~
113
+ tools = [
114
+ {
115
+ "type": "function",
116
+ "function": {
117
+ "name": "get_current_weather",
118
+ "description": "Get the current weather",
119
+ "parameters": {
120
+ "type": "object",
121
+ "properties": {
122
+ "location": {
123
+ "type": "string",
124
+ "description": "The city and state, e.g. San Francisco, CA",
125
+ },
126
+ "format": {
127
+ "type": "string",
128
+ "enum": ["celsius", "fahrenheit"],
129
+ "description": "The temperature unit to use. Infer this from the users location.",
130
+ "default": "celsius"
131
+ },
132
+ },
133
+ "required": ["location","format"],
134
+ },
135
+ }
136
+ },
137
+ {
138
+ "type": "function",
139
+ "function": {
140
+ "name": "get_n_day_weather_forecast",
141
+ "description": "Get an N-day weather forecast",
142
+ "parameters": {
143
+ "type": "object",
144
+ "properties": {
145
+ "location": {
146
+ "type": "string",
147
+ "description": "The city and state, e.g. San Francisco, CA",
148
+ },
149
+ "format": {
150
+ "type": "string",
151
+ "enum": ["celsius", "fahrenheit"],
152
+ "description": "The temperature unit to use. Infer this from the users location.",
153
+ "default": "celsius"
154
+ },
155
+ "num_days": {
156
+ "type": "integer",
157
+ "description": "The number of days to forecast",
158
+ "default": 1
159
+ }
160
+ },
161
+ "required": ["location", "format", "num_days"]
162
+ },
163
+ }
164
+ },
165
+ ]
166
+
167
+
168
+ from openai import OpenAI
169
+ openai_api_key = "None"
170
+ openai_api_base = "http://localhost:8000/v1"
171
+
172
+ client = OpenAI(
173
+ api_key=openai_api_key,
174
+ base_url=openai_api_base,
175
+ )
176
+
177
+ query = """What's the weather like today in San Francisco"""
178
+
179
+ chat_response = client.chat.completions.create(
180
+ model="MadeAgents/Hammer2.1-3b",
181
+ messages=[
182
+ {"role": "user", "content": query},],
183
+ tools = tools,
184
+ temperature=0
185
+ )
186
+ print(chat_response.choices[0].message.content)
187
+ ~~~
188
+
189
+
190
+ ### Using Hugging Face Transformers
191
+ Hammer2.1’s chat template also includes a tool calling template, meaning that you can use Hugging Face transformers’ tool calling support. This is a simple example of how to use our model using Transformers.
192
+ ~~~
193
+ import torch
194
+ from transformers import AutoModelForCausalLM, AutoTokenizer
195
+
196
+
197
+ tokenizer = AutoTokenizer.from_pretrained("MadeAgents/Hammer2.1-3b")
198
+ model = AutoModelForCausalLM.from_pretrained("MadeAgents/Hammer2.1-3b", torch_dtype=torch.bfloat16, device_map="auto")
199
+
200
+ # Example conversation
201
+ messages = [
202
+ {"role": "user", "content": "What's the weather like in New York?"},
203
+ {"role": "assistant","content": '```\n{"name": "get_weather", "arguments": {"location": "New York, NY ", "unit": "celsius"}\n```'},
204
+ {"role": "tool", "name": "get_weather", "content": '{"temperature": 72, "description": "Partly cloudy"}'},
205
+ {"role": "user", "content": "Now, search for the weather in San Francisco."}
206
+ ]
207
+
208
+ # Example function definition (optional)
209
+ tools = [
210
+ {
211
+ "name": "get_weather",
212
+ "description": "Get the current weather for a location",
213
+ "parameters": {
214
+ "type": "object",
215
+ "properties": {
216
+ "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
217
+ "unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to return"}
218
+ },
219
+ "required": ["location"]
220
+ }
221
+ },
222
+ {
223
+ "name": "respond",
224
+ "description": "When you are ready to respond, use this function. This function allows the assistant to formulate and deliver appropriate replies based on the input message and the context of the conversation. Generate a concise response for simple questions, and a more detailed response for complex questions.",
225
+ "parameters": {
226
+ "type": "object",
227
+ "properties": {
228
+ "message": {"type": "string", "description": "The content of the message to respond to."}
229
+ },
230
+ "required": ["message"]
231
+ }
232
+ }
233
+ ]
234
+
235
+ inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
236
+ inputs = {k: v.to(model.device) for k, v in inputs.items()}
237
+ out = model.generate(**inputs, max_new_tokens=128)
238
+ print(tokenizer.decode(out[0][len(inputs["input_ids"][0]):], skip_special_tokens=True))
239
+ ~~~
hammer2.1-3b-Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fa787cdc1d314dc73b35f6e882d045b76062d67e7e67b02121d2dac7cece218
3
+ size 1274295104
hammer2.1-3b-Q2_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33138ca1b75be48c03284340ae0a0074758163a5e815008c5ccc583293e9dbee
3
+ size 1197667136
hammer2.1-3b-Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52408af9d7d881e8bf71b881844debfe23b408d21bc8ccebbc98829680ba1eca
3
+ size 1590014784
hammer2.1-3b-Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:667723a1d374501974fbedde1ccc7014c6498aee75fc5abddc59820bc2fd4f60
3
+ size 1828025152
hammer2.1-3b-Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a42369a669dbab0be10f1e04d755e55eb103b4b1bb7b4dec8c0ce4cf6c12b98d
3
+ size 1929442112
hammer2.1-3b-Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bac437adc93b1996be5140e5946dc7fbae5d3ef9eced124a0d830d9e0e7a1562
3
+ size 2224354112
hammer2.1-3b-Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d5485e395b24bd25092f5ea5934a9af3a61cf1970635a79afbf9a7eeeb9e243
3
+ size 2537698112
hammer2.1-3b-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7367edbec88feb5587b0e5f17e5f356c62a7c440e7f199f84c9c48f957addac5
3
+ size 3284880928
hammer2.1-3b-f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28eefc018864f9fbd01e635d5dad523e30c4de19ffce96a62de7a51d129bc11a
3
+ size 6177201280
imatrix.dat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4232c085249d7ada5f761d58fa92ce05e865a4124bfbad89c7593ba1ffa0de0
3
+ size 3363009