zecanard commited on
Commit
d60ba92
·
verified ·
1 Parent(s): 5119913

Add files using upload-large-folder tool

Browse files
Files changed (3) hide show
  1. README.md +18 -15
  2. chat_template.jinja +45 -126
  3. tokenizer_config.json +4 -4
README.md CHANGED
@@ -1,20 +1,21 @@
1
  ---
2
  base_model: TeichAI/gemma-4-31B-it-Claude-Opus-Distill
 
 
 
3
  tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - gemma4
8
- - reasoning
9
- - mlx
10
  license: apache-2.0
11
  datasets:
12
- - TeichAI/Claude-Opus-4.6-Reasoning-887x
13
- - TeichAI/Claude-Sonnet-4.6-Reasoning-1100x
14
- - TeichAI/claude-4.5-opus-high-reasoning-250x
15
- - Crownelius/Opus-4.6-Reasoning-2100x-formatted
16
- library_name: mlx
17
- pipeline_tag: image-text-to-text
18
  ---
19
  # 🦆 zecanard/gemma-4-31B-it-Claude-Opus-Distilled-MLX-8bit-mxfp8
20
 
@@ -23,9 +24,9 @@ Please refer to the [original model card](https://huggingface.co/TeichAI/gemma-4
23
 
24
  ## 🌟 Quality
25
 
26
- Quantized vision language model with **8.564 bits per weight**.
27
 
28
- `mlx_vlm.convert --hf-path TeichAI/gemma-4-31B-it-Claude-Opus-Distill --quantize --q-bits 8 --q-group-size 32 --q-mode mxfp8`
29
 
30
  ## 🛠️ Customizations
31
 
@@ -33,6 +34,8 @@ This quant is aware of the current date, and also enables thinking (if available
33
 
34
  `{%- set enable_thinking = true %}`
35
 
 
 
36
  ## 🖥️ Use with `mlx`
37
 
38
  ```bash
@@ -40,5 +43,5 @@ pip install -U mlx-vlm
40
  ```
41
 
42
  ```bash
43
- mlx_vlm.generate --model zecanard/gemma-4-31B-it-Claude-Opus-Distilled-MLX-8bit-mxfp8 --max-tokens 100 --temperature 0.0 --prompt "Describe this image." --image <path_to_image>
44
  ```
 
1
  ---
2
  base_model: TeichAI/gemma-4-31B-it-Claude-Opus-Distill
3
+ language: en
4
+ pipeline_tag: image-text-to-text
5
+ library_name: mlx
6
  tags:
7
+ - mlx
8
+ - text-generation-inference
9
+ - transformers
10
+ - unsloth
11
+ - gemma4
12
+ - reasoning
13
  license: apache-2.0
14
  datasets:
15
+ - TeichAI/Claude-Opus-4.6-Reasoning-887x
16
+ - TeichAI/Claude-Sonnet-4.6-Reasoning-1100x
17
+ - TeichAI/claude-4.5-opus-high-reasoning-250x
18
+ - Crownelius/Opus-4.6-Reasoning-2100x-formatted
 
 
19
  ---
20
  # 🦆 zecanard/gemma-4-31B-it-Claude-Opus-Distilled-MLX-8bit-mxfp8
21
 
 
24
 
25
  ## 🌟 Quality
26
 
27
+ Quantized vision language model with an effective **8.564 bits per weight**.
28
 
29
+ `mlx_vlm.convert --quantize --q-bits 8 --q-group-size 32 --q-mode mxfp8`
30
 
31
  ## 🛠️ Customizations
32
 
 
34
 
35
  `{%- set enable_thinking = true %}`
36
 
37
+ You may also need to adjust your environment’s **Reasoning Section Parsing** to recognize `<|channel>thought` as the **Start String**, and `<channel|>` as the **End String**.
38
+
39
  ## 🖥️ Use with `mlx`
40
 
41
  ```bash
 
43
  ```
44
 
45
  ```bash
46
+ mlx_vlm.generate --model zecanard/gemma-4-31B-it-Claude-Opus-Distilled-MLX-8bit-mxfp8 --max-tokens 100 --temperature 0 --prompt "Describe this image." --image <path_to_image>
47
  ```
chat_template.jinja CHANGED
@@ -3,7 +3,7 @@
3
  {%- if strftime_now is defined %}
4
  {%- set currentDate = strftime_now("%Y-%m-%d %G:%i:%s") %}
5
  {%- elif not currentDate is defined %}
6
- {%- set currentDate = "2026-04-13" %}
7
  {%- endif %}
8
  {{- "The current date is: " + currentDate + ".\n\n" }}
9
  {#- Template customizations by @zecanard. #}
@@ -20,15 +20,34 @@
20
  description:<|"|>{{ value['description'] }}<|"|>
21
  {%- set add_comma = true -%}
22
  {%- endif -%}
 
 
 
 
23
  {%- if value['type'] | upper == 'STRING' -%}
24
  {%- if value['enum'] -%}
25
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
26
  enum:{{ format_argument(value['enum']) }}
27
  {%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  {%- elif value['type'] | upper == 'ARRAY' -%}
29
  {%- if value['items'] is mapping and value['items'] -%}
30
- {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
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 -%}
@@ -61,32 +80,6 @@
61
  }
62
  {%- endif -%}
63
  {%- endif -%}
64
- {%- if value['nullable'] %}
65
- {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
66
- nullable:true
67
- {%- endif -%}
68
- {%- if value['type'] | upper == 'OBJECT' -%}
69
- {%- if value['properties'] is defined and value['properties'] is mapping -%}
70
- {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
71
- properties:{
72
- {{- format_parameters(value['properties'], value['required'] | default([])) -}}
73
- }
74
- {%- elif value is mapping -%}
75
- {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
76
- properties:{
77
- {{- format_parameters(value, value['required'] | default([])) -}}
78
- }
79
- {%- endif -%}
80
- {%- if value['required'] -%}
81
- {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
82
- required:[
83
- {%- for item in value['required'] | default([]) -%}
84
- <|"|>{{- item -}}<|"|>
85
- {%- if not loop.last %},{% endif -%}
86
- {%- endfor -%}
87
- ]
88
- {%- endif -%}
89
- {%- endif -%}
90
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
91
  type:<|"|>{{ value['type'] | upper }}<|"|>}
92
  {%- endif -%}
@@ -166,31 +159,16 @@
166
  {{- ns.result | trim -}}
167
  {%- endmacro -%}
168
 
169
- {%- macro format_tool_response_block(tool_name, response) -%}
170
- {{- '<|tool_response>' -}}
171
- {%- if response is mapping -%}
172
- {{- 'response:' + tool_name + '{' -}}
173
- {%- for key, value in response | dictsort -%}
174
- {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
175
- {%- if not loop.last %},{% endif -%}
176
- {%- endfor -%}
177
- {{- '}' -}}
178
- {%- else -%}
179
- {{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}
180
- {%- endif -%}
181
- {{- '<tool_response|>' -}}
182
- {%- endmacro -%}
183
-
184
  {%- set ns = namespace(prev_message_type=None) -%}
185
  {%- set loop_messages = messages -%}
186
- {{- bos_token -}}
187
  {#- Handle System/Tool Definitions Block -#}
188
  {%- if enable_thinking | default(true) or tools or messages[0]['role'] in ['system', 'developer'] -%}
189
  {{- '<|turn>system\n' -}}
190
 
191
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
192
  {%- if enable_thinking | default(true) -%}
193
- {{- '<|think|>\n' -}}
194
  {%- set ns.prev_message_type = 'think' -%}
195
  {%- endif -%}
196
 
@@ -211,41 +189,11 @@
211
  {{- '<turn|>\n' -}}
212
  {%- endif %}
213
 
214
- {#- Pre-scan: find last user message index for reasoning guard -#}
215
- {%- set ns_turn = namespace(last_user_idx=-1) -%}
216
- {%- for i in range(loop_messages | length) -%}
217
- {%- if loop_messages[i]['role'] == 'user' -%}
218
- {%- set ns_turn.last_user_idx = i -%}
219
- {%- endif -%}
220
- {%- endfor -%}
221
-
222
  {#- Loop through messages -#}
223
  {%- for message in loop_messages -%}
224
- {%- if message['role'] != 'tool' -%}
225
  {%- set ns.prev_message_type = None -%}
226
  {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
227
- {#- Detect continuation: suppress duplicate <|turn>model when previous non-tool message was also assistant -#}
228
- {%- set prev_nt = namespace(role=None, found=false) -%}
229
- {%- if loop.index0 > 0 -%}
230
- {%- for j in range(loop.index0 - 1, -1, -1) -%}
231
- {%- if not prev_nt.found -%}
232
- {%- if loop_messages[j]['role'] != 'tool' -%}
233
- {%- set prev_nt.role = loop_messages[j]['role'] -%}
234
- {%- set prev_nt.found = true -%}
235
- {%- endif -%}
236
- {%- endif -%}
237
- {%- endfor -%}
238
- {%- endif -%}
239
- {%- set continue_same_model_turn = (role == 'model' and prev_nt.role == 'assistant') -%}
240
- {%- if not continue_same_model_turn -%}
241
  {{- '<|turn>' + role + '\n' }}
242
- {%- endif -%}
243
-
244
- {#- Render reasoning/reasoning_content as thinking channel -#}
245
- {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
246
- {%- if thinking_text and loop.index0 > ns_turn.last_user_idx -%}
247
- {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
248
- {%- endif -%}
249
 
250
  {%- if message['tool_calls'] -%}
251
  {%- for tool_call in message['tool_calls'] -%}
@@ -266,49 +214,23 @@
266
  {%- set ns.prev_message_type = 'tool_call' -%}
267
  {%- endif -%}
268
 
269
- {%- set ns_tr_out = namespace(flag=false) -%}
270
- {%- if message.get('tool_responses') -%}
271
- {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
272
  {%- for tool_response in message['tool_responses'] -%}
273
- {{- format_tool_response_block(tool_response['name'] | default('unknown'), tool_response['response']) -}}
274
- {%- set ns_tr_out.flag = true -%}
275
- {%- set ns.prev_message_type = 'tool_response' -%}
276
- {%- endfor -%}
277
- {%- elif message.get('tool_calls') -%}
278
- {#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}
279
- {%- set ns_tool_scan = namespace(stopped=false) -%}
280
- {%- for k in range(loop.index0 + 1, loop_messages | length) -%}
281
- {%- if ns_tool_scan.stopped -%}
282
- {%- elif loop_messages[k]['role'] != 'tool' -%}
283
- {%- set ns_tool_scan.stopped = true -%}
284
- {%- else -%}
285
- {%- set follow = loop_messages[k] -%}
286
- {#- Resolve tool_call_id to function name -#}
287
- {%- set ns_tname = namespace(name=follow.get('name') | default('unknown')) -%}
288
- {%- for tc in message['tool_calls'] -%}
289
- {%- if tc.get('id') == follow.get('tool_call_id') -%}
290
- {%- set ns_tname.name = tc['function']['name'] -%}
291
- {%- endif -%}
292
  {%- endfor -%}
293
- {#- Handle content as string or content-parts array -#}
294
- {%- set tool_body = follow.get('content') -%}
295
- {%- if tool_body is string -%}
296
- {{- format_tool_response_block(ns_tname.name, tool_body) -}}
297
- {%- elif tool_body is sequence and tool_body is not string -%}
298
- {%- set ns_txt = namespace(s='') -%}
299
- {%- for part in tool_body -%}
300
- {%- if part.get('type') == 'text' -%}
301
- {%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}
302
- {%- endif -%}
303
- {%- endfor -%}
304
- {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
305
- {%- else -%}
306
- {{- format_tool_response_block(ns_tname.name, tool_body) -}}
307
- {%- endif -%}
308
- {%- set ns_tr_out.flag = true -%}
309
- {%- set ns.prev_message_type = 'tool_response' -%}
310
  {%- endif -%}
 
311
  {%- endfor -%}
 
312
  {%- endif -%}
313
 
314
  {%- if message['content'] is string -%}
@@ -326,31 +248,28 @@
326
  {{- item['text'] | trim -}}
327
  {%- endif -%}
328
  {%- elif item['type'] == 'image' -%}
329
- {{- '<|image|>' -}}
330
  {%- set ns.prev_message_type = 'image' -%}
331
  {%- elif item['type'] == 'audio' -%}
332
  {{- '<|audio|>' -}}
333
  {%- set ns.prev_message_type = 'audio' -%}
334
  {%- elif item['type'] == 'video' -%}
335
- {{- '<|video|>' -}}
336
  {%- set ns.prev_message_type = 'video' -%}
337
  {%- endif -%}
338
  {%- endfor -%}
339
  {%- endif -%}
340
 
341
- {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
342
- {{- '<|tool_response>' -}}
343
- {%- elif not (ns_tr_out.flag and not message.get('content')) -%}
344
  {{- '<turn|>\n' -}}
345
  {%- endif -%}
346
- {%- endif -%}
347
  {%- endfor -%}
348
 
349
  {%- if add_generation_prompt -%}
350
- {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
351
  {{- '<|turn>model\n' -}}
352
- {%- if not enable_thinking | default(true) -%}
353
- {{- '<|channel>thought\n<channel|>' -}}
354
- {%- endif -%}
355
  {%- endif -%}
356
- {%- endif -%}
 
 
 
 
3
  {%- if strftime_now is defined %}
4
  {%- set currentDate = strftime_now("%Y-%m-%d %G:%i:%s") %}
5
  {%- elif not currentDate is defined %}
6
+ {%- set currentDate = "2026-04-15" %}
7
  {%- endif %}
8
  {{- "The current date is: " + currentDate + ".\n\n" }}
9
  {#- Template customizations by @zecanard. #}
 
20
  description:<|"|>{{ value['description'] }}<|"|>
21
  {%- set add_comma = true -%}
22
  {%- endif -%}
23
+ {%- if value['nullable'] %}
24
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
25
+ nullable:true
26
+ {%- endif -%}
27
  {%- if value['type'] | upper == 'STRING' -%}
28
  {%- if value['enum'] -%}
29
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
30
  enum:{{ format_argument(value['enum']) }}
31
  {%- endif -%}
32
+ {%- elif value['type'] | upper == 'OBJECT' -%}
33
+ ,properties:{
34
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
35
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
36
+ {%- elif value is mapping -%}
37
+ {{- format_parameters(value, value['required'] | default([])) -}}
38
+ {%- endif -%}
39
+ }
40
+ {%- if value['required'] -%}
41
+ ,required:[
42
+ {%- for item in value['required'] | default([]) -%}
43
+ <|"|>{{- item -}}<|"|>
44
+ {%- if not loop.last %},{% endif -%}
45
+ {%- endfor -%}
46
+ ]
47
+ {%- endif -%}
48
  {%- elif value['type'] | upper == 'ARRAY' -%}
49
  {%- if value['items'] is mapping and value['items'] -%}
50
+ ,items:{
 
51
  {%- set ns_items = namespace(found_first=false) -%}
52
  {%- for item_key, item_value in value['items'] | dictsort -%}
53
  {%- if item_value is not none -%}
 
80
  }
81
  {%- endif -%}
82
  {%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
84
  type:<|"|>{{ value['type'] | upper }}<|"|>}
85
  {%- endif -%}
 
159
  {{- ns.result | trim -}}
160
  {%- endmacro -%}
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  {%- set ns = namespace(prev_message_type=None) -%}
163
  {%- set loop_messages = messages -%}
164
+ {{ bos_token }}
165
  {#- Handle System/Tool Definitions Block -#}
166
  {%- if enable_thinking | default(true) or tools or messages[0]['role'] in ['system', 'developer'] -%}
167
  {{- '<|turn>system\n' -}}
168
 
169
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
170
  {%- if enable_thinking | default(true) -%}
171
+ {{- '<|think|>' -}}
172
  {%- set ns.prev_message_type = 'think' -%}
173
  {%- endif -%}
174
 
 
189
  {{- '<turn|>\n' -}}
190
  {%- endif %}
191
 
 
 
 
 
 
 
 
 
192
  {#- Loop through messages -#}
193
  {%- for message in loop_messages -%}
 
194
  {%- set ns.prev_message_type = None -%}
195
  {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  {{- '<|turn>' + role + '\n' }}
 
 
 
 
 
 
 
197
 
198
  {%- if message['tool_calls'] -%}
199
  {%- for tool_call in message['tool_calls'] -%}
 
214
  {%- set ns.prev_message_type = 'tool_call' -%}
215
  {%- endif -%}
216
 
217
+ {%- if message['tool_responses'] -%}
218
+ {#- Tool Response handling -#}
 
219
  {%- for tool_response in message['tool_responses'] -%}
220
+ {{- '<|tool_response>' -}}
221
+ {%- if tool_response['response'] is mapping -%}
222
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{' -}}
223
+ {%- for key, value in tool_response['response'] | dictsort -%}
224
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
225
+ {%- if not loop.last %},{% endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  {%- endfor -%}
227
+ {{- '}' -}}
228
+ {%- else -%}
229
+ {{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  {%- endif -%}
231
+ {{- '<tool_response|>' -}}
232
  {%- endfor -%}
233
+ {%- set ns.prev_message_type = 'tool_response' -%}
234
  {%- endif -%}
235
 
236
  {%- if message['content'] is string -%}
 
248
  {{- item['text'] | trim -}}
249
  {%- endif -%}
250
  {%- elif item['type'] == 'image' -%}
251
+ {{- '\n\n<|image|>\n\n' -}}
252
  {%- set ns.prev_message_type = 'image' -%}
253
  {%- elif item['type'] == 'audio' -%}
254
  {{- '<|audio|>' -}}
255
  {%- set ns.prev_message_type = 'audio' -%}
256
  {%- elif item['type'] == 'video' -%}
257
+ {{- '\n\n<|video|>\n\n' -}}
258
  {%- set ns.prev_message_type = 'video' -%}
259
  {%- endif -%}
260
  {%- endfor -%}
261
  {%- endif -%}
262
 
263
+ {%- if not (message['tool_responses'] and not message['content']) -%}
 
 
264
  {{- '<turn|>\n' -}}
265
  {%- endif -%}
 
266
  {%- endfor -%}
267
 
268
  {%- if add_generation_prompt -%}
269
+ {%- if ns.prev_message_type != 'tool_response' -%}
270
  {{- '<|turn>model\n' -}}
 
 
 
271
  {%- endif -%}
272
+ {%- if not enable_thinking | default(true) -%}
273
+ {{- '<|channel>thought\n<channel|>' -}}
274
+ {%- endif -%}
275
+ {%- endif -%}
tokenizer_config.json CHANGED
@@ -7,7 +7,7 @@
7
  "eoa_token": "<audio|>",
8
  "eoc_token": "<channel|>",
9
  "eoi_token": "<image|>",
10
- "eos_token": "<turn|>",
11
  "eot_token": "<turn|>",
12
  "escape_token": "<|\"|>",
13
  "etc_token": "<tool_call|>",
@@ -19,7 +19,7 @@
19
  "image_token": "<|image|>",
20
  "is_local": true,
21
  "mask_token": "<mask>",
22
- "model_max_length": 262144,
23
  "model_specific_special_tokens": {
24
  "audio_token": "<|audio|>",
25
  "boa_token": "<|audio>",
@@ -41,7 +41,7 @@
41
  "think_token": "<|think|>"
42
  },
43
  "pad_token": "<pad>",
44
- "padding_side": "right",
45
  "processor_class": "Gemma4Processor",
46
  "response_schema": {
47
  "properties": {
@@ -82,7 +82,7 @@
82
  }
83
  },
84
  "type": "object",
85
- "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
86
  },
87
  "soc_token": "<|channel>",
88
  "sot_token": "<|turn>",
 
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|>",
 
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>",
 
41
  "think_token": "<|think|>"
42
  },
43
  "pad_token": "<pad>",
44
+ "padding_side": "left",
45
  "processor_class": "Gemma4Processor",
46
  "response_schema": {
47
  "properties": {
 
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>",