DavidAU commited on
Commit
2efe237
·
verified ·
1 Parent(s): ab5fb8a

Upload folder using huggingface_hub

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
chat_template-instruct.jinja ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {%- set add_comma = false -%}
6
+ {%- if key not in standard_keys -%}
7
+ {%- if ns.found_first %},{% endif -%}
8
+ {%- set ns.found_first = true -%}
9
+ {{ key }}:{
10
+ {%- if value['description'] -%}
11
+ description:<|"|>{{ value['description'] }}<|"|>
12
+ {%- set add_comma = true -%}
13
+ {%- endif -%}
14
+ {%- if value['nullable'] %}
15
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
16
+ nullable:true
17
+ {%- endif -%}
18
+ {%- if value['type'] | upper == 'STRING' -%}
19
+ {%- if value['enum'] -%}
20
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
21
+ enum:{{ format_argument(value['enum']) }}
22
+ {%- endif -%}
23
+ {%- elif value['type'] | upper == 'OBJECT' -%}
24
+ ,properties:{
25
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
26
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
27
+ {%- elif value is mapping -%}
28
+ {{- format_parameters(value, value['required'] | default([])) -}}
29
+ {%- endif -%}
30
+ }
31
+ {%- if value['required'] -%}
32
+ ,required:[
33
+ {%- for item in value['required'] | default([]) -%}
34
+ <|"|>{{- item -}}<|"|>
35
+ {%- if not loop.last %},{% endif -%}
36
+ {%- endfor -%}
37
+ ]
38
+ {%- endif -%}
39
+ {%- elif value['type'] | upper == 'ARRAY' -%}
40
+ {%- if value['items'] is mapping and value['items'] -%}
41
+ ,items:{
42
+ {%- set ns_items = namespace(found_first=false) -%}
43
+ {%- for item_key, item_value in value['items'] | dictsort -%}
44
+ {%- if item_value is not none -%}
45
+ {%- if ns_items.found_first %},{% endif -%}
46
+ {%- set ns_items.found_first = true -%}
47
+ {%- if item_key == 'properties' -%}
48
+ properties:{
49
+ {%- if item_value is mapping -%}
50
+ {{- format_parameters(item_value, value['items']['required'] | default([])) -}}
51
+ {%- endif -%}
52
+ }
53
+ {%- elif item_key == 'required' -%}
54
+ required:[
55
+ {%- for req_item in item_value -%}
56
+ <|"|>{{- req_item -}}<|"|>
57
+ {%- if not loop.last %},{% endif -%}
58
+ {%- endfor -%}
59
+ ]
60
+ {%- elif item_key == 'type' -%}
61
+ {%- if item_value is string -%}
62
+ type:{{ format_argument(item_value | upper) }}
63
+ {%- else -%}
64
+ type:{{ format_argument(item_value | map('upper') | list) }}
65
+ {%- endif -%}
66
+ {%- else -%}
67
+ {{ item_key }}:{{ format_argument(item_value) }}
68
+ {%- endif -%}
69
+ {%- endif -%}
70
+ {%- endfor -%}
71
+ }
72
+ {%- endif -%}
73
+ {%- endif -%}
74
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
75
+ type:<|"|>{{ value['type'] | upper }}<|"|>}
76
+ {%- endif -%}
77
+ {%- endfor -%}
78
+ {%- endmacro -%}
79
+ {%- macro format_function_declaration(tool_data) -%}
80
+ declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|>
81
+ {%- set params = tool_data['function']['parameters'] -%}
82
+ {%- if params -%}
83
+ ,parameters:{
84
+ {%- if params['properties'] -%}
85
+ properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
86
+ {%- endif -%}
87
+ {%- if params['required'] -%}
88
+ required:[
89
+ {%- for item in params['required'] -%}
90
+ <|"|>{{- item -}}<|"|>
91
+ {{- ',' if not loop.last -}}
92
+ {%- endfor -%}
93
+ ],
94
+ {%- endif -%}
95
+ {%- if params['type'] -%}
96
+ type:<|"|>{{- params['type'] | upper -}}<|"|>}
97
+ {%- endif -%}
98
+ {%- endif -%}
99
+ {%- if 'response' in tool_data['function'] -%}
100
+ {%- set response_declaration = tool_data['function']['response'] -%}
101
+ ,response:{
102
+ {%- if response_declaration['description'] -%}
103
+ description:<|"|>{{- response_declaration['description'] -}}<|"|>,
104
+ {%- endif -%}
105
+ {%- if response_declaration['type'] | upper == 'OBJECT' -%}
106
+ type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>}
107
+ {%- endif -%}
108
+ {%- endif -%}
109
+ }
110
+ {%- endmacro -%}
111
+ {%- macro format_argument(argument, escape_keys=True) -%}
112
+ {%- if argument is string -%}
113
+ {{- '<|"|>' + argument + '<|"|>' -}}
114
+ {%- elif argument is boolean -%}
115
+ {{- 'true' if argument else 'false' -}}
116
+ {%- elif argument is mapping -%}
117
+ {{- '{' -}}
118
+ {%- set ns = namespace(found_first=false) -%}
119
+ {%- for key, value in argument | dictsort -%}
120
+ {%- if ns.found_first %},{% endif -%}
121
+ {%- set ns.found_first = true -%}
122
+ {%- if escape_keys -%}
123
+ {{- '<|"|>' + key + '<|"|>' -}}
124
+ {%- else -%}
125
+ {{- key -}}
126
+ {%- endif -%}
127
+ :{{- format_argument(value, escape_keys=escape_keys) -}}
128
+ {%- endfor -%}
129
+ {{- '}' -}}
130
+ {%- elif argument is sequence -%}
131
+ {{- '[' -}}
132
+ {%- for item in argument -%}
133
+ {{- format_argument(item, escape_keys=escape_keys) -}}
134
+ {%- if not loop.last %},{% endif -%}
135
+ {%- endfor -%}
136
+ {{- ']' -}}
137
+ {%- else -%}
138
+ {{- argument -}}
139
+ {%- endif -%}
140
+ {%- endmacro -%}
141
+ {%- macro strip_thinking(text) -%}
142
+ {%- set ns = namespace(result='') -%}
143
+ {%- for part in text.split('<channel|>') -%}
144
+ {%- if '<|channel>' in part -%}
145
+ {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}
146
+ {%- else -%}
147
+ {%- set ns.result = ns.result + part -%}
148
+ {%- endif -%}
149
+ {%- endfor -%}
150
+ {{- ns.result | trim -}}
151
+ {%- endmacro -%}
152
+
153
+ {%- set ns = namespace(prev_message_type=None) -%}
154
+ {%- set loop_messages = messages -%}
155
+ {{ bos_token }}
156
+ {#- Handle System/Tool Definitions Block -#}
157
+ {%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
158
+ {{- '<|turn>system\n' -}}
159
+
160
+ {#- Inject Thinking token at the very top of the FIRST system turn -#}
161
+ {%- if enable_thinking is defined and enable_thinking -%}
162
+ {{- '<|think|>' -}}
163
+ {%- set ns.prev_message_type = 'think' -%}
164
+ {%- endif -%}
165
+
166
+ {%- if messages[0]['role'] in ['system', 'developer'] -%}
167
+ {{- messages[0]['content'] | trim -}}
168
+ {%- set loop_messages = messages[1:] -%}
169
+ {%- endif -%}
170
+
171
+ {%- if tools -%}
172
+ {%- for tool in tools %}
173
+ {{- '<|tool>' -}}
174
+ {{- format_function_declaration(tool) | trim -}}
175
+ {{- '<tool|>' -}}
176
+ {%- endfor %}
177
+ {%- set ns.prev_message_type = 'tool' -%}
178
+ {%- endif -%}
179
+
180
+ {{- '<turn|>\n' -}}
181
+ {%- endif %}
182
+
183
+ {#- Loop through messages -#}
184
+ {%- for message in loop_messages -%}
185
+ {%- set ns.prev_message_type = None -%}
186
+ {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
187
+ {{- '<|turn>' + role + '\n' }}
188
+
189
+ {%- if message['tool_calls'] -%}
190
+ {%- for tool_call in message['tool_calls'] -%}
191
+ {%- set function = tool_call['function'] -%}
192
+ {{- '<|tool_call>call:' + function['name'] + '{' -}}
193
+ {%- if function['arguments'] is mapping -%}
194
+ {%- set ns_args = namespace(found_first=false) -%}
195
+ {%- for key, value in function['arguments'] | dictsort -%}
196
+ {%- if ns_args.found_first %},{% endif -%}
197
+ {%- set ns_args.found_first = true -%}
198
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
199
+ {%- endfor -%}
200
+ {%- elif function['arguments'] is string -%}
201
+ {{- function['arguments'] -}}
202
+ {%- endif -%}
203
+ {{- '}<tool_call|>' -}}
204
+ {%- endfor -%}
205
+ {%- set ns.prev_message_type = 'tool_call' -%}
206
+ {%- endif -%}
207
+
208
+ {%- if message['tool_responses'] -%}
209
+ {#- Tool Response handling -#}
210
+ {%- for tool_response in message['tool_responses'] -%}
211
+ {{- '<|tool_response>' -}}
212
+ {%- if tool_response['response'] is mapping -%}
213
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{' -}}
214
+ {%- for key, value in tool_response['response'] | dictsort -%}
215
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
216
+ {%- if not loop.last %},{% endif -%}
217
+ {%- endfor -%}
218
+ {{- '}' -}}
219
+ {%- else -%}
220
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}}
221
+ {%- endif -%}
222
+ {{- '<tool_response|>' -}}
223
+ {%- endfor -%}
224
+ {%- set ns.prev_message_type = 'tool_response' -%}
225
+ {%- endif -%}
226
+
227
+ {%- if message['content'] is string -%}
228
+ {%- if role == 'model' -%}
229
+ {{- strip_thinking(message['content']) -}}
230
+ {%- else -%}
231
+ {{- message['content'] | trim -}}
232
+ {%- endif -%}
233
+ {%- elif message['content'] is sequence -%}
234
+ {%- for item in message['content'] -%}
235
+ {%- if item['type'] == 'text' -%}
236
+ {%- if role == 'model' -%}
237
+ {{- strip_thinking(item['text']) -}}
238
+ {%- else -%}
239
+ {{- item['text'] | trim -}}
240
+ {%- endif -%}
241
+ {%- elif item['type'] == 'image' -%}
242
+ {{- '\n\n<|image|>\n\n' -}}
243
+ {%- set ns.prev_message_type = 'image' -%}
244
+ {%- elif item['type'] == 'audio' -%}
245
+ {{- '<|audio|>' -}}
246
+ {%- set ns.prev_message_type = 'audio' -%}
247
+ {%- elif item['type'] == 'video' -%}
248
+ {{- '\n\n<|video|>\n\n' -}}
249
+ {%- set ns.prev_message_type = 'video' -%}
250
+ {%- endif -%}
251
+ {%- endfor -%}
252
+ {%- endif -%}
253
+
254
+ {%- if not (message['tool_responses'] and not message['content']) -%}
255
+ {{- '<turn|>\n' -}}
256
+ {%- endif -%}
257
+ {%- endfor -%}
258
+
259
+ {%- if add_generation_prompt -%}
260
+ {%- if ns.prev_message_type != 'tool_response' -%}
261
+ {{- '<|turn>model\n' -}}
262
+ {%- endif -%}
263
+ {%- endif -%}
chat_template.jinja ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set enable_thinking = true -%}
2
+ {%- macro format_parameters(properties, required) -%}
3
+ {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
4
+ {%- set ns = namespace(found_first=false) -%}
5
+ {%- for key, value in properties | dictsort -%}
6
+ {%- set add_comma = false -%}
7
+ {%- if key not in standard_keys -%}
8
+ {%- if ns.found_first %},{% endif -%}
9
+ {%- set ns.found_first = true -%}
10
+ {{ key }}:{
11
+ {%- if value['description'] -%}
12
+ description:<|"|>{{ value['description'] }}<|"|>
13
+ {%- set add_comma = true -%}
14
+ {%- endif -%}
15
+ {%- if value['nullable'] %}
16
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
17
+ nullable:true
18
+ {%- endif -%}
19
+ {%- if value['type'] | upper == 'STRING' -%}
20
+ {%- if value['enum'] -%}
21
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
22
+ enum:{{ format_argument(value['enum']) }}
23
+ {%- endif -%}
24
+ {%- elif value['type'] | upper == 'OBJECT' -%}
25
+ ,properties:{
26
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
27
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
28
+ {%- elif value is mapping -%}
29
+ {{- format_parameters(value, value['required'] | default([])) -}}
30
+ {%- endif -%}
31
+ }
32
+ {%- if value['required'] -%}
33
+ ,required:[
34
+ {%- for item in value['required'] | default([]) -%}
35
+ <|"|>{{- item -}}<|"|>
36
+ {%- if not loop.last %},{% endif -%}
37
+ {%- endfor -%}
38
+ ]
39
+ {%- endif -%}
40
+ {%- elif value['type'] | upper == 'ARRAY' -%}
41
+ {%- if value['items'] is mapping and value['items'] -%}
42
+ ,items:{
43
+ {%- set ns_items = namespace(found_first=false) -%}
44
+ {%- for item_key, item_value in value['items'] | dictsort -%}
45
+ {%- if item_value is not none -%}
46
+ {%- if ns_items.found_first %},{% endif -%}
47
+ {%- set ns_items.found_first = true -%}
48
+ {%- if item_key == 'properties' -%}
49
+ properties:{
50
+ {%- if item_value is mapping -%}
51
+ {{- format_parameters(item_value, value['items']['required'] | default([])) -}}
52
+ {%- endif -%}
53
+ }
54
+ {%- elif item_key == 'required' -%}
55
+ required:[
56
+ {%- for req_item in item_value -%}
57
+ <|"|>{{- req_item -}}<|"|>
58
+ {%- if not loop.last %},{% endif -%}
59
+ {%- endfor -%}
60
+ ]
61
+ {%- elif item_key == 'type' -%}
62
+ {%- if item_value is string -%}
63
+ type:{{ format_argument(item_value | upper) }}
64
+ {%- else -%}
65
+ type:{{ format_argument(item_value | map('upper') | list) }}
66
+ {%- endif -%}
67
+ {%- else -%}
68
+ {{ item_key }}:{{ format_argument(item_value) }}
69
+ {%- endif -%}
70
+ {%- endif -%}
71
+ {%- endfor -%}
72
+ }
73
+ {%- endif -%}
74
+ {%- endif -%}
75
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
76
+ type:<|"|>{{ value['type'] | upper }}<|"|>}
77
+ {%- endif -%}
78
+ {%- endfor -%}
79
+ {%- endmacro -%}
80
+ {%- macro format_function_declaration(tool_data) -%}
81
+ declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|>
82
+ {%- set params = tool_data['function']['parameters'] -%}
83
+ {%- if params -%}
84
+ ,parameters:{
85
+ {%- if params['properties'] -%}
86
+ properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
87
+ {%- endif -%}
88
+ {%- if params['required'] -%}
89
+ required:[
90
+ {%- for item in params['required'] -%}
91
+ <|"|>{{- item -}}<|"|>
92
+ {{- ',' if not loop.last -}}
93
+ {%- endfor -%}
94
+ ],
95
+ {%- endif -%}
96
+ {%- if params['type'] -%}
97
+ type:<|"|>{{- params['type'] | upper -}}<|"|>}
98
+ {%- endif -%}
99
+ {%- endif -%}
100
+ {%- if 'response' in tool_data['function'] -%}
101
+ {%- set response_declaration = tool_data['function']['response'] -%}
102
+ ,response:{
103
+ {%- if response_declaration['description'] -%}
104
+ description:<|"|>{{- response_declaration['description'] -}}<|"|>,
105
+ {%- endif -%}
106
+ {%- if response_declaration['type'] | upper == 'OBJECT' -%}
107
+ type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>}
108
+ {%- endif -%}
109
+ {%- endif -%}
110
+ }
111
+ {%- endmacro -%}
112
+ {%- macro format_argument(argument, escape_keys=True) -%}
113
+ {%- if argument is string -%}
114
+ {{- '<|"|>' + argument + '<|"|>' -}}
115
+ {%- elif argument is boolean -%}
116
+ {{- 'true' if argument else 'false' -}}
117
+ {%- elif argument is mapping -%}
118
+ {{- '{' -}}
119
+ {%- set ns = namespace(found_first=false) -%}
120
+ {%- for key, value in argument | dictsort -%}
121
+ {%- if ns.found_first %},{% endif -%}
122
+ {%- set ns.found_first = true -%}
123
+ {%- if escape_keys -%}
124
+ {{- '<|"|>' + key + '<|"|>' -}}
125
+ {%- else -%}
126
+ {{- key -}}
127
+ {%- endif -%}
128
+ :{{- format_argument(value, escape_keys=escape_keys) -}}
129
+ {%- endfor -%}
130
+ {{- '}' -}}
131
+ {%- elif argument is sequence -%}
132
+ {{- '[' -}}
133
+ {%- for item in argument -%}
134
+ {{- format_argument(item, escape_keys=escape_keys) -}}
135
+ {%- if not loop.last %},{% endif -%}
136
+ {%- endfor -%}
137
+ {{- ']' -}}
138
+ {%- else -%}
139
+ {{- argument -}}
140
+ {%- endif -%}
141
+ {%- endmacro -%}
142
+ {%- macro strip_thinking(text) -%}
143
+ {%- set ns = namespace(result='') -%}
144
+ {%- for part in text.split('<channel|>') -%}
145
+ {%- if '<|channel>' in part -%}
146
+ {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}
147
+ {%- else -%}
148
+ {%- set ns.result = ns.result + part -%}
149
+ {%- endif -%}
150
+ {%- endfor -%}
151
+ {{- ns.result | trim -}}
152
+ {%- endmacro -%}
153
+
154
+ {%- set ns = namespace(prev_message_type=None) -%}
155
+ {%- set loop_messages = messages -%}
156
+ {{ bos_token }}
157
+ {#- Handle System/Tool Definitions Block -#}
158
+ {%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
159
+ {{- '<|turn>system\n' -}}
160
+
161
+ {#- Inject Thinking token at the very top of the FIRST system turn -#}
162
+ {%- if enable_thinking is defined and enable_thinking -%}
163
+ {{- '<|think|>' -}}
164
+ {%- set ns.prev_message_type = 'think' -%}
165
+ {%- endif -%}
166
+
167
+ {%- if messages[0]['role'] in ['system', 'developer'] -%}
168
+ {{- messages[0]['content'] | trim -}}
169
+ {%- set loop_messages = messages[1:] -%}
170
+ {%- endif -%}
171
+
172
+ {%- if tools -%}
173
+ {%- for tool in tools %}
174
+ {{- '<|tool>' -}}
175
+ {{- format_function_declaration(tool) | trim -}}
176
+ {{- '<tool|>' -}}
177
+ {%- endfor %}
178
+ {%- set ns.prev_message_type = 'tool' -%}
179
+ {%- endif -%}
180
+
181
+ {{- '<turn|>\n' -}}
182
+ {%- endif %}
183
+
184
+ {#- Loop through messages -#}
185
+ {%- for message in loop_messages -%}
186
+ {%- set ns.prev_message_type = None -%}
187
+ {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
188
+ {{- '<|turn>' + role + '\n' }}
189
+
190
+ {%- if message['tool_calls'] -%}
191
+ {%- for tool_call in message['tool_calls'] -%}
192
+ {%- set function = tool_call['function'] -%}
193
+ {{- '<|tool_call>call:' + function['name'] + '{' -}}
194
+ {%- if function['arguments'] is mapping -%}
195
+ {%- set ns_args = namespace(found_first=false) -%}
196
+ {%- for key, value in function['arguments'] | dictsort -%}
197
+ {%- if ns_args.found_first %},{% endif -%}
198
+ {%- set ns_args.found_first = true -%}
199
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
200
+ {%- endfor -%}
201
+ {%- elif function['arguments'] is string -%}
202
+ {{- function['arguments'] -}}
203
+ {%- endif -%}
204
+ {{- '}<tool_call|>' -}}
205
+ {%- endfor -%}
206
+ {%- set ns.prev_message_type = 'tool_call' -%}
207
+ {%- endif -%}
208
+
209
+ {%- if message['tool_responses'] -%}
210
+ {#- Tool Response handling -#}
211
+ {%- for tool_response in message['tool_responses'] -%}
212
+ {{- '<|tool_response>' -}}
213
+ {%- if tool_response['response'] is mapping -%}
214
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{' -}}
215
+ {%- for key, value in tool_response['response'] | dictsort -%}
216
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
217
+ {%- if not loop.last %},{% endif -%}
218
+ {%- endfor -%}
219
+ {{- '}' -}}
220
+ {%- else -%}
221
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}}
222
+ {%- endif -%}
223
+ {{- '<tool_response|>' -}}
224
+ {%- endfor -%}
225
+ {%- set ns.prev_message_type = 'tool_response' -%}
226
+ {%- endif -%}
227
+
228
+ {%- if message['content'] is string -%}
229
+ {%- if role == 'model' -%}
230
+ {{- strip_thinking(message['content']) -}}
231
+ {%- else -%}
232
+ {{- message['content'] | trim -}}
233
+ {%- endif -%}
234
+ {%- elif message['content'] is sequence -%}
235
+ {%- for item in message['content'] -%}
236
+ {%- if item['type'] == 'text' -%}
237
+ {%- if role == 'model' -%}
238
+ {{- strip_thinking(item['text']) -}}
239
+ {%- else -%}
240
+ {{- item['text'] | trim -}}
241
+ {%- endif -%}
242
+ {%- elif item['type'] == 'image' -%}
243
+ {{- '\n\n<|image|>\n\n' -}}
244
+ {%- set ns.prev_message_type = 'image' -%}
245
+ {%- elif item['type'] == 'audio' -%}
246
+ {{- '<|audio|>' -}}
247
+ {%- set ns.prev_message_type = 'audio' -%}
248
+ {%- elif item['type'] == 'video' -%}
249
+ {{- '\n\n<|video|>\n\n' -}}
250
+ {%- set ns.prev_message_type = 'video' -%}
251
+ {%- endif -%}
252
+ {%- endfor -%}
253
+ {%- endif -%}
254
+
255
+ {%- if not (message['tool_responses'] and not message['content']) -%}
256
+ {{- '<turn|>\n' -}}
257
+ {%- endif -%}
258
+ {%- endfor -%}
259
+
260
+ {%- if add_generation_prompt -%}
261
+ {%- if ns.prev_message_type != 'tool_response' -%}
262
+ {{- '<|turn>model\n' -}}
263
+ {%- endif -%}
264
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma4ForConditionalGeneration"
4
+ ],
5
+ "audio_config": {
6
+ "_name_or_path": "",
7
+ "architectures": null,
8
+ "attention_chunk_size": 12,
9
+ "attention_context_left": 13,
10
+ "attention_context_right": 0,
11
+ "attention_invalid_logits_value": -1000000000.0,
12
+ "attention_logit_cap": 50.0,
13
+ "chunk_size_feed_forward": 0,
14
+ "conv_kernel_size": 5,
15
+ "torch_dtype": "bfloat16",
16
+ "gradient_clipping": 10000000000.0,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 1024,
19
+ "id2label": {
20
+ "0": "LABEL_0",
21
+ "1": "LABEL_1"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "is_encoder_decoder": false,
25
+ "label2id": {
26
+ "LABEL_0": 0,
27
+ "LABEL_1": 1
28
+ },
29
+ "model_type": "gemma4_audio",
30
+ "num_attention_heads": 8,
31
+ "num_hidden_layers": 12,
32
+ "output_attentions": false,
33
+ "output_hidden_states": false,
34
+ "output_proj_dims": 1536,
35
+ "problem_type": null,
36
+ "residual_weight": 0.5,
37
+ "return_dict": true,
38
+ "rms_norm_eps": 1e-06,
39
+ "subsampling_conv_channels": [
40
+ 128,
41
+ 32
42
+ ],
43
+ "use_clipped_linears": true
44
+ },
45
+ "audio_token_id": 258881,
46
+ "boa_token_id": 256000,
47
+ "boi_token_id": 255999,
48
+ "torch_dtype": "bfloat16",
49
+ "eoa_token_id": 258883,
50
+ "eoa_token_index": 258883,
51
+ "eoi_token_id": 258882,
52
+ "eos_token_id": [
53
+ 1,
54
+ 106
55
+ ],
56
+ "image_token_id": 258880,
57
+ "initializer_range": 0.02,
58
+ "model_name": "/mnt/w/E4B-Gemma4-it-vl-HERE-DECKARD4",
59
+ "model_type": "gemma4",
60
+ "pad_token_id": 0,
61
+ "text_config": {
62
+ "attention_bias": false,
63
+ "attention_dropout": 0.0,
64
+ "attention_k_eq_v": false,
65
+ "bos_token_id": 2,
66
+ "torch_dtype": "bfloat16",
67
+ "enable_moe_block": false,
68
+ "eos_token_id": 1,
69
+ "expert_intermediate_size": null,
70
+ "final_logit_softcapping": 30.0,
71
+ "global_head_dim": 512,
72
+ "head_dim": 256,
73
+ "hidden_activation": "gelu_pytorch_tanh",
74
+ "hidden_size": 2560,
75
+ "hidden_size_per_layer_input": 256,
76
+ "initializer_range": 0.02,
77
+ "intermediate_size": 10240,
78
+ "layer_types": [
79
+ "sliding_attention",
80
+ "sliding_attention",
81
+ "sliding_attention",
82
+ "sliding_attention",
83
+ "sliding_attention",
84
+ "full_attention",
85
+ "sliding_attention",
86
+ "sliding_attention",
87
+ "sliding_attention",
88
+ "sliding_attention",
89
+ "sliding_attention",
90
+ "full_attention",
91
+ "sliding_attention",
92
+ "sliding_attention",
93
+ "sliding_attention",
94
+ "sliding_attention",
95
+ "sliding_attention",
96
+ "full_attention",
97
+ "sliding_attention",
98
+ "sliding_attention",
99
+ "sliding_attention",
100
+ "sliding_attention",
101
+ "sliding_attention",
102
+ "full_attention",
103
+ "sliding_attention",
104
+ "sliding_attention",
105
+ "sliding_attention",
106
+ "sliding_attention",
107
+ "sliding_attention",
108
+ "full_attention",
109
+ "sliding_attention",
110
+ "sliding_attention",
111
+ "sliding_attention",
112
+ "sliding_attention",
113
+ "sliding_attention",
114
+ "full_attention",
115
+ "sliding_attention",
116
+ "sliding_attention",
117
+ "sliding_attention",
118
+ "sliding_attention",
119
+ "sliding_attention",
120
+ "full_attention"
121
+ ],
122
+ "max_position_embeddings": 131072,
123
+ "model_type": "gemma4_text",
124
+ "moe_intermediate_size": null,
125
+ "num_attention_heads": 8,
126
+ "num_experts": null,
127
+ "num_global_key_value_heads": null,
128
+ "num_hidden_layers": 42,
129
+ "num_key_value_heads": 2,
130
+ "num_kv_shared_layers": 18,
131
+ "pad_token_id": 0,
132
+ "rms_norm_eps": 1e-06,
133
+ "rope_parameters": {
134
+ "full_attention": {
135
+ "partial_rotary_factor": 0.25,
136
+ "rope_theta": 1000000.0,
137
+ "rope_type": "proportional"
138
+ },
139
+ "sliding_attention": {
140
+ "rope_theta": 10000.0,
141
+ "rope_type": "default"
142
+ }
143
+ },
144
+ "sliding_window": 512,
145
+ "tie_word_embeddings": true,
146
+ "top_k_experts": null,
147
+ "use_bidirectional_attention": null,
148
+ "use_cache": true,
149
+ "use_double_wide_mlp": false,
150
+ "vocab_size": 262144,
151
+ "vocab_size_per_layer_input": 262144
152
+ },
153
+ "tie_word_embeddings": true,
154
+ "unsloth_version": "2026.4.4",
155
+ "video_token_id": 258884,
156
+ "vision_config": {
157
+ "_name_or_path": "",
158
+ "architectures": null,
159
+ "attention_bias": false,
160
+ "attention_dropout": 0.0,
161
+ "chunk_size_feed_forward": 0,
162
+ "default_output_length": 280,
163
+ "torch_dtype": "bfloat16",
164
+ "global_head_dim": 64,
165
+ "head_dim": 64,
166
+ "hidden_activation": "gelu_pytorch_tanh",
167
+ "hidden_size": 768,
168
+ "id2label": {
169
+ "0": "LABEL_0",
170
+ "1": "LABEL_1"
171
+ },
172
+ "initializer_range": 0.02,
173
+ "intermediate_size": 3072,
174
+ "is_encoder_decoder": false,
175
+ "label2id": {
176
+ "LABEL_0": 0,
177
+ "LABEL_1": 1
178
+ },
179
+ "max_position_embeddings": 131072,
180
+ "model_type": "gemma4_vision",
181
+ "num_attention_heads": 12,
182
+ "num_hidden_layers": 16,
183
+ "num_key_value_heads": 12,
184
+ "output_attentions": false,
185
+ "output_hidden_states": false,
186
+ "patch_size": 16,
187
+ "pooling_kernel_size": 3,
188
+ "position_embedding_size": 10240,
189
+ "problem_type": null,
190
+ "return_dict": true,
191
+ "rms_norm_eps": 1e-06,
192
+ "rope_parameters": {
193
+ "rope_theta": 100.0,
194
+ "rope_type": "default"
195
+ },
196
+ "standardize": false,
197
+ "use_clipped_linears": true
198
+ },
199
+ "vision_soft_tokens_per_image": 280
200
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce52673317d17796487f8b5e52b0d28178fd1a82beb00bf6365d16d061e0d6c4
3
+ size 15992595852
processor_config.json ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_ms_per_token": 40,
3
+ "audio_seq_length": 750,
4
+ "feature_extractor": {
5
+ "audio_ms_per_token": 40,
6
+ "audio_seq_length": 750,
7
+ "dither": 0.0,
8
+ "feature_extractor": {
9
+ "dither": 0.0,
10
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
11
+ "feature_size": 128,
12
+ "fft_length": 512,
13
+ "fft_overdrive": false,
14
+ "frame_length": 320,
15
+ "hop_length": 160,
16
+ "input_scale_factor": 1.0,
17
+ "max_frequency": 8000.0,
18
+ "mel_floor": 0.001,
19
+ "min_frequency": 0.0,
20
+ "padding_side": "right",
21
+ "padding_value": 0.0,
22
+ "per_bin_mean": null,
23
+ "per_bin_stddev": null,
24
+ "preemphasis": 0.0,
25
+ "preemphasis_htk_flavor": true,
26
+ "return_attention_mask": true,
27
+ "sampling_rate": 16000
28
+ },
29
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
30
+ "feature_size": 128,
31
+ "fft_length": 512,
32
+ "fft_overdrive": false,
33
+ "frame_length": 320,
34
+ "hop_length": 160,
35
+ "image_processor": {
36
+ "do_convert_rgb": true,
37
+ "do_normalize": false,
38
+ "do_rescale": true,
39
+ "do_resize": true,
40
+ "image_mean": [
41
+ 0.0,
42
+ 0.0,
43
+ 0.0
44
+ ],
45
+ "image_processor_type": "Gemma4ImageProcessor",
46
+ "image_seq_length": 280,
47
+ "image_std": [
48
+ 1.0,
49
+ 1.0,
50
+ 1.0
51
+ ],
52
+ "max_soft_tokens": 280,
53
+ "patch_size": 16,
54
+ "pooling_kernel_size": 3,
55
+ "resample": 3,
56
+ "rescale_factor": 0.00392156862745098
57
+ },
58
+ "image_seq_length": 280,
59
+ "input_scale_factor": 1.0,
60
+ "max_frequency": 8000.0,
61
+ "mel_floor": 0.001,
62
+ "min_frequency": 0.0,
63
+ "padding_side": "left",
64
+ "padding_value": 0.0,
65
+ "per_bin_mean": null,
66
+ "per_bin_stddev": null,
67
+ "preemphasis": 0.0,
68
+ "preemphasis_htk_flavor": true,
69
+ "return_attention_mask": true,
70
+ "sampling_rate": 16000,
71
+ "video_processor": {
72
+ "do_convert_rgb": true,
73
+ "do_normalize": true,
74
+ "do_rescale": true,
75
+ "do_resize": true,
76
+ "do_sample_frames": true,
77
+ "image_mean": [
78
+ 0.0,
79
+ 0.0,
80
+ 0.0
81
+ ],
82
+ "image_std": [
83
+ 1.0,
84
+ 1.0,
85
+ 1.0
86
+ ],
87
+ "max_soft_tokens": 70,
88
+ "num_frames": 32,
89
+ "patch_size": 16,
90
+ "pooling_kernel_size": 3,
91
+ "resample": 3,
92
+ "rescale_factor": 0.00392156862745098,
93
+ "return_metadata": false,
94
+ "video_processor_type": "Gemma4VideoProcessor"
95
+ }
96
+ },
97
+ "image_processor": {
98
+ "audio_ms_per_token": 40,
99
+ "audio_seq_length": 750,
100
+ "do_convert_rgb": true,
101
+ "do_normalize": false,
102
+ "do_rescale": true,
103
+ "do_resize": true,
104
+ "feature_extractor": {
105
+ "dither": 0.0,
106
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
107
+ "feature_size": 128,
108
+ "fft_length": 512,
109
+ "fft_overdrive": false,
110
+ "frame_length": 320,
111
+ "hop_length": 160,
112
+ "input_scale_factor": 1.0,
113
+ "max_frequency": 8000.0,
114
+ "mel_floor": 0.001,
115
+ "min_frequency": 0.0,
116
+ "padding_side": "right",
117
+ "padding_value": 0.0,
118
+ "per_bin_mean": null,
119
+ "per_bin_stddev": null,
120
+ "preemphasis": 0.0,
121
+ "preemphasis_htk_flavor": true,
122
+ "return_attention_mask": true,
123
+ "sampling_rate": 16000
124
+ },
125
+ "image_mean": [
126
+ 0.0,
127
+ 0.0,
128
+ 0.0
129
+ ],
130
+ "image_processor": {
131
+ "do_convert_rgb": true,
132
+ "do_normalize": false,
133
+ "do_rescale": true,
134
+ "do_resize": true,
135
+ "image_mean": [
136
+ 0.0,
137
+ 0.0,
138
+ 0.0
139
+ ],
140
+ "image_processor_type": "Gemma4ImageProcessor",
141
+ "image_seq_length": 280,
142
+ "image_std": [
143
+ 1.0,
144
+ 1.0,
145
+ 1.0
146
+ ],
147
+ "max_soft_tokens": 280,
148
+ "patch_size": 16,
149
+ "pooling_kernel_size": 3,
150
+ "resample": 3,
151
+ "rescale_factor": 0.00392156862745098
152
+ },
153
+ "image_processor_type": "Gemma4ImageProcessor",
154
+ "image_seq_length": 280,
155
+ "image_std": [
156
+ 1.0,
157
+ 1.0,
158
+ 1.0
159
+ ],
160
+ "max_soft_tokens": 280,
161
+ "patch_size": 16,
162
+ "pooling_kernel_size": 3,
163
+ "resample": 3,
164
+ "rescale_factor": 0.00392156862745098,
165
+ "video_processor": {
166
+ "do_convert_rgb": true,
167
+ "do_normalize": true,
168
+ "do_rescale": true,
169
+ "do_resize": true,
170
+ "do_sample_frames": true,
171
+ "image_mean": [
172
+ 0.0,
173
+ 0.0,
174
+ 0.0
175
+ ],
176
+ "image_std": [
177
+ 1.0,
178
+ 1.0,
179
+ 1.0
180
+ ],
181
+ "max_soft_tokens": 70,
182
+ "num_frames": 32,
183
+ "patch_size": 16,
184
+ "pooling_kernel_size": 3,
185
+ "resample": 3,
186
+ "rescale_factor": 0.00392156862745098,
187
+ "return_metadata": false,
188
+ "video_processor_type": "Gemma4VideoProcessor"
189
+ }
190
+ },
191
+ "image_seq_length": 280,
192
+ "processor_class": "Gemma4Processor",
193
+ "video_processor": {
194
+ "audio_ms_per_token": 40,
195
+ "audio_seq_length": 750,
196
+ "do_convert_rgb": true,
197
+ "do_normalize": true,
198
+ "do_rescale": true,
199
+ "do_resize": true,
200
+ "do_sample_frames": true,
201
+ "feature_extractor": {
202
+ "dither": 0.0,
203
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
204
+ "feature_size": 128,
205
+ "fft_length": 512,
206
+ "fft_overdrive": false,
207
+ "frame_length": 320,
208
+ "hop_length": 160,
209
+ "input_scale_factor": 1.0,
210
+ "max_frequency": 8000.0,
211
+ "mel_floor": 0.001,
212
+ "min_frequency": 0.0,
213
+ "padding_side": "right",
214
+ "padding_value": 0.0,
215
+ "per_bin_mean": null,
216
+ "per_bin_stddev": null,
217
+ "preemphasis": 0.0,
218
+ "preemphasis_htk_flavor": true,
219
+ "return_attention_mask": true,
220
+ "sampling_rate": 16000
221
+ },
222
+ "image_mean": [
223
+ 0.0,
224
+ 0.0,
225
+ 0.0
226
+ ],
227
+ "image_processor": {
228
+ "do_convert_rgb": true,
229
+ "do_normalize": false,
230
+ "do_rescale": true,
231
+ "do_resize": true,
232
+ "image_mean": [
233
+ 0.0,
234
+ 0.0,
235
+ 0.0
236
+ ],
237
+ "image_processor_type": "Gemma4ImageProcessor",
238
+ "image_seq_length": 280,
239
+ "image_std": [
240
+ 1.0,
241
+ 1.0,
242
+ 1.0
243
+ ],
244
+ "max_soft_tokens": 280,
245
+ "patch_size": 16,
246
+ "pooling_kernel_size": 3,
247
+ "resample": 3,
248
+ "rescale_factor": 0.00392156862745098
249
+ },
250
+ "image_seq_length": 280,
251
+ "image_std": [
252
+ 1.0,
253
+ 1.0,
254
+ 1.0
255
+ ],
256
+ "max_soft_tokens": 70,
257
+ "num_frames": 32,
258
+ "patch_size": 16,
259
+ "pooling_kernel_size": 3,
260
+ "resample": 3,
261
+ "rescale_factor": 0.00392156862745098,
262
+ "return_metadata": false,
263
+ "video_processor": {
264
+ "do_convert_rgb": true,
265
+ "do_normalize": true,
266
+ "do_rescale": true,
267
+ "do_resize": true,
268
+ "do_sample_frames": true,
269
+ "image_mean": [
270
+ 0.0,
271
+ 0.0,
272
+ 0.0
273
+ ],
274
+ "image_std": [
275
+ 1.0,
276
+ 1.0,
277
+ 1.0
278
+ ],
279
+ "max_soft_tokens": 70,
280
+ "num_frames": 32,
281
+ "patch_size": 16,
282
+ "pooling_kernel_size": 3,
283
+ "resample": 3,
284
+ "rescale_factor": 0.00392156862745098,
285
+ "return_metadata": false,
286
+ "video_processor_type": "Gemma4VideoProcessor"
287
+ },
288
+ "video_processor_type": "Gemma4VideoProcessor"
289
+ }
290
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
3
+ size 32169626
tokenizer_config.json ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_token": "<|audio|>",
3
+ "backend": "tokenizers",
4
+ "boa_token": "<|audio>",
5
+ "boi_token": "<|image>",
6
+ "bos_token": "<bos>",
7
+ "eoa_token": "<audio|>",
8
+ "eoc_token": "<channel|>",
9
+ "eoi_token": "<image|>",
10
+ "eos_token": "<eos>",
11
+ "eot_token": "<turn|>",
12
+ "escape_token": "<|\"|>",
13
+ "etc_token": "<tool_call|>",
14
+ "etd_token": "<tool|>",
15
+ "etr_token": "<tool_response|>",
16
+ "extra_special_tokens": [
17
+ "<|video|>"
18
+ ],
19
+ "image_token": "<|image|>",
20
+ "is_local": true,
21
+ "mask_token": "<mask>",
22
+ "model_max_length": 1000000000000000019884624838656,
23
+ "model_specific_special_tokens": {
24
+ "audio_token": "<|audio|>",
25
+ "boa_token": "<|audio>",
26
+ "boi_token": "<|image>",
27
+ "eoa_token": "<audio|>",
28
+ "eoc_token": "<channel|>",
29
+ "eoi_token": "<image|>",
30
+ "eot_token": "<turn|>",
31
+ "escape_token": "<|\"|>",
32
+ "etc_token": "<tool_call|>",
33
+ "etd_token": "<tool|>",
34
+ "etr_token": "<tool_response|>",
35
+ "image_token": "<|image|>",
36
+ "soc_token": "<|channel>",
37
+ "sot_token": "<|turn>",
38
+ "stc_token": "<|tool_call>",
39
+ "std_token": "<|tool>",
40
+ "str_token": "<|tool_response>",
41
+ "think_token": "<|think|>"
42
+ },
43
+ "pad_token": "<pad>",
44
+ "padding_side": "left",
45
+ "processor_class": "Gemma4Processor",
46
+ "response_schema": {
47
+ "properties": {
48
+ "content": {
49
+ "type": "string"
50
+ },
51
+ "role": {
52
+ "const": "assistant"
53
+ },
54
+ "thinking": {
55
+ "type": "string"
56
+ },
57
+ "tool_calls": {
58
+ "items": {
59
+ "properties": {
60
+ "function": {
61
+ "properties": {
62
+ "arguments": {
63
+ "additionalProperties": {},
64
+ "type": "object",
65
+ "x-parser": "gemma4-tool-call"
66
+ },
67
+ "name": {
68
+ "type": "string"
69
+ }
70
+ },
71
+ "type": "object",
72
+ "x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})"
73
+ },
74
+ "type": {
75
+ "const": "function"
76
+ }
77
+ },
78
+ "type": "object"
79
+ },
80
+ "type": "array",
81
+ "x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>"
82
+ }
83
+ },
84
+ "type": "object",
85
+ "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<content>(?:(?!\\<\\|tool_call\\>)(?!\\<turn\\|\\>).)+)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?:\\<turn\\|\\>)?"
86
+ },
87
+ "soc_token": "<|channel>",
88
+ "sot_token": "<|turn>",
89
+ "stc_token": "<|tool_call>",
90
+ "std_token": "<|tool>",
91
+ "str_token": "<|tool_response>",
92
+ "think_token": "<|think|>",
93
+ "tokenizer_class": "GemmaTokenizer",
94
+ "unk_token": "<unk>",
95
+ "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 {%- set add_comma = false -%}\n {%- if key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{ key }}:{\n {%- if value['description'] -%}\n description:<|\"|>{{ value['description'] }}<|\"|>\n {%- set add_comma = true -%}\n {%- endif -%}\n {%- if value['nullable'] %}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n nullable:true\n {%- endif -%}\n {%- if value['type'] | upper == 'STRING' -%}\n {%- if value['enum'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\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 <|\"|>{{- item -}}<|\"|>\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 <|\"|>{{- req_item -}}<|\"|>\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 {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n type:<|\"|>{{ value['type'] | upper }}<|\"|>}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{%- macro format_function_declaration(tool_data) -%}\n declaration:{{- tool_data['function']['name'] -}}{description:<|\"|>{{- tool_data['function']['description'] -}}<|\"|>\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 <|\"|>{{- item -}}<|\"|>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:<|\"|>{{- params['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n {%- if 'response' in tool_data['function'] -%}\n {%- set response_declaration = tool_data['function']['response'] -%}\n ,response:{\n {%- if response_declaration['description'] -%}\n description:<|\"|>{{- response_declaration['description'] -}}<|\"|>,\n {%- endif -%}\n {%- if response_declaration['type'] | upper == 'OBJECT' -%}\n type:<|\"|>{{- response_declaration['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n }\n{%- endmacro -%}\n{%- macro format_argument(argument, escape_keys=True) -%}\n {%- if argument is string -%}\n {{- '<|\"|>' + argument + '<|\"|>' -}}\n {%- elif argument is boolean -%}\n {{- 'true' if argument else 'false' -}}\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 {{- '<|\"|>' + key + '<|\"|>' -}}\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{%- macro strip_thinking(text) -%}\n {%- set ns = namespace(result='') -%}\n {%- for part in text.split('<channel|>') -%}\n {%- if '<|channel>' in part -%}\n {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}\n {%- else -%}\n {%- set ns.result = ns.result + part -%}\n {%- endif -%}\n {%- endfor -%}\n {{- ns.result | trim -}}\n{%- endmacro -%}\n\n{%- set ns = namespace(prev_message_type=None) -%}\n{%- set loop_messages = messages -%}\n{{ bos_token }}\n{#- Handle System/Tool Definitions Block -#}\n{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}\n {{- '<|turn>system\\n' -}}\n\n {#- Inject Thinking token at the very top of the FIRST system turn -#}\n {%- if enable_thinking is defined and enable_thinking -%}\n {{- '<|think|>' -}}\n {%- set ns.prev_message_type = 'think' -%}\n {%- endif -%}\n\n {%- if messages[0]['role'] in ['system', 'developer'] -%}\n {{- messages[0]['content'] | trim -}}\n {%- set loop_messages = messages[1:] -%}\n {%- endif -%}\n\n {%- if tools -%}\n {%- for tool in tools %}\n {{- '<|tool>' -}}\n {{- format_function_declaration(tool) | trim -}}\n {{- '<tool|>' -}}\n {%- endfor %}\n {%- set ns.prev_message_type = 'tool' -%}\n {%- endif -%}\n\n {{- '<turn|>\\n' -}}\n{%- endif %}\n\n{#- Loop through messages -#}\n{%- for message in loop_messages -%}\n {%- set ns.prev_message_type = None -%}\n {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}\n {{- '<|turn>' + role + '\\n' }}\n\n {%- if message['tool_calls'] -%}\n {%- for tool_call in message['tool_calls'] -%}\n {%- set function = tool_call['function'] -%}\n {{- '<|tool_call>call:' + function['name'] + '{' -}}\n {%- if function['arguments'] is mapping -%}\n {%- set ns_args = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns_args.found_first %},{% endif -%}\n {%- set ns_args.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is string -%}\n {{- function['arguments'] -}}\n {%- endif -%}\n {{- '}<tool_call|>' -}}\n {%- endfor -%}\n {%- set ns.prev_message_type = 'tool_call' -%}\n {%- endif -%}\n\n {%- if message['tool_responses'] -%}\n {#- Tool Response handling -#}\n {%- for tool_response in message['tool_responses'] -%}\n {{- '<|tool_response>' -}}\n {%- if tool_response['response'] is mapping -%}\n {{- 'response:' + tool_response['name'] | default('unknown') + '{' -}}\n {%- for key, value in tool_response['response'] | dictsort -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- '}' -}}\n {%- else -%}\n {{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}}\n {%- endif -%}\n {{- '<tool_response|>' -}}\n {%- endfor -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endif -%}\n\n {%- if message['content'] is string -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(message['content']) -}}\n {%- else -%}\n {{- message['content'] | trim -}}\n {%- endif -%}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'text' -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(item['text']) -}}\n {%- else -%}\n {{- item['text'] | trim -}}\n {%- endif -%}\n {%- elif item['type'] == 'image' -%}\n {{- '\\n\\n<|image|>\\n\\n' -}}\n {%- set ns.prev_message_type = 'image' -%}\n {%- elif item['type'] == 'audio' -%}\n {{- '<|audio|>' -}}\n {%- set ns.prev_message_type = 'audio' -%}\n {%- elif item['type'] == 'video' -%}\n {{- '\\n\\n<|video|>\\n\\n' -}}\n {%- set ns.prev_message_type = 'video' -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if not (message['tool_responses'] and not message['content']) -%}\n {{- '<turn|>\\n' -}}\n {%- endif -%}\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {%- if ns.prev_message_type != 'tool_response' -%}\n {{- '<|turn>model\\n' -}}\n {%- endif -%}\n{%- endif -%}"
96
+ }