ashxhart commited on
Commit
2c6fc65
·
verified ·
1 Parent(s): 8b9ed7b

Release validated hybrid MLX 2-bit model with native MTP

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ 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
+ model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Z.AI Co., Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: mlx
3
+ license: mit
4
+ license_link: LICENSE
5
+ base_model: zai-org/GLM-5.3-Flash
6
+ base_model_relation: quantized
7
+ pipeline_tag: image-text-to-text
8
+ language:
9
+ - en
10
+ - zh
11
+ tags:
12
+ - mlx
13
+ - mlx-vlm
14
+ - omlx
15
+ - glm
16
+ - glm5-next
17
+ - native-mtp
18
+ - speculative-decoding
19
+ - mixed-precision
20
+ - mixture-of-experts
21
+ - multimodal
22
+ - vision-language
23
+ - quantized
24
+ - apple-silicon
25
+ - 2-bit
26
+ ---
27
+
28
+ <div align="center">
29
+ <a href="https://huggingface.co/zai-org/GLM-5.3-Flash">
30
+ <img src="zai-logo.png" width="72" height="72" alt="Z.ai logo">
31
+ </a>
32
+ </div>
33
+
34
+ <p align="center">
35
+ <img src="https://img.shields.io/badge/Z.ai-GLM--5.3--Flash-111827?style=flat-square" alt="Z.ai GLM-5.3-Flash">
36
+ <img src="https://img.shields.io/badge/Apple_Silicon-MLX-000000?style=flat-square&logo=apple&logoColor=white" alt="Apple silicon MLX">
37
+ <img src="https://img.shields.io/badge/Native_MTP-Depth_1-2563EB?style=flat-square" alt="Native MTP depth 1">
38
+ <img src="https://img.shields.io/badge/Vontra-Hybrid_2--bit-6E56CF?style=flat-square&logo=huggingface&logoColor=white" alt="Vontra hybrid 2-bit">
39
+ </p>
40
+
41
+ <h1 align="center">GLM-5.3-Flash, hybrid MLX 2-bit with native MTP</h1>
42
+
43
+ <p align="center">
44
+ A deterministic quality-protected MLX conversion of <a href="https://huggingface.co/zai-org/GLM-5.3-Flash">zai-org/GLM-5.3-Flash</a>, retaining the model's matching native next-token prediction layer.
45
+ </p>
46
+
47
+ <p align="center">
48
+ <a href="https://huggingface.co/zai-org/GLM-5.3-Flash">Original model</a> ·
49
+ <a href="https://z.ai/blog/glm-5.3-flash">Z.ai overview</a> ·
50
+ <a href="https://arxiv.org/abs/2602.15763">Technical report</a> ·
51
+ <a href="https://github.com/ml-explore/mlx">Apple MLX</a> ·
52
+ <a href="LICENSE">MIT licence</a>
53
+ </p>
54
+
55
+ > [!IMPORTANT]
56
+ > This is a hybrid 2-bit checkpoint, not a uniform Q2 build. Routed trunk experts use Q2, non-expert language projections use Q8, native-MTP expert projections use Q4, and sensitive components remain BF16. This allocation passed live generation where broader Q2 recipes did not.
57
+
58
+ ## At a glance
59
+
60
+ | Item | Value |
61
+ | --- | --- |
62
+ | Repository | `Vontra/GLM-5.3-Flash-MLX-2bit-MTP` |
63
+ | Base model | [`zai-org/GLM-5.3-Flash`](https://huggingface.co/zai-org/GLM-5.3-Flash) |
64
+ | Source revision | [`04c4e9e95c5da8862dced7e5056455116f83a7e0`](https://huggingface.co/zai-org/GLM-5.3-Flash/commit/04c4e9e95c5da8862dced7e5056455116f83a7e0) |
65
+ | Source weight format | FP8 E4M3 with 128x128 block scaling |
66
+ | Output format | MLX safetensors, affine weight quantisation, group size 64 |
67
+ | Quantisation | Deterministic hybrid 2-bit recipe |
68
+ | Native MTP | Preserved, one upstream prediction layer, runtime depth 1 |
69
+ | Indexed tensors | 114,154 |
70
+ | Weight shards | 26 |
71
+ | Tensor payload | 111,317,859,192 bytes, 111.318 GB / 103.673 GiB |
72
+ | Configured context | 1,048,576 tokens |
73
+ | Architecture | `glm5_next`, multimodal sparse MoE |
74
+
75
+ ## Precision recipe
76
+
77
+ | Component | Treatment |
78
+ | --- | --- |
79
+ | Routed trunk experts | Q2 affine, group size 64; 36,288 source matrices stacked into 126 runtime modules |
80
+ | Non-expert language projections | Q8 affine, group size 64; 540 source matrices mapped to 552 runtime modules |
81
+ | Native-MTP routed experts | Q4 affine, group size 64; 864 source matrices stacked into 3 runtime modules |
82
+ | Sparse indexer projections | All 36 at Q8 affine, group size 64 |
83
+ | Token embedding and output head | BF16 |
84
+ | Vision encoder and projector | BF16 |
85
+ | MTP fusion projection | BF16 |
86
+ | Routers, hyper-connections, norms and other non-quantisable tensors | Source precision |
87
+
88
+ This is weight-only post-training quantisation. It does not retrain or fine-tune the upstream model.
89
+
90
+ ## Runtime compatibility
91
+
92
+ GLM-5.3-Flash uses the `glm5_next` multimodal architecture and a native NextN/MTP block. Use a runtime that supports this architecture and per-module MLX quantisation metadata.
93
+
94
+ | Component | Tested version |
95
+ | --- | --- |
96
+ | oMLX | 0.6.3rc3, build 2475 |
97
+ | MLX | 0.32.0 |
98
+ | mlx-lm | 0.31.3 |
99
+ | mlx-vlm | 0.6.3 |
100
+ | Native-MTP draft depth | 1 |
101
+
102
+ The current upstream chat template defaults to maximum reasoning effort. For short, direct answers, pass `reasoning_effort: low` through the chat-template arguments.
103
+
104
+ ## Download and use
105
+
106
+ ```bash
107
+ hf download Vontra/GLM-5.3-Flash-MLX-2bit-MTP \
108
+ --local-dir ./GLM-5.3-Flash-MLX-2bit-MTP
109
+ ```
110
+
111
+ Add the downloaded directory to a compatible oMLX model directory, refresh the model registry, and select the model. Native MTP is optional and uses draft depth 1.
112
+
113
+ For an OpenAI-compatible request through oMLX, include the upstream low-reasoning template option when you want a concise answer:
114
+
115
+ ```json
116
+ {
117
+ "model": "GLM-5.3-Flash-MLX-2bit-MTP",
118
+ "messages": [{"role": "user", "content": "What is the capital of France?"}],
119
+ "chat_template_kwargs": {"reasoning_effort": "low"}
120
+ }
121
+ ```
122
+
123
+ ## Apple M3 Studio performance
124
+
125
+ Each result is the median of three 512-token text-generation runs after a separate warm-up. Both modes used the same checkpoint, prompt, deterministic sampling settings, and current upstream chat template.
126
+
127
+ | Runtime mode | Runs | Output per run | Median decode speed | Long-run output parity |
128
+ | --- | ---: | ---: | ---: | --- |
129
+ | Native MTP disabled | 3 | 512 tokens | **6.063 tok/s** | Reference |
130
+ | Native MTP enabled, depth 1 | 3 | 512 tokens | **6.257 tok/s** | Exact match |
131
+
132
+ Native MTP improved median decode throughput by **3.21%** in this test. All six 512-token runs produced the same output hash. MTP gains depend on the prompt and draft acceptance, so treat this as a practical reference for the tested Studio rather than a universal result.
133
+
134
+ ## Architecture
135
+
136
+ GLM-5.3-Flash combines KDA linear-attention layers with periodic sparse-attention layers, a sparse mixture-of-experts feed-forward stack, manifold-constrained hyper-connections, a vision encoder, and one native next-token prediction layer.
137
+
138
+ | Architecture detail | Upstream value |
139
+ | --- | ---: |
140
+ | Parameters | 320B total / 18B active |
141
+ | Language layers | 45 |
142
+ | Routed / active experts | 288 / 8, plus 1 shared expert |
143
+ | Hidden size | 4,096 |
144
+ | Attention heads | 64 |
145
+ | Native MTP layers | 1 |
146
+ | Configured maximum context | 1,048,576 tokens |
147
+
148
+ See the [official model card](https://huggingface.co/zai-org/GLM-5.3-Flash), [Z.ai overview](https://z.ai/blog/glm-5.3-flash), and [GLM-5 technical report](https://arxiv.org/abs/2602.15763) for upstream training, evaluations, intended uses, and safety guidance.
149
+
150
+ ## Validation
151
+
152
+ | Check | Result |
153
+ | --- | --- |
154
+ | Official source structure | 76,108 tensors, 62 shards and 37,338 FP8 weight-scale pairs validated before conversion |
155
+ | Safetensors index and shard resolution | 114,154 entries resolve to 26 final shards |
156
+ | Saved precision layout | 36,288 Q2, 864 Q4 and 540 Q8 source matrices; all quantised matrices have matching weight, scale and bias tensors |
157
+ | Vision payload | 347 BF16 source tensors preserved |
158
+ | Native MTP structure | Complete upstream prediction layer preserved; runtime reports native-MTP compatibility |
159
+ | MTP disabled generation | Deterministic factual, arithmetic, instruction and coherence checks passed |
160
+ | MTP enabled generation | The same checks passed with exact output parity |
161
+ | Sustained generation | Three 512-token runs per mode; 6.063 tok/s off and 6.257 tok/s on |
162
+
163
+ ## Limitations
164
+
165
+ - Hybrid quantisation can reduce quality relative to the official checkpoint. The effect depends on the workload.
166
+ - The configured one-million-token context does not mean every Apple silicon system has enough memory for a full-context request.
167
+ - Image and video prefill have different memory and throughput characteristics from text-only generation. The published throughput numbers are text-only.
168
+ - Native MTP may be neutral or slower on prompts with low draft acceptance.
169
+ - Runtime support for `glm5_next`, mixed per-module quantisation, and native MTP is version-sensitive.
170
+
171
+ This is a community quantisation, not an official Z.ai release.
172
+
173
+ ## Licence and attribution
174
+
175
+ The upstream model uses the **MIT License**. The official licence text is included as `LICENSE`.
176
+
177
+ Model design, training, upstream evaluations, and documentation belong to Z.ai and the GLM-5 contributors. The MLX conversion, native-MTP preservation, validation, and packaging are provided by [Vontra](https://huggingface.co/Vontra).
178
+
179
+ If you use this model in research, cite the upstream report:
180
+
181
+ ```bibtex
182
+ @misc{glm5team2026glm5,
183
+ title = {GLM-5: from Vibe Coding to Agentic Engineering},
184
+ author = {GLM-5-Team and others},
185
+ year = {2026},
186
+ eprint = {2602.15763},
187
+ archivePrefix= {arXiv},
188
+ primaryClass = {cs.LG},
189
+ url = {https://arxiv.org/abs/2602.15763}
190
+ }
191
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gMASK]<sop>
2
+ {%- set effective_reasoning_effort = reasoning_effort if reasoning_effort is defined and reasoning_effort in ['low', 'high'] else 'max' -%}
3
+ {%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
4
+ {%- set clear_thinking = clear_thinking if clear_thinking is defined else false -%}
5
+ {%- if tools -%}
6
+ {%- macro tool_to_json(tool) -%}
7
+ {%- set ns_tool = namespace(first=true) -%}
8
+ {{ '{' -}}
9
+ {%- for k, v in tool.items() -%}
10
+ {%- if k != 'defer_loading' and k != 'strict' -%}
11
+ {%- if not ns_tool.first -%}{{- ', ' -}}{%- endif -%}
12
+ {%- set ns_tool.first = false -%}
13
+ "{{ k }}": {{ v | tojson(ensure_ascii=False) }}
14
+ {%- endif -%}
15
+ {%- endfor -%}
16
+ {{- '}' -}}
17
+ {%- endmacro -%}
18
+ {%- macro tool_references_to_response(refs) -%}
19
+ {{- '<tool_response><tools>\n' -}}
20
+ {%- for tr in refs -%}
21
+ {%- for tool in tools -%}
22
+ {%- if 'function' in tool -%}
23
+ {%- set tool = tool['function'] -%}
24
+ {%- endif -%}
25
+ {%- if tool.name == tr.name -%}
26
+ {{- tool_to_json(tool) + '\n' -}}
27
+ {%- endif -%}
28
+ {%- endfor -%}
29
+ {%- endfor -%}
30
+ {{- '</tools></tool_response>' -}}
31
+ {%- endmacro -%}
32
+ <|system|>
33
+ # Tools
34
+
35
+ You may call one or more functions to assist with the user query.
36
+
37
+ You are provided with function signatures within <tools></tools> XML tags:
38
+ <tools>
39
+ {% for tool in tools %}
40
+ {%- if 'function' in tool -%}
41
+ {%- set tool = tool['function'] -%}
42
+ {%- endif -%}
43
+ {% if tool.defer_loading is not defined or not tool.defer_loading %}
44
+ {{ tool_to_json(tool) }}
45
+ {% endif %}
46
+ {% endfor %}
47
+ </tools>
48
+
49
+ For each function call, output the function name and arguments within the following XML format:
50
+ <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}
51
+ {%- macro emit_image() -%}<|begin_of_image|><|image|><|end_of_image|>{%- endmacro -%}
52
+ {%- macro emit_video() -%}<|begin_of_video|><|video|><|end_of_video|>{%- endmacro -%}
53
+ {%- macro emit_audio() -%}<|begin_of_audio|><|end_of_audio|>{%- endmacro -%}
54
+ {%- macro visible_text(content) -%}
55
+ {%- if content is string -%}
56
+ {{- content -}}
57
+ {%- elif content is iterable and content is not mapping -%}
58
+ {%- for item in content -%}
59
+ {%- if item is mapping and item.type == 'text' -%}
60
+ {{- item.text -}}
61
+ {%- elif item is string -%}
62
+ {{- item -}}
63
+ {%- elif item is mapping and item.type in ['image', 'image_url'] -%}
64
+ {{- emit_image() -}}
65
+ {%- elif item is mapping and item.type in ['video', 'video_url'] -%}
66
+ {{- emit_video() -}}
67
+ {%- elif item is mapping and item.type in ['audio', 'audio_url', 'input_audio'] -%}
68
+ {{- emit_audio() -}}
69
+ {%- endif -%}
70
+ {%- endfor -%}
71
+ {%- else -%}
72
+ {{- content }}
73
+ {%- endif -%}
74
+ {%- endmacro -%}
75
+ {%- macro tool_response(text) -%}
76
+ {{- '<tool_response>' + text + '</tool_response>' -}}
77
+ {%- endmacro -%}
78
+ {%- macro render_tool_response(m) -%}
79
+ {%- if m.content is string -%}
80
+ {{- tool_response(m.content) -}}
81
+ {%- elif m.content and m.content is not mapping and m.content.0.type == "tool_reference" -%}
82
+ {{- tool_references_to_response(m.content) -}}
83
+ {%- elif is_list_of_outputs(m) -%}
84
+ {%- for tr in m.content -%}
85
+ {%- if tr.output is iterable and tr.output is not string and tr.output is not mapping and tr.output and tr.output.0.type == "tool_reference" -%}
86
+ {{- tool_references_to_response(tr.output) -}}
87
+ {%- else -%}
88
+ {{- tool_response(visible_text(tr.output)) -}}
89
+ {%- endif -%}
90
+ {%- endfor -%}
91
+ {%- else -%}
92
+ {{- tool_response(visible_text(m.content)) -}}
93
+ {%- endif -%}
94
+ {%- endmacro -%}
95
+ {%- macro id_of(obj) -%}
96
+ {%- if obj.tool_call_id -%}
97
+ {{- obj.tool_call_id -}}
98
+ {%- elif obj.id -%}
99
+ {{- obj.id -}}
100
+ {%- endif -%}
101
+ {%- endmacro -%}
102
+ {%- macro is_list_of_outputs(m) -%}
103
+ {%- if m.content and m.content.0.output is defined -%}1{%- endif -%}
104
+ {%- endmacro -%}
105
+ {%- macro has_dup_tool_result_id(lo, hi, target) -%}
106
+ {%- set ns_cnt = namespace(n=0) -%}
107
+ {%- for k in range(lo, hi + 1) -%}
108
+ {%- set m = messages[k] -%}
109
+ {%- if is_list_of_outputs(m) -%}
110
+ {%- for entry in m.content -%}
111
+ {%- if id_of(entry) == target -%}
112
+ {%- set ns_cnt.n = ns_cnt.n + 1 -%}
113
+ {%- endif -%}
114
+ {%- endfor -%}
115
+ {%- elif id_of(m) == target -%}
116
+ {%- set ns_cnt.n = ns_cnt.n + 1 -%}
117
+ {%- endif -%}
118
+ {%- if ns_cnt.n > 1 -%}{%- break -%}{%- endif -%}
119
+ {%- endfor -%}
120
+ {%- if ns_cnt.n > 1 -%}1{%- endif -%}
121
+ {%- endmacro -%}
122
+ {%- macro tc_id_exists(tcs, target) -%}
123
+ {%- set ns_f = namespace(found=false) -%}
124
+ {%- for tc in tcs -%}
125
+ {%- if id_of(tc) == target -%}
126
+ {%- set ns_f.found = true -%}
127
+ {%- break -%}
128
+ {%- endif -%}
129
+ {%- endfor -%}
130
+ {%- if ns_f.found -%}1{%- endif -%}
131
+ {%- endmacro -%}
132
+ {%- set ns = namespace(last_user_index=-1) -%}
133
+ {%- for m in messages %}
134
+ {%- if m.role == 'user' %}
135
+ {%- set ns.last_user_index = loop.index0 -%}
136
+ {%- endif %}
137
+ {%- endfor %}
138
+ {%- for m in messages -%}
139
+ {%- if m.role == 'user' -%}<|user|>{{ visible_text(m.content) }}
140
+ {%- elif m.role == 'assistant' -%}
141
+ <|assistant|>
142
+ {%- set content = visible_text(m.content) %}
143
+ {%- if m.reasoning_content is string %}
144
+ {%- set reasoning_content = m.reasoning_content %}
145
+ {%- elif '</think>' in content %}
146
+ {%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
147
+ {%- set content = content.split('</think>')[-1] %}
148
+ {%- endif %}
149
+ {%- if (not clear_thinking or loop.index0 > ns.last_user_index) and reasoning_content is defined -%}
150
+ {{ '<think>' + reasoning_content + '</think>'}}
151
+ {%- else -%}
152
+ {{ '<think></think>' }}
153
+ {%- endif -%}
154
+ {%- if content.strip() -%}
155
+ {{ content.strip() }}
156
+ {%- endif -%}
157
+ {% if m.tool_calls %}
158
+ {% for tc in m.tool_calls %}
159
+ {%- if tc.function %}
160
+ {%- set tc = tc.function %}
161
+ {%- endif %}
162
+ {{- '<tool_call>' + tc.name -}}
163
+ {% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
164
+ {% endif %}
165
+ {%- elif m.role == 'tool' -%}
166
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
167
+ {{- '<|observation|>' -}}
168
+ {%- set block_start = loop.index0 -%}
169
+ {%- set ns_blk = namespace(end=block_start) -%}
170
+ {%- for j in range(block_start, messages|length) -%}
171
+ {%- if messages[j].role == 'tool' -%}
172
+ {%- set ns_blk.end = j -%}
173
+ {%- else -%}
174
+ {%- break -%}
175
+ {%- endif -%}
176
+ {%- endfor -%}
177
+ {%- set ns_a = namespace(tool_calls=none) -%}
178
+ {%- if block_start > 0 and messages[block_start - 1].role == 'assistant' and messages[block_start - 1].tool_calls -%}
179
+ {%- set ns_a.tool_calls = messages[block_start - 1].tool_calls -%}
180
+ {%- endif -%}
181
+ {%- set ns_chk = namespace(can_sort=true) -%}
182
+ {%- if not ns_a.tool_calls -%}
183
+ {%- set ns_chk.can_sort = false -%}
184
+ {%- else -%}
185
+ {%- for k in range(block_start, ns_blk.end + 1) -%}
186
+ {%- set m = messages[k] -%}
187
+ {%- if is_list_of_outputs(m) -%}
188
+ {%- for entry in m.content -%}
189
+ {%- set eid = id_of(entry) -%}
190
+ {%- if not eid -%}
191
+ {%- set ns_chk.can_sort = false -%}
192
+ {%- elif has_dup_tool_result_id(block_start, ns_blk.end, eid) -%}
193
+ {%- set ns_chk.can_sort = false -%}
194
+ {%- elif not tc_id_exists(ns_a.tool_calls, eid) -%}
195
+ {%- set ns_chk.can_sort = false -%}
196
+ {%- endif -%}
197
+ {%- endfor -%}
198
+ {%- else -%}
199
+ {%- set tk_id = id_of(m) -%}
200
+ {%- if not tk_id -%}
201
+ {%- set ns_chk.can_sort = false -%}
202
+ {%- elif has_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%}
203
+ {%- set ns_chk.can_sort = false -%}
204
+ {%- elif not tc_id_exists(ns_a.tool_calls, tk_id) -%}
205
+ {%- set ns_chk.can_sort = false -%}
206
+ {%- endif -%}
207
+ {%- endif -%}
208
+ {%- endfor -%}
209
+ {%- for i in range(ns_a.tool_calls | length) -%}
210
+ {%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
211
+ {%- if not tc_id -%}
212
+ {%- set ns_chk.can_sort = false -%}
213
+ {%- endif -%}
214
+ {%- for j in range(i + 1, ns_a.tool_calls | length) -%}
215
+ {%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
216
+ {%- set ns_chk.can_sort = false -%}
217
+ {%- endif -%}
218
+ {%- endfor -%}
219
+ {%- endfor -%}
220
+ {%- endif -%}
221
+ {%- if ns_chk.can_sort -%}
222
+ {%- for tc in ns_a.tool_calls -%}
223
+ {%- set tc_id = id_of(tc) -%}
224
+ {%- for k in range(block_start, ns_blk.end + 1) -%}
225
+ {%- set m = messages[k] -%}
226
+ {%- if is_list_of_outputs(m) -%}
227
+ {%- for entry in m.content -%}
228
+ {%- set eid = id_of(entry) -%}
229
+ {%- if eid == tc_id -%}
230
+ {%- if entry.output is iterable and entry.output is not string and entry.output is not mapping and entry.output and entry.output.0.type == "tool_reference" -%}
231
+ {{- tool_references_to_response(entry.output) -}}
232
+ {%- else -%}
233
+ {{- tool_response(visible_text(entry.output)) -}}
234
+ {%- endif -%}
235
+ {%- endif -%}
236
+ {%- endfor -%}
237
+ {%- else -%}
238
+ {%- set tk_id = id_of(m) -%}
239
+ {%- if tk_id == tc_id -%}
240
+ {{- render_tool_response(m) -}}
241
+ {%- endif -%}
242
+ {%- endif -%}
243
+ {%- endfor -%}
244
+ {%- endfor -%}
245
+ {%- else -%}
246
+ {%- for k in range(block_start, ns_blk.end + 1) -%}
247
+ {{- render_tool_response(messages[k]) -}}
248
+ {%- endfor -%}
249
+ {%- endif -%}
250
+ {% endif -%}
251
+ {%- elif m.role == 'system' -%}
252
+ <|system|>{{ visible_text(m.content) }}
253
+ {%- endif -%}
254
+ {%- endfor -%}
255
+ {%- if add_generation_prompt -%}
256
+ <|assistant|>{{- '<think>' -}}
257
+ {%- endif -%}
config.json ADDED
The diff for this file is too large to render. See raw diff
 
generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": [
4
+ 154820,
5
+ 154827,
6
+ 154829
7
+ ],
8
+ "pad_token_id": 154820,
9
+ "temperature": 1.0,
10
+ "top_p": 0.95,
11
+ "transformers_version": "5.16.0"
12
+ }
model-00001-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0c654ea38e0f40a7728c8062f35d75f6f9304c14d42f19f7574e3f0361c9b17
3
+ size 4262597686
model-00002-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:675fa7549f3678a0b028c840c168694ad12733e8aaf8cf62adb7e7387d088b42
3
+ size 4293514772
model-00003-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c69e1215351a5d5f75998050dc1730acf3fb231e0bcfc63b283d76f552719b9
3
+ size 4294821198
model-00004-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09ad608d9050001dfd74098fc91cc1491dae7e19c1f7626abd95551873cbb89b
3
+ size 4294431997
model-00005-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7b5f142d354e68dd52b5bf42769154fa12a15bd849e712cddec74aa5f3a65de
3
+ size 4295361270
model-00006-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:626c3e92a87ec34f9643cb330a866467a8a774ed4f575c457083855734a8e9de
3
+ size 4293446869
model-00007-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7731687aaefa0ee67c2e94283c0a496c8893aed74f43c0155da87020316721df
3
+ size 4294953179
model-00008-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aef4a3b9c447209cf70e0ed92d479ef288b6d6a05bf56b1883d9db42cb13c05e
3
+ size 4293405720
model-00009-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cbed63a49752edd85c2e266f2a2754d5be9a3c857b40644dd15f58b76744e77
3
+ size 4293986907
model-00010-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27c4647ee77b21e3de79f366b305bd7ab3258709b54530aecca4619e14925914
3
+ size 4294821189
model-00011-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef0eb0e2cf48ebb61d565647feef9d7ea9c155705acb73e3ba3679a56140b40d
3
+ size 4294953263
model-00012-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62337b50ccc850edfdaf2ccc694b9742e0c5824a12b10b80e936d5056b1a66ff
3
+ size 4294839297
model-00013-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9f237024c6cb231cdf139de31e7abf6d0096d67195bf9c09030f0416f23b314
3
+ size 4293447262
model-00014-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11af3e9192c6fb8a9b13c6baf5c74b03079364199591cdab70a79a59ae5d4418
3
+ size 4293163421
model-00015-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f7cdad5391f4d4fd2e898215e0a695f2742b5684a91849ca9c7a0a5edfcd975
3
+ size 4293854344
model-00016-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:200bf1b2950e2122e6dbdcca8470cf34b522410eb4d39837ebf17b8367bfb85f
3
+ size 4294432069
model-00017-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db6a60f0263cf9b73efc868511f51ef1c2460ed8688c68ecba1e6bcddc080c62
3
+ size 4295361284
model-00018-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d09ec8fa0d56b915bc3bdb71483f82459464984b42370f2487eb93f404ddbbb1
3
+ size 4294413721
model-00019-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec969059ea0c6cca1b4a80146449249a0cdbf0fdeda3edc5c72944e9684933fd
3
+ size 4293986723
model-00020-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:317b2e1a2ed7e410ee2ae474c5e6c790d6cbd9a7b1842a249d3ccc72921019ee
3
+ size 4294818375
model-00021-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d6e47b4e09ef6ec808f3e447fc8587cfbc0b8432a0aa99c9eabbcd5a56198e3
3
+ size 4294432430
model-00022-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c183b61a3b329d4dc52b88d1ac6c1e0babf628c08f3cb358b5ece215dfe89ef8
3
+ size 4293986633
model-00023-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1d6be4c536d600d811000f4c8ab64f0c3b8eb41df858975976371276fcd7d84
3
+ size 4294820098
model-00024-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d7de7c2bbf74f9a46a8fdba8d012f40152ed9779fe4cdd8c496316779e58505
3
+ size 4294948636
model-00025-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fec1ccd9af5275b2ca089079005d3be97bb784df2488b468938d3c7e782d7902
3
+ size 4294295437
model-00026-of-00026.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:436d0ea39606b31b4682f8a5160eee7c9cc43effb6850fb20861ecd8042414f2
3
+ size 4006523695
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b6cf7511d91da0459b3938bbcfb376f38b9dc9af93f215f97afbf50818518f2
3
+ size 12053718
processor_config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_rescale": true,
4
+ "patch_expand_factor": 1,
5
+ "merge_size": 2,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_std": [
12
+ 0.26862954,
13
+ 0.26130258,
14
+ 0.27577711
15
+ ],
16
+ "temporal_patch_size": 2,
17
+ "patch_size": 14,
18
+ "min_image_tokens": 16,
19
+ "max_image_tokens": 8000,
20
+ "image_processor_type": "Glm5NextImageProcessor"
21
+ },
22
+ "video_processor": {
23
+ "do_rescale": true,
24
+ "video_processor_type": "Glm5NextVideoProcessor",
25
+ "patch_expand_factor": 1,
26
+ "merge_size": 2,
27
+ "image_mean": [
28
+ 0.48145466,
29
+ 0.4578275,
30
+ 0.40821073
31
+ ],
32
+ "image_std": [
33
+ 0.26862954,
34
+ 0.26130258,
35
+ 0.27577711
36
+ ],
37
+ "temporal_patch_size": 2,
38
+ "patch_size": 14,
39
+ "min_image_tokens": 16,
40
+ "max_image_tokens": 240000,
41
+ "fps": 2
42
+ },
43
+ "processor_class": "Glm5NextProcessor"
44
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19e773648cb4e65de8660ea6365e10acca112d42a854923df93db4a6f333a82d
3
+ size 20217442
tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": false,
4
+ "do_lower_case": false,
5
+ "eos_token": "<|endoftext|>",
6
+ "extra_special_tokens": [
7
+ "<|endoftext|>",
8
+ "[MASK]",
9
+ "[gMASK]",
10
+ "[sMASK]",
11
+ "<sop>",
12
+ "<eop>",
13
+ "<|system|>",
14
+ "<|user|>",
15
+ "<|assistant|>",
16
+ "<|observation|>",
17
+ "<|begin_of_image|>",
18
+ "<|end_of_image|>",
19
+ "<|begin_of_video|>",
20
+ "<|end_of_video|>",
21
+ "<|begin_of_audio|>",
22
+ "<|end_of_audio|>",
23
+ "<|begin_of_transcription|>",
24
+ "<|end_of_transcription|>"
25
+ ],
26
+ "is_local": true,
27
+ "model_max_length": 1048576,
28
+ "model_specific_special_tokens": {},
29
+ "pad_token": "<|endoftext|>",
30
+ "padding_side": "left",
31
+ "remove_space": false,
32
+ "tokenizer_class": "TokenizersBackend"
33
+ }
zai-logo.png ADDED