lmmy commited on
Commit
81342a8
·
verified ·
1 Parent(s): a066148

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ tags:
4
+ - gemma3
5
+ - gemma
6
+ - google
7
+ - functiongemma
8
+ - mlx
9
+ pipeline_tag: text-generation
10
+ library_name: transformers
11
+ extra_gated_heading: Access Gemma on Hugging Face
12
+ extra_gated_prompt: To access FunctionGemma on Hugging Face, you’re required to review
13
+ and agree to Google’s usage license. To do this, please ensure you’re logged in
14
+ to Hugging Face and click below. Requests are processed immediately.
15
+ extra_gated_button_content: Acknowledge license
16
+ base_model: google/functiongemma-270m-it
17
+ ---
18
+ ## 💫 Community Model> functiongemma-270m-it by google
19
+
20
+ _👾 [LM Studio](https://lmstudio.ai) Community models highlights program. Highlighting new & noteworthy models by the community. Join the conversation on [Discord](https://discord.gg/aPQfnNkxGC)_.
21
+
22
+ **Model creator**: [google](https://huggingface.co/google)<br>
23
+ **Original model**: [functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)<br>
24
+ **MLX quantization**: provided by [LM Studio team](https://x.com/lmstudio) using [mlx_lm](https://github.com/ml-explore/mlx-lm)<br>
25
+
26
+ ## Technical Details
27
+
28
+ Original bfloat16 version of functiongemma-270m-it using MLX, optimized for Apple Silicon.
29
+
30
+ ## Special thanks
31
+
32
+ 🙏 Special thanks to the [Apple Machine Learning Research](https://github.com/ml-explore) team for creating [MLX](https://github.com/ml-explore/mlx).
33
+
34
+ ## Disclaimers
35
+
36
+ LM Studio is not the creator, originator, or owner of any Model featured in the Community Model Program. Each Community Model is created and provided by third parties. LM Studio does not endorse, support, represent or guarantee the completeness, truthfulness, accuracy, or reliability of any Community Model. You understand that Community Models can produce content that might be offensive, harmful, inaccurate or otherwise inappropriate, or deceptive. Each Community Model is the sole responsibility of the person or entity who originated such Model. LM Studio may not monitor or control the Community Models and cannot, and does not, take responsibility for any such Model. LM Studio disclaims all warranties or guarantees about the accuracy, reliability or benefits of the Community Models. LM Studio further disclaims any warranty that the Community Model will meet your requirements, be secure, uninterrupted or available at any time or location, or error-free, viruses-free, or that any errors will be corrected, or otherwise. You will be solely responsible for any damage resulting from your use of or access to the Community Models, your downloading of any Community Model, or use of any other Community Model provided by or through LM Studio.
chat_template.jinja ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro format_parameters(properties, required) -%}
2
+ {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
3
+ {%- set ns = namespace(found_first=false) -%}
4
+ {%- for key, value in properties | dictsort -%}
5
+ {%- if key not in standard_keys -%}
6
+ {%- if ns.found_first %},{% endif -%}
7
+ {%- set ns.found_first = true -%}
8
+ {{- key }}:{description:<escape>{{ value['description'] }}<escape>
9
+ {%- if value['type'] | upper == 'STRING' -%}
10
+ {%- if value['enum'] -%}
11
+ ,enum:{{ format_argument(value['enum']) }}
12
+ {%- endif -%}
13
+ {%- elif value['type'] | upper == 'OBJECT' -%}
14
+ ,properties:{
15
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
16
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
17
+ {%- elif value is mapping -%}
18
+ {{- format_parameters(value, value['required'] | default([])) -}}
19
+ {%- endif -%}
20
+ }
21
+ {%- if value['required'] -%}
22
+ ,required:[
23
+ {%- for item in value['required'] | default([]) -%}
24
+ <escape>{{- item -}}<escape>
25
+ {%- if not loop.last %},{% endif -%}
26
+ {%- endfor -%}
27
+ ]
28
+ {%- endif -%}
29
+ {%- elif value['type'] | upper == 'ARRAY' -%}
30
+ {%- if value['items'] is mapping and value['items'] -%}
31
+ ,items:{
32
+ {%- set ns_items = namespace(found_first=false) -%}
33
+ {%- for item_key, item_value in value['items'] | dictsort -%}
34
+ {%- if item_value is not none -%}
35
+ {%- if ns_items.found_first %},{% endif -%}
36
+ {%- set ns_items.found_first = true -%}
37
+ {%- if item_key == 'properties' -%}
38
+ properties:{
39
+ {%- if item_value is mapping -%}
40
+ {{- format_parameters(item_value, value['items']['required'] | default([])) -}}
41
+ {%- endif -%}
42
+ }
43
+ {%- elif item_key == 'required' -%}
44
+ required:[
45
+ {%- for req_item in item_value -%}
46
+ <escape>{{- req_item -}}<escape>
47
+ {%- if not loop.last %},{% endif -%}
48
+ {%- endfor -%}
49
+ ]
50
+ {%- elif item_key == 'type' -%}
51
+ {%- if item_value is string -%}
52
+ type:{{ format_argument(item_value | upper) }}
53
+ {%- else -%}
54
+ type:{{ format_argument(item_value | map('upper') | list) }}
55
+ {%- endif -%}
56
+ {%- else -%}
57
+ {{ item_key }}:{{ format_argument(item_value) }}
58
+ {%- endif -%}
59
+ {%- endif -%}
60
+ {%- endfor -%}
61
+ }
62
+ {%- endif -%}
63
+ {%- endif -%}
64
+ ,type:<escape>{{ value['type'] | upper }}<escape>}
65
+ {%- endif -%}
66
+ {%- endfor -%}
67
+ {%- endmacro -%}
68
+ {% macro format_function_declaration(tool_data) -%}
69
+ declaration:{{- tool_data['function']['name'] -}}
70
+ {description:<escape>{{- tool_data['function']['description'] -}}<escape>
71
+ {%- set params = tool_data['function']['parameters'] -%}
72
+ {%- if params -%}
73
+ ,parameters:{
74
+ {%- if params['properties'] -%}
75
+ properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
76
+ {%- endif -%}
77
+ {%- if params['required'] -%}
78
+ required:[
79
+ {%- for item in params['required'] -%}
80
+ <escape>{{- item -}}<escape>
81
+ {{- ',' if not loop.last -}}
82
+ {%- endfor -%}
83
+ ],
84
+ {%- endif -%}
85
+ {%- if params['type'] -%}
86
+ type:<escape>{{- params['type'] | upper -}}<escape>}
87
+ {%- endif -%}
88
+ {%- endif -%}
89
+ }
90
+ {%- endmacro -%}
91
+ {% macro format_argument(argument, escape_keys=True) -%}
92
+ {%- if argument is string -%}
93
+ {{- '<escape>' + argument + '<escape>' -}}
94
+ {%- elif argument is boolean -%}
95
+ {%- if argument -%}
96
+ {{- 'true' -}}
97
+ {%- else -%}
98
+ {{- 'false' -}}
99
+ {%- endif -%}
100
+ {%- elif argument is mapping -%}
101
+ {{- '{' -}}
102
+ {%- set ns = namespace(found_first=false) -%}
103
+ {%- for key, value in argument | dictsort -%}
104
+ {%- if ns.found_first %},{% endif -%}
105
+ {%- set ns.found_first = true -%}
106
+ {%- if escape_keys -%}
107
+ {{- '<escape>' + key + '<escape>' -}}
108
+ {%- else -%}
109
+ {{- key -}}
110
+ {%- endif -%}
111
+ :{{- format_argument(value, escape_keys=escape_keys) -}}
112
+ {%- endfor -%}
113
+ {{- '}' -}}
114
+ {%- elif argument is sequence -%}
115
+ {{- '[' -}}
116
+ {%- for item in argument -%}
117
+ {{- format_argument(item, escape_keys=escape_keys) -}}
118
+ {%- if not loop.last %},{% endif -%}
119
+ {%- endfor -%}
120
+ {{- ']' -}}
121
+ {%- else -%}
122
+ {{- argument -}}
123
+ {%- endif -%}
124
+ {%- endmacro -%}
125
+ {{ bos_token }}
126
+ {%- set ns = namespace(prev_message_type=None) -%}
127
+ {#- Tool Declarations -#}
128
+ {%- set loop_messages = messages -%}
129
+ {%- if tools or messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}
130
+ {{- '<start_of_turn>developer\n' -}}
131
+ {%- if messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}
132
+ {%- if messages[0]['content'] is string -%}
133
+ {{- messages[0]['content'] | trim -}}
134
+ {%- elif messages[0]['content'] is sequence -%}
135
+ {%- for item in messages[0]['content'] -%}
136
+ {%- if item['type'] == 'text' -%}
137
+ {{- item['text'] | trim -}}
138
+ {%- endif -%}
139
+ {%- endfor -%}
140
+ {%- endif -%}
141
+ {%- set loop_messages = messages[1:] -%}
142
+ {%- endif -%}
143
+ {%- if tools -%}
144
+ {%- for tool in tools %}
145
+ {{- '<start_function_declaration>' -}}
146
+ {{- format_function_declaration(tool) | trim }}
147
+ {{- '<end_function_declaration>' -}}
148
+ {%- endfor %}
149
+ {%- endif -%}
150
+ {{- '<end_of_turn>\n' }}
151
+ {%- endif %}
152
+ {#- Loop through messages. -#}
153
+ {%- for message in loop_messages -%}
154
+ {%- if (message['role'] == 'assistant') -%}
155
+ {#- Rename "assistant" to "model". -#}
156
+ {%- set role = "model" -%}
157
+ {%- else -%}
158
+ {%- set role = message['role'] -%}
159
+ {%- endif -%}
160
+ {%- if role != 'tool' -%}
161
+ {%- if ns.prev_message_type != 'tool_response' -%}
162
+ {{- '<start_of_turn>' + role + '\n' }}
163
+ {%- endif -%}
164
+ {%- set ns.prev_message_type = None -%}
165
+ {%- if 'content' in message and message['content'] is not none -%}
166
+ {%- if message['content'] is string -%}
167
+ {{ message['content'] | trim }}
168
+ {%- elif message['content'] is sequence -%}
169
+ {%- for item in message['content'] -%}
170
+ {%- if item['type'] == 'image' -%}
171
+ {{ '<start_of_image>' }}
172
+ {%- elif item['type'] == 'text' -%}
173
+ {{ item['text'] | trim }}
174
+ {%- endif -%}
175
+ {%- endfor -%}
176
+ {%- else -%}
177
+ {{ raise_exception("Invalid content type in user/assistant message") }}
178
+ {%- endif -%}
179
+ {%- set ns.prev_message_type = 'content' -%}
180
+ {%- endif -%}
181
+ {%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls'] is iterable -%}
182
+ {#- Tool Calls -#}
183
+ {%- for tool_call in message['tool_calls'] -%}
184
+ {% set function = tool_call['function'] %}
185
+ {{- '<start_function_call>call:' + function['name'] + '{' -}}
186
+ {%- if 'arguments' in function -%}
187
+ {%- if function['arguments'] is mapping -%}
188
+ {%- set ns = namespace(found_first=false) -%}
189
+ {%- for key, value in function['arguments'] | dictsort -%}
190
+ {%- if ns.found_first %},{% endif -%}
191
+ {%- set ns.found_first = true -%}
192
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
193
+ {%- endfor -%}
194
+ {%- elif function['arguments'] is string -%}
195
+ {# This handles string-JSON, just in case #}
196
+ {{ function['arguments'] }}
197
+ {%- endif %}
198
+ {%- endif -%}
199
+ {{- '}<end_function_call>' -}}
200
+ {%- endfor -%}
201
+ {%- if loop.last -%}
202
+ {{ '<start_function_response>' }}
203
+ {%- endif -%}
204
+ {%- set ns.prev_message_type = 'tool_call' -%}
205
+ {%- endif -%}
206
+ {%- else -%}
207
+ {#- Tool Responses -#}
208
+ {%- if 'content' in message and message['content'] -%}
209
+ {%- if message['content'] is mapping -%}
210
+ {%- if 'name' in message['content'] and 'response' in message['content'] -%}
211
+ {{ '<start_function_response>response:' + message['content']['name'] | trim + '{' }}
212
+ {%- set response_ns = namespace(found_first=false) -%}
213
+ {%- for key, value in message['content']['response'] | dictsort -%}
214
+ {%- if response_ns.found_first %},{% endif -%}
215
+ {%- set response_ns.found_first = true -%}
216
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
217
+ {%- endfor -%}
218
+ {{- '}<end_function_response>' -}}
219
+ {%- elif 'name' in message -%}
220
+ {{ '<start_function_response>response:' + message['name'] | trim + '{' }}
221
+ {%- set response_ns = namespace(found_first=false) -%}
222
+ {%- for key, value in message['content'] | dictsort -%}
223
+ {%- if response_ns.found_first %},{% endif -%}
224
+ {%- set response_ns.found_first = true -%}
225
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
226
+ {%- endfor -%}
227
+ {{- '}<end_function_response>' -}}
228
+ {%- else -%}
229
+ {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }}
230
+ {%- endif -%}
231
+ {%- elif message['content'] is string -%}
232
+ {%- if 'name' in message -%}
233
+ {{ '<start_function_response>response:' + message['name'] | trim + '{value:' + format_argument(message['content'], escape_keys=False) + '}<end_function_response>' }}
234
+ {%- else -%}
235
+ {{ raise_exception("Invalid tool response: 'name' must be provided.") }}
236
+ {%- endif -%}
237
+ {%- elif message['content'] is sequence -%}
238
+ {%- for item in message['content'] -%}
239
+ {%- if item is mapping -%}
240
+ {%- if 'name' in item and 'response' in item -%}
241
+ {{ '<start_function_response>response:' + item['name'] | trim + '{' }}
242
+ {%- set response_ns = namespace(found_first=false) -%}
243
+ {%- for key, value in item['response'] | dictsort -%}
244
+ {%- if response_ns.found_first %},{% endif -%}
245
+ {%- set response_ns.found_first = true -%}
246
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
247
+ {%- endfor -%}
248
+ {{- '}<end_function_response>' -}}
249
+ {%- elif 'name' in message -%}
250
+ {{ '<start_function_response>response:' + message['name'] | trim + '{' }}
251
+ {%- set response_ns = namespace(found_first=false) -%}
252
+ {%- for key, value in item | dictsort -%}
253
+ {%- if response_ns.found_first %},{% endif -%}
254
+ {%- set response_ns.found_first = true -%}
255
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
256
+ {%- endfor -%}
257
+ {{- '}<end_function_response>' -}}
258
+ {%- else -%}
259
+ {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }}
260
+ {%- endif -%}
261
+ {%- else -%}
262
+ {{ raise_exception("Invalid tool response message: multiple responses must all be mappings") }}
263
+ {%- endif -%}
264
+ {%- endfor -%}
265
+ {%- else -%}
266
+ {{ raise_exception("Invalid content type in tool message: must be mapping, sequence of mappings, or string.") }}
267
+ {%- endif -%}
268
+ {%- endif -%}
269
+ {%- set ns.prev_message_type = 'tool_response' -%}
270
+ {%- endif -%}
271
+ {%- if ns.prev_message_type not in ['tool_call', 'tool_response'] -%}
272
+ {{ '<end_of_turn>\n' }}
273
+ {%- endif -%}
274
+ {%- endfor -%}
275
+ {%- if add_generation_prompt -%}
276
+ {%- if ns.prev_message_type != 'tool_response' -%}
277
+ {{- '<start_of_turn>model\n' -}}
278
+ {%- endif -%}
279
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_sliding_window_pattern": 6,
3
+ "architectures": [
4
+ "Gemma3ForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "attn_logit_softcapping": null,
9
+ "bos_token_id": 2,
10
+ "dtype": "bfloat16",
11
+ "eos_token_id": [
12
+ 1,
13
+ 50
14
+ ],
15
+ "final_logit_softcapping": null,
16
+ "head_dim": 256,
17
+ "hidden_activation": "gelu_pytorch_tanh",
18
+ "hidden_size": 640,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 2048,
21
+ "layer_types": [
22
+ "sliding_attention",
23
+ "sliding_attention",
24
+ "sliding_attention",
25
+ "sliding_attention",
26
+ "sliding_attention",
27
+ "full_attention",
28
+ "sliding_attention",
29
+ "sliding_attention",
30
+ "sliding_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "full_attention",
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "full_attention"
40
+ ],
41
+ "max_position_embeddings": 32768,
42
+ "model_type": "gemma3_text",
43
+ "num_attention_heads": 4,
44
+ "num_hidden_layers": 18,
45
+ "num_key_value_heads": 1,
46
+ "pad_token_id": 0,
47
+ "query_pre_attn_scalar": 256,
48
+ "rms_norm_eps": 1e-06,
49
+ "rope_local_base_freq": 10000.0,
50
+ "rope_parameters": null,
51
+ "rope_scaling": null,
52
+ "rope_theta": 1000000.0,
53
+ "sliding_window": 512,
54
+ "transformers_version": "4.57.3",
55
+ "use_bidirectional_attention": false,
56
+ "use_cache": true,
57
+ "vocab_size": 262144
58
+ }
generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cache_implementation": "hybrid",
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 1,
6
+ 50,
7
+ 106
8
+ ],
9
+ "top_k": 64,
10
+ "top_p": 0.95,
11
+ "transformers_version": "4.57.3"
12
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b28331584ea946bf1adc4d2f73f117c14ba1a4f6d237b1d7d44bd0f38ef3322
3
+ size 536222762
model.safetensors.index.json ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 536196352,
4
+ "total_parameters": 268098176
5
+ },
6
+ "weight_map": {
7
+ "model.embed_tokens.weight": "model.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model.safetensors",
13
+ "model.layers.0.post_feedforward_layernorm.weight": "model.safetensors",
14
+ "model.layers.0.pre_feedforward_layernorm.weight": "model.safetensors",
15
+ "model.layers.0.self_attn.k_norm.weight": "model.safetensors",
16
+ "model.layers.0.self_attn.k_proj.weight": "model.safetensors",
17
+ "model.layers.0.self_attn.o_proj.weight": "model.safetensors",
18
+ "model.layers.0.self_attn.q_norm.weight": "model.safetensors",
19
+ "model.layers.0.self_attn.q_proj.weight": "model.safetensors",
20
+ "model.layers.0.self_attn.v_proj.weight": "model.safetensors",
21
+ "model.layers.1.input_layernorm.weight": "model.safetensors",
22
+ "model.layers.1.mlp.down_proj.weight": "model.safetensors",
23
+ "model.layers.1.mlp.gate_proj.weight": "model.safetensors",
24
+ "model.layers.1.mlp.up_proj.weight": "model.safetensors",
25
+ "model.layers.1.post_attention_layernorm.weight": "model.safetensors",
26
+ "model.layers.1.post_feedforward_layernorm.weight": "model.safetensors",
27
+ "model.layers.1.pre_feedforward_layernorm.weight": "model.safetensors",
28
+ "model.layers.1.self_attn.k_norm.weight": "model.safetensors",
29
+ "model.layers.1.self_attn.k_proj.weight": "model.safetensors",
30
+ "model.layers.1.self_attn.o_proj.weight": "model.safetensors",
31
+ "model.layers.1.self_attn.q_norm.weight": "model.safetensors",
32
+ "model.layers.1.self_attn.q_proj.weight": "model.safetensors",
33
+ "model.layers.1.self_attn.v_proj.weight": "model.safetensors",
34
+ "model.layers.10.input_layernorm.weight": "model.safetensors",
35
+ "model.layers.10.mlp.down_proj.weight": "model.safetensors",
36
+ "model.layers.10.mlp.gate_proj.weight": "model.safetensors",
37
+ "model.layers.10.mlp.up_proj.weight": "model.safetensors",
38
+ "model.layers.10.post_attention_layernorm.weight": "model.safetensors",
39
+ "model.layers.10.post_feedforward_layernorm.weight": "model.safetensors",
40
+ "model.layers.10.pre_feedforward_layernorm.weight": "model.safetensors",
41
+ "model.layers.10.self_attn.k_norm.weight": "model.safetensors",
42
+ "model.layers.10.self_attn.k_proj.weight": "model.safetensors",
43
+ "model.layers.10.self_attn.o_proj.weight": "model.safetensors",
44
+ "model.layers.10.self_attn.q_norm.weight": "model.safetensors",
45
+ "model.layers.10.self_attn.q_proj.weight": "model.safetensors",
46
+ "model.layers.10.self_attn.v_proj.weight": "model.safetensors",
47
+ "model.layers.11.input_layernorm.weight": "model.safetensors",
48
+ "model.layers.11.mlp.down_proj.weight": "model.safetensors",
49
+ "model.layers.11.mlp.gate_proj.weight": "model.safetensors",
50
+ "model.layers.11.mlp.up_proj.weight": "model.safetensors",
51
+ "model.layers.11.post_attention_layernorm.weight": "model.safetensors",
52
+ "model.layers.11.post_feedforward_layernorm.weight": "model.safetensors",
53
+ "model.layers.11.pre_feedforward_layernorm.weight": "model.safetensors",
54
+ "model.layers.11.self_attn.k_norm.weight": "model.safetensors",
55
+ "model.layers.11.self_attn.k_proj.weight": "model.safetensors",
56
+ "model.layers.11.self_attn.o_proj.weight": "model.safetensors",
57
+ "model.layers.11.self_attn.q_norm.weight": "model.safetensors",
58
+ "model.layers.11.self_attn.q_proj.weight": "model.safetensors",
59
+ "model.layers.11.self_attn.v_proj.weight": "model.safetensors",
60
+ "model.layers.12.input_layernorm.weight": "model.safetensors",
61
+ "model.layers.12.mlp.down_proj.weight": "model.safetensors",
62
+ "model.layers.12.mlp.gate_proj.weight": "model.safetensors",
63
+ "model.layers.12.mlp.up_proj.weight": "model.safetensors",
64
+ "model.layers.12.post_attention_layernorm.weight": "model.safetensors",
65
+ "model.layers.12.post_feedforward_layernorm.weight": "model.safetensors",
66
+ "model.layers.12.pre_feedforward_layernorm.weight": "model.safetensors",
67
+ "model.layers.12.self_attn.k_norm.weight": "model.safetensors",
68
+ "model.layers.12.self_attn.k_proj.weight": "model.safetensors",
69
+ "model.layers.12.self_attn.o_proj.weight": "model.safetensors",
70
+ "model.layers.12.self_attn.q_norm.weight": "model.safetensors",
71
+ "model.layers.12.self_attn.q_proj.weight": "model.safetensors",
72
+ "model.layers.12.self_attn.v_proj.weight": "model.safetensors",
73
+ "model.layers.13.input_layernorm.weight": "model.safetensors",
74
+ "model.layers.13.mlp.down_proj.weight": "model.safetensors",
75
+ "model.layers.13.mlp.gate_proj.weight": "model.safetensors",
76
+ "model.layers.13.mlp.up_proj.weight": "model.safetensors",
77
+ "model.layers.13.post_attention_layernorm.weight": "model.safetensors",
78
+ "model.layers.13.post_feedforward_layernorm.weight": "model.safetensors",
79
+ "model.layers.13.pre_feedforward_layernorm.weight": "model.safetensors",
80
+ "model.layers.13.self_attn.k_norm.weight": "model.safetensors",
81
+ "model.layers.13.self_attn.k_proj.weight": "model.safetensors",
82
+ "model.layers.13.self_attn.o_proj.weight": "model.safetensors",
83
+ "model.layers.13.self_attn.q_norm.weight": "model.safetensors",
84
+ "model.layers.13.self_attn.q_proj.weight": "model.safetensors",
85
+ "model.layers.13.self_attn.v_proj.weight": "model.safetensors",
86
+ "model.layers.14.input_layernorm.weight": "model.safetensors",
87
+ "model.layers.14.mlp.down_proj.weight": "model.safetensors",
88
+ "model.layers.14.mlp.gate_proj.weight": "model.safetensors",
89
+ "model.layers.14.mlp.up_proj.weight": "model.safetensors",
90
+ "model.layers.14.post_attention_layernorm.weight": "model.safetensors",
91
+ "model.layers.14.post_feedforward_layernorm.weight": "model.safetensors",
92
+ "model.layers.14.pre_feedforward_layernorm.weight": "model.safetensors",
93
+ "model.layers.14.self_attn.k_norm.weight": "model.safetensors",
94
+ "model.layers.14.self_attn.k_proj.weight": "model.safetensors",
95
+ "model.layers.14.self_attn.o_proj.weight": "model.safetensors",
96
+ "model.layers.14.self_attn.q_norm.weight": "model.safetensors",
97
+ "model.layers.14.self_attn.q_proj.weight": "model.safetensors",
98
+ "model.layers.14.self_attn.v_proj.weight": "model.safetensors",
99
+ "model.layers.15.input_layernorm.weight": "model.safetensors",
100
+ "model.layers.15.mlp.down_proj.weight": "model.safetensors",
101
+ "model.layers.15.mlp.gate_proj.weight": "model.safetensors",
102
+ "model.layers.15.mlp.up_proj.weight": "model.safetensors",
103
+ "model.layers.15.post_attention_layernorm.weight": "model.safetensors",
104
+ "model.layers.15.post_feedforward_layernorm.weight": "model.safetensors",
105
+ "model.layers.15.pre_feedforward_layernorm.weight": "model.safetensors",
106
+ "model.layers.15.self_attn.k_norm.weight": "model.safetensors",
107
+ "model.layers.15.self_attn.k_proj.weight": "model.safetensors",
108
+ "model.layers.15.self_attn.o_proj.weight": "model.safetensors",
109
+ "model.layers.15.self_attn.q_norm.weight": "model.safetensors",
110
+ "model.layers.15.self_attn.q_proj.weight": "model.safetensors",
111
+ "model.layers.15.self_attn.v_proj.weight": "model.safetensors",
112
+ "model.layers.16.input_layernorm.weight": "model.safetensors",
113
+ "model.layers.16.mlp.down_proj.weight": "model.safetensors",
114
+ "model.layers.16.mlp.gate_proj.weight": "model.safetensors",
115
+ "model.layers.16.mlp.up_proj.weight": "model.safetensors",
116
+ "model.layers.16.post_attention_layernorm.weight": "model.safetensors",
117
+ "model.layers.16.post_feedforward_layernorm.weight": "model.safetensors",
118
+ "model.layers.16.pre_feedforward_layernorm.weight": "model.safetensors",
119
+ "model.layers.16.self_attn.k_norm.weight": "model.safetensors",
120
+ "model.layers.16.self_attn.k_proj.weight": "model.safetensors",
121
+ "model.layers.16.self_attn.o_proj.weight": "model.safetensors",
122
+ "model.layers.16.self_attn.q_norm.weight": "model.safetensors",
123
+ "model.layers.16.self_attn.q_proj.weight": "model.safetensors",
124
+ "model.layers.16.self_attn.v_proj.weight": "model.safetensors",
125
+ "model.layers.17.input_layernorm.weight": "model.safetensors",
126
+ "model.layers.17.mlp.down_proj.weight": "model.safetensors",
127
+ "model.layers.17.mlp.gate_proj.weight": "model.safetensors",
128
+ "model.layers.17.mlp.up_proj.weight": "model.safetensors",
129
+ "model.layers.17.post_attention_layernorm.weight": "model.safetensors",
130
+ "model.layers.17.post_feedforward_layernorm.weight": "model.safetensors",
131
+ "model.layers.17.pre_feedforward_layernorm.weight": "model.safetensors",
132
+ "model.layers.17.self_attn.k_norm.weight": "model.safetensors",
133
+ "model.layers.17.self_attn.k_proj.weight": "model.safetensors",
134
+ "model.layers.17.self_attn.o_proj.weight": "model.safetensors",
135
+ "model.layers.17.self_attn.q_norm.weight": "model.safetensors",
136
+ "model.layers.17.self_attn.q_proj.weight": "model.safetensors",
137
+ "model.layers.17.self_attn.v_proj.weight": "model.safetensors",
138
+ "model.layers.2.input_layernorm.weight": "model.safetensors",
139
+ "model.layers.2.mlp.down_proj.weight": "model.safetensors",
140
+ "model.layers.2.mlp.gate_proj.weight": "model.safetensors",
141
+ "model.layers.2.mlp.up_proj.weight": "model.safetensors",
142
+ "model.layers.2.post_attention_layernorm.weight": "model.safetensors",
143
+ "model.layers.2.post_feedforward_layernorm.weight": "model.safetensors",
144
+ "model.layers.2.pre_feedforward_layernorm.weight": "model.safetensors",
145
+ "model.layers.2.self_attn.k_norm.weight": "model.safetensors",
146
+ "model.layers.2.self_attn.k_proj.weight": "model.safetensors",
147
+ "model.layers.2.self_attn.o_proj.weight": "model.safetensors",
148
+ "model.layers.2.self_attn.q_norm.weight": "model.safetensors",
149
+ "model.layers.2.self_attn.q_proj.weight": "model.safetensors",
150
+ "model.layers.2.self_attn.v_proj.weight": "model.safetensors",
151
+ "model.layers.3.input_layernorm.weight": "model.safetensors",
152
+ "model.layers.3.mlp.down_proj.weight": "model.safetensors",
153
+ "model.layers.3.mlp.gate_proj.weight": "model.safetensors",
154
+ "model.layers.3.mlp.up_proj.weight": "model.safetensors",
155
+ "model.layers.3.post_attention_layernorm.weight": "model.safetensors",
156
+ "model.layers.3.post_feedforward_layernorm.weight": "model.safetensors",
157
+ "model.layers.3.pre_feedforward_layernorm.weight": "model.safetensors",
158
+ "model.layers.3.self_attn.k_norm.weight": "model.safetensors",
159
+ "model.layers.3.self_attn.k_proj.weight": "model.safetensors",
160
+ "model.layers.3.self_attn.o_proj.weight": "model.safetensors",
161
+ "model.layers.3.self_attn.q_norm.weight": "model.safetensors",
162
+ "model.layers.3.self_attn.q_proj.weight": "model.safetensors",
163
+ "model.layers.3.self_attn.v_proj.weight": "model.safetensors",
164
+ "model.layers.4.input_layernorm.weight": "model.safetensors",
165
+ "model.layers.4.mlp.down_proj.weight": "model.safetensors",
166
+ "model.layers.4.mlp.gate_proj.weight": "model.safetensors",
167
+ "model.layers.4.mlp.up_proj.weight": "model.safetensors",
168
+ "model.layers.4.post_attention_layernorm.weight": "model.safetensors",
169
+ "model.layers.4.post_feedforward_layernorm.weight": "model.safetensors",
170
+ "model.layers.4.pre_feedforward_layernorm.weight": "model.safetensors",
171
+ "model.layers.4.self_attn.k_norm.weight": "model.safetensors",
172
+ "model.layers.4.self_attn.k_proj.weight": "model.safetensors",
173
+ "model.layers.4.self_attn.o_proj.weight": "model.safetensors",
174
+ "model.layers.4.self_attn.q_norm.weight": "model.safetensors",
175
+ "model.layers.4.self_attn.q_proj.weight": "model.safetensors",
176
+ "model.layers.4.self_attn.v_proj.weight": "model.safetensors",
177
+ "model.layers.5.input_layernorm.weight": "model.safetensors",
178
+ "model.layers.5.mlp.down_proj.weight": "model.safetensors",
179
+ "model.layers.5.mlp.gate_proj.weight": "model.safetensors",
180
+ "model.layers.5.mlp.up_proj.weight": "model.safetensors",
181
+ "model.layers.5.post_attention_layernorm.weight": "model.safetensors",
182
+ "model.layers.5.post_feedforward_layernorm.weight": "model.safetensors",
183
+ "model.layers.5.pre_feedforward_layernorm.weight": "model.safetensors",
184
+ "model.layers.5.self_attn.k_norm.weight": "model.safetensors",
185
+ "model.layers.5.self_attn.k_proj.weight": "model.safetensors",
186
+ "model.layers.5.self_attn.o_proj.weight": "model.safetensors",
187
+ "model.layers.5.self_attn.q_norm.weight": "model.safetensors",
188
+ "model.layers.5.self_attn.q_proj.weight": "model.safetensors",
189
+ "model.layers.5.self_attn.v_proj.weight": "model.safetensors",
190
+ "model.layers.6.input_layernorm.weight": "model.safetensors",
191
+ "model.layers.6.mlp.down_proj.weight": "model.safetensors",
192
+ "model.layers.6.mlp.gate_proj.weight": "model.safetensors",
193
+ "model.layers.6.mlp.up_proj.weight": "model.safetensors",
194
+ "model.layers.6.post_attention_layernorm.weight": "model.safetensors",
195
+ "model.layers.6.post_feedforward_layernorm.weight": "model.safetensors",
196
+ "model.layers.6.pre_feedforward_layernorm.weight": "model.safetensors",
197
+ "model.layers.6.self_attn.k_norm.weight": "model.safetensors",
198
+ "model.layers.6.self_attn.k_proj.weight": "model.safetensors",
199
+ "model.layers.6.self_attn.o_proj.weight": "model.safetensors",
200
+ "model.layers.6.self_attn.q_norm.weight": "model.safetensors",
201
+ "model.layers.6.self_attn.q_proj.weight": "model.safetensors",
202
+ "model.layers.6.self_attn.v_proj.weight": "model.safetensors",
203
+ "model.layers.7.input_layernorm.weight": "model.safetensors",
204
+ "model.layers.7.mlp.down_proj.weight": "model.safetensors",
205
+ "model.layers.7.mlp.gate_proj.weight": "model.safetensors",
206
+ "model.layers.7.mlp.up_proj.weight": "model.safetensors",
207
+ "model.layers.7.post_attention_layernorm.weight": "model.safetensors",
208
+ "model.layers.7.post_feedforward_layernorm.weight": "model.safetensors",
209
+ "model.layers.7.pre_feedforward_layernorm.weight": "model.safetensors",
210
+ "model.layers.7.self_attn.k_norm.weight": "model.safetensors",
211
+ "model.layers.7.self_attn.k_proj.weight": "model.safetensors",
212
+ "model.layers.7.self_attn.o_proj.weight": "model.safetensors",
213
+ "model.layers.7.self_attn.q_norm.weight": "model.safetensors",
214
+ "model.layers.7.self_attn.q_proj.weight": "model.safetensors",
215
+ "model.layers.7.self_attn.v_proj.weight": "model.safetensors",
216
+ "model.layers.8.input_layernorm.weight": "model.safetensors",
217
+ "model.layers.8.mlp.down_proj.weight": "model.safetensors",
218
+ "model.layers.8.mlp.gate_proj.weight": "model.safetensors",
219
+ "model.layers.8.mlp.up_proj.weight": "model.safetensors",
220
+ "model.layers.8.post_attention_layernorm.weight": "model.safetensors",
221
+ "model.layers.8.post_feedforward_layernorm.weight": "model.safetensors",
222
+ "model.layers.8.pre_feedforward_layernorm.weight": "model.safetensors",
223
+ "model.layers.8.self_attn.k_norm.weight": "model.safetensors",
224
+ "model.layers.8.self_attn.k_proj.weight": "model.safetensors",
225
+ "model.layers.8.self_attn.o_proj.weight": "model.safetensors",
226
+ "model.layers.8.self_attn.q_norm.weight": "model.safetensors",
227
+ "model.layers.8.self_attn.q_proj.weight": "model.safetensors",
228
+ "model.layers.8.self_attn.v_proj.weight": "model.safetensors",
229
+ "model.layers.9.input_layernorm.weight": "model.safetensors",
230
+ "model.layers.9.mlp.down_proj.weight": "model.safetensors",
231
+ "model.layers.9.mlp.gate_proj.weight": "model.safetensors",
232
+ "model.layers.9.mlp.up_proj.weight": "model.safetensors",
233
+ "model.layers.9.post_attention_layernorm.weight": "model.safetensors",
234
+ "model.layers.9.post_feedforward_layernorm.weight": "model.safetensors",
235
+ "model.layers.9.pre_feedforward_layernorm.weight": "model.safetensors",
236
+ "model.layers.9.self_attn.k_norm.weight": "model.safetensors",
237
+ "model.layers.9.self_attn.k_proj.weight": "model.safetensors",
238
+ "model.layers.9.self_attn.o_proj.weight": "model.safetensors",
239
+ "model.layers.9.self_attn.q_norm.weight": "model.safetensors",
240
+ "model.layers.9.self_attn.q_proj.weight": "model.safetensors",
241
+ "model.layers.9.self_attn.v_proj.weight": "model.safetensors",
242
+ "model.norm.weight": "model.safetensors"
243
+ }
244
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b83627b470a2b3eeb6cbd480490191e50f21549cb3de1d0fcc1a001a48c6c04
3
+ size 33378493
tokenizer_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": null,
3
+ "backend": "tokenizers",
4
+ "boi_token": "<start_of_image>",
5
+ "bos_token": "<bos>",
6
+ "clean_up_tokenization_spaces": false,
7
+ "eoi_token": "<end_of_image>",
8
+ "eos_token": "<eos>",
9
+ "image_token": "<image_soft_token>",
10
+ "is_local": true,
11
+ "mask_token": "<mask>",
12
+ "model_max_length": 1000000000000000019884624838656,
13
+ "model_specific_special_tokens": {
14
+ "boi_token": "<start_of_image>",
15
+ "eoi_token": "<end_of_image>",
16
+ "image_token": "<image_soft_token>",
17
+ "sfr_token": "<start_function_response>"
18
+ },
19
+ "pad_token": "<pad>",
20
+ "padding_side": "left",
21
+ "sfr_token": "<start_function_response>",
22
+ "sp_model_kwargs": null,
23
+ "spaces_between_special_tokens": false,
24
+ "tokenizer_class": "GemmaTokenizer",
25
+ "unk_token": "<unk>",
26
+ "use_default_system_prompt": false,
27
+ "chat_template": "{%- macro format_parameters(properties, required) -%}\n {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in properties | dictsort -%}\n {%- if key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{- key }}:{description:<escape>{{ value['description'] }}<escape>\n {%- if value['type'] | upper == 'STRING' -%}\n {%- if value['enum'] -%}\n ,enum:{{ format_argument(value['enum']) }}\n {%- endif -%}\n {%- elif value['type'] | upper == 'OBJECT' -%}\n ,properties:{\n {%- if value['properties'] is defined and value['properties'] is mapping -%}\n {{- format_parameters(value['properties'], value['required'] | default([])) -}}\n {%- elif value is mapping -%}\n {{- format_parameters(value, value['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- if value['required'] -%}\n ,required:[\n {%- for item in value['required'] | default([]) -%}\n <escape>{{- item -}}<escape>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- endif -%}\n {%- elif value['type'] | upper == 'ARRAY' -%}\n {%- if value['items'] is mapping and value['items'] -%}\n ,items:{\n {%- set ns_items = namespace(found_first=false) -%}\n {%- for item_key, item_value in value['items'] | dictsort -%}\n {%- if item_value is not none -%}\n {%- if ns_items.found_first %},{% endif -%}\n {%- set ns_items.found_first = true -%}\n {%- if item_key == 'properties' -%}\n properties:{\n {%- if item_value is mapping -%}\n {{- format_parameters(item_value, value['items']['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- elif item_key == 'required' -%}\n required:[\n {%- for req_item in item_value -%}\n <escape>{{- req_item -}}<escape>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- elif item_key == 'type' -%}\n {%- if item_value is string -%}\n type:{{ format_argument(item_value | upper) }}\n {%- else -%}\n type:{{ format_argument(item_value | map('upper') | list) }}\n {%- endif -%}\n {%- else -%}\n {{ item_key }}:{{ format_argument(item_value) }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n }\n {%- endif -%}\n {%- endif -%}\n ,type:<escape>{{ value['type'] | upper }}<escape>}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{% macro format_function_declaration(tool_data) -%}\ndeclaration:{{- tool_data['function']['name'] -}}\n{description:<escape>{{- tool_data['function']['description'] -}}<escape>\n{%- set params = tool_data['function']['parameters'] -%}\n{%- if params -%}\n ,parameters:{\n {%- if params['properties'] -%}\n properties:{ {{- format_parameters(params['properties'], params['required']) -}} },\n {%- endif -%}\n {%- if params['required'] -%}\n required:[\n {%- for item in params['required'] -%}\n <escape>{{- item -}}<escape>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:<escape>{{- params['type'] | upper -}}<escape>}\n {%- endif -%}\n{%- endif -%}\n}\n{%- endmacro -%}\n{% macro format_argument(argument, escape_keys=True) -%}\n{%- if argument is string -%}\n {{- '<escape>' + argument + '<escape>' -}}\n{%- elif argument is boolean -%}\n {%- if argument -%}\n {{- 'true' -}}\n {%- else -%}\n {{- 'false' -}}\n {%- endif -%}\n{%- elif argument is mapping -%}\n {{- '{' -}}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in argument | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- if escape_keys -%}\n {{- '<escape>' + key + '<escape>' -}}\n {%- else -%}\n {{- key -}}\n {%- endif -%}\n :{{- format_argument(value, escape_keys=escape_keys) -}}\n {%- endfor -%}\n {{- '}' -}}\n{%- elif argument is sequence -%}\n {{- '[' -}}\n {%- for item in argument -%}\n {{- format_argument(item, escape_keys=escape_keys) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- ']' -}}\n{%- else -%}\n {{- argument -}}\n{%- endif -%}\n{%- endmacro -%}\n{{ bos_token }}\n{%- set ns = namespace(prev_message_type=None) -%}\n{#- Tool Declarations -#}\n{%- set loop_messages = messages -%}\n{%- if tools or messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}\n {{- '<start_of_turn>developer\\n' -}}\n {%- if messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}\n {%- if messages[0]['content'] is string -%}\n {{- messages[0]['content'] | trim -}}\n {%- elif messages[0]['content'] is sequence -%}\n {%- for item in messages[0]['content'] -%}\n {%- if item['type'] == 'text' -%}\n {{- item['text'] | trim -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- set loop_messages = messages[1:] -%}\n {%- endif -%}\n {%- if tools -%}\n {%- for tool in tools %}\n {{- '<start_function_declaration>' -}}\n {{- format_function_declaration(tool) | trim }}\n {{- '<end_function_declaration>' -}}\n {%- endfor %}\n {%- endif -%}\n {{- '<end_of_turn>\\n' }}\n{%- endif %}\n{#- Loop through messages. -#}\n{%- for message in loop_messages -%}\n {%- if (message['role'] == 'assistant') -%}\n {#- Rename \"assistant\" to \"model\". -#}\n {%- set role = \"model\" -%}\n {%- else -%}\n {%- set role = message['role'] -%}\n {%- endif -%}\n {%- if role != 'tool' -%}\n {%- if ns.prev_message_type != 'tool_response' -%}\n {{- '<start_of_turn>' + role + '\\n' }}\n {%- endif -%}\n {%- set ns.prev_message_type = None -%}\n {%- if 'content' in message and message['content'] is not none -%}\n {%- if message['content'] is string -%}\n {{ message['content'] | trim }}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item['type'] == 'text' -%}\n {{ item['text'] | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type in user/assistant message\") }}\n {%- endif -%}\n {%- set ns.prev_message_type = 'content' -%}\n {%- endif -%}\n {%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls'] is iterable -%}\n {#- Tool Calls -#}\n {%- for tool_call in message['tool_calls'] -%}\n {% set function = tool_call['function'] %}\n {{- '<start_function_call>call:' + function['name'] + '{' -}}\n {%- if 'arguments' in function -%}\n {%- if function['arguments'] is mapping -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is string -%}\n {# This handles string-JSON, just in case #}\n {{ function['arguments'] }}\n {%- endif %}\n {%- endif -%}\n {{- '}<end_function_call>' -}}\n {%- endfor -%}\n {%- if loop.last -%}\n {{ '<start_function_response>' }}\n {%- endif -%}\n {%- set ns.prev_message_type = 'tool_call' -%}\n {%- endif -%}\n {%- else -%}\n {#- Tool Responses -#}\n {%- if 'content' in message and message['content'] -%}\n {%- if message['content'] is mapping -%}\n {%- if 'name' in message['content'] and 'response' in message['content'] -%}\n {{ '<start_function_response>response:' + message['content']['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in message['content']['response'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- elif 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in message['content'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.\") }}\n {%- endif -%}\n {%- elif message['content'] is string -%}\n {%- if 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{value:' + format_argument(message['content'], escape_keys=False) + '}<end_function_response>' }}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response: 'name' must be provided.\") }}\n {%- endif -%}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item is mapping -%}\n {%- if 'name' in item and 'response' in item -%}\n {{ '<start_function_response>response:' + item['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in item['response'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- elif 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in item | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.\") }}\n {%- endif -%}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response message: multiple responses must all be mappings\") }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type in tool message: must be mapping, sequence of mappings, or string.\") }}\n {%- endif -%}\n {%- endif -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endif -%}\n {%- if ns.prev_message_type not in ['tool_call', 'tool_response'] -%}\n {{ '<end_of_turn>\\n' }}\n {%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {%- if ns.prev_message_type != 'tool_response' -%}\n {{- '<start_of_turn>model\\n' -}}\n {%- endif -%}\n{%- endif -%}\n"
28
+ }