yujiepan commited on
Commit
e16779f
·
verified ·
1 Parent(s): 81fbd34

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
README.md ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ base_model:
4
+ - Qwen/Qwen3.5-397B-A17B
5
+ ---
6
+
7
+ This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from [Qwen/Qwen3.5-397B-A17B](https://huggingface.co/Qwen/Qwen3.5-397B-A17B).
8
+
9
+ | File path | Size |
10
+ |------|------|
11
+ | model.safetensors | 9.6MB |
12
+
13
+
14
+ ### Example usage:
15
+
16
+ - vLLM
17
+
18
+ ```bash
19
+ # Multi-token prediction is supported
20
+ model_id=tiny-random/qwen3.5-moe
21
+ vllm serve $model_id \
22
+ --tensor-parallel-size 2 \
23
+ --speculative-config.method qwen3_next_mtp \
24
+ --speculative-config.num_speculative_tokens 2 \
25
+ --reasoning-parser qwen3 \
26
+ --tool-call-parser qwen3_coder \
27
+ --enable-auto-tool-choice \
28
+ --max-cudagraph-capture-size 16
29
+ ```
30
+
31
+ - SGLang
32
+
33
+ ```bash
34
+ # Multi-token prediction is supported
35
+ model_id=tiny-random/qwen3.5-moe
36
+ python3 -m sglang.launch_server --model-path $model_id --tp-size 2 \
37
+ --tool-call-parser qwen3_coder \
38
+ --reasoning-parser qwen3 \
39
+ --speculative-algo NEXTN \
40
+ --speculative-num-steps 3 \
41
+ --speculative-eagle-topk 1 \
42
+ --speculative-num-draft-tokens 4
43
+ ```
44
+
45
+ - Transformers
46
+
47
+ ```python
48
+ import numpy as np
49
+ import torch
50
+ import transformers
51
+ from PIL import Image
52
+ from transformers import (
53
+ AutoModel,
54
+ AutoModelForCausalLM,
55
+ AutoProcessor,
56
+ AutoTokenizer,
57
+ Qwen3_5MoeForConditionalGeneration,
58
+ )
59
+
60
+ model_id = "tiny-random/qwen3.5-moe"
61
+ model = Qwen3_5MoeForConditionalGeneration.from_pretrained(
62
+ model_id, dtype=torch.bfloat16, device_map="cuda",
63
+ )
64
+ processor = AutoProcessor.from_pretrained(model_id)
65
+ messages = [
66
+ {
67
+ "role": "user",
68
+ "content": [
69
+ {
70
+ "type": "image",
71
+ "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
72
+ },
73
+ {"type": "text", "text": "Describe this image."},
74
+ ],
75
+ }
76
+ ]
77
+
78
+ inputs = processor.apply_chat_template(
79
+ messages,
80
+ tokenize=True,
81
+ add_generation_prompt=True,
82
+ return_dict=True,
83
+ return_tensors="pt"
84
+ ).to(model.device)
85
+
86
+ generated_ids = model.generate(**inputs, max_new_tokens=32)
87
+ output_text = processor.batch_decode(generated_ids[0])
88
+ print(output_text)
89
+ ```
90
+
91
+ ### Codes to create this repo:
92
+
93
+ <details>
94
+ <summary>Click to expand</summary>
95
+
96
+ ```python
97
+ import json
98
+ from copy import deepcopy
99
+ from pathlib import Path
100
+
101
+ import torch
102
+ from huggingface_hub import file_exists, hf_hub_download
103
+ from transformers import (
104
+ AutoConfig,
105
+ AutoModelForCausalLM,
106
+ AutoProcessor,
107
+ GenerationConfig,
108
+ Qwen3_5MoeForConditionalGeneration,
109
+ set_seed,
110
+ )
111
+
112
+ source_model_id = "Qwen/Qwen3.5-397B-A17B"
113
+ save_folder = "/tmp/tiny-random/qwen35-moe"
114
+
115
+ processor = AutoProcessor.from_pretrained(source_model_id, trust_remote_code=True)
116
+ processor.save_pretrained(save_folder)
117
+
118
+ with open(hf_hub_download(source_model_id, filename='config.json', repo_type='model'), 'r', encoding='utf-8') as f:
119
+ config_json = json.load(f)
120
+
121
+ config_json['text_config'].update({
122
+ 'head_dim': 32,
123
+ 'hidden_size': 8,
124
+ "layer_types": ['linear_attention'] * 3 + ['full_attention'],
125
+ 'intermediate_size': 32,
126
+ 'moe_intermediate_size': 32,
127
+ 'num_hidden_layers': 4,
128
+ 'num_attention_heads': 8,
129
+ 'num_key_value_heads': 4,
130
+ 'num_experts': 128,
131
+ # "num_experts_per_tok": 10,
132
+ 'shared_expert_intermediate_size': 32,
133
+ "linear_key_head_dim": 32,
134
+ "linear_num_key_heads": 4,
135
+ "linear_num_value_heads": 8,
136
+ "linear_value_head_dim": 32,
137
+ })
138
+ config_json['text_config']['rope_parameters']['mrope_section'] = [1, 1, 2]
139
+ config_json["tie_word_embeddings"] = False
140
+ config_json['vision_config'].update(
141
+ {
142
+ 'hidden_size': 64,
143
+ 'intermediate_size': 128,
144
+ 'num_heads': 2,
145
+ 'out_hidden_size': 8,
146
+ 'depth': 2,
147
+ }
148
+ )
149
+ with open(f"{save_folder}/config.json", "w", encoding='utf-8') as f:
150
+ json.dump(config_json, f, indent=2)
151
+
152
+ config = AutoConfig.from_pretrained(
153
+ save_folder,
154
+ trust_remote_code=True,
155
+ )
156
+ print(config)
157
+ torch.set_default_dtype(torch.bfloat16)
158
+ model = Qwen3_5MoeForConditionalGeneration(config)
159
+ model.mtp = torch.nn.ModuleDict({
160
+ "pre_fc_norm_embedding": torch.nn.RMSNorm(config.text_config.hidden_size),
161
+ "fc": torch.nn.Linear(config.text_config.hidden_size * 2, config.text_config.hidden_size, bias=False),
162
+ "layers": torch.nn.ModuleList([deepcopy(model.model.language_model.layers[3])]),
163
+ "norm": torch.nn.RMSNorm(config.text_config.hidden_size),
164
+ "pre_fc_norm_hidden": torch.nn.RMSNorm(config.text_config.hidden_size),
165
+ })
166
+ torch.set_default_dtype(torch.float32)
167
+ if file_exists(filename="generation_config.json", repo_id=source_model_id, repo_type='model'):
168
+ model.generation_config = GenerationConfig.from_pretrained(
169
+ source_model_id, trust_remote_code=True,
170
+ )
171
+ model.generation_config.do_sample = True
172
+ print(model.generation_config)
173
+ model = model.cpu()
174
+ with torch.no_grad():
175
+ for name, p in sorted(model.named_parameters()):
176
+ torch.nn.init.normal_(p, 0, 0.1)
177
+ print(name, p.shape)
178
+ model.save_pretrained(save_folder)
179
+ ```
180
+
181
+ </details>
182
+
183
+ ### Printing the model:
184
+
185
+ <details><summary>Click to expand</summary>
186
+
187
+ ```text
188
+ Qwen3_5MoeForConditionalGeneration(
189
+ (model): Qwen3_5MoeModel(
190
+ (visual): Qwen3_5MoeVisionModel(
191
+ (patch_embed): Qwen3_5MoeVisionPatchEmbed(
192
+ (proj): Conv3d(3, 64, kernel_size=(2, 16, 16), stride=(2, 16, 16))
193
+ )
194
+ (pos_embed): Embedding(2304, 64)
195
+ (rotary_pos_emb): Qwen3_5MoeVisionRotaryEmbedding()
196
+ (blocks): ModuleList(
197
+ (0-1): 2 x Qwen3_5MoeVisionBlock(
198
+ (norm1): LayerNorm((64,), eps=1e-06, elementwise_affine=True)
199
+ (norm2): LayerNorm((64,), eps=1e-06, elementwise_affine=True)
200
+ (attn): Qwen3_5MoeVisionAttention(
201
+ (qkv): Linear(in_features=64, out_features=192, bias=True)
202
+ (proj): Linear(in_features=64, out_features=64, bias=True)
203
+ )
204
+ (mlp): Qwen3_5MoeVisionMLP(
205
+ (linear_fc1): Linear(in_features=64, out_features=128, bias=True)
206
+ (linear_fc2): Linear(in_features=128, out_features=64, bias=True)
207
+ (act_fn): GELUTanh()
208
+ )
209
+ )
210
+ )
211
+ (merger): Qwen3_5MoeVisionPatchMerger(
212
+ (norm): LayerNorm((64,), eps=1e-06, elementwise_affine=True)
213
+ (linear_fc1): Linear(in_features=256, out_features=256, bias=True)
214
+ (act_fn): GELU(approximate='none')
215
+ (linear_fc2): Linear(in_features=256, out_features=8, bias=True)
216
+ )
217
+ )
218
+ (language_model): Qwen3_5MoeTextModel(
219
+ (embed_tokens): Embedding(248320, 8)
220
+ (layers): ModuleList(
221
+ (0-2): 3 x Qwen3_5MoeDecoderLayer(
222
+ (linear_attn): Qwen3_5MoeGatedDeltaNet(
223
+ (act): SiLUActivation()
224
+ (conv1d): Conv1d(512, 512, kernel_size=(4,), stride=(1,), padding=(3,), groups=512, bias=False)
225
+ (norm): FusedRMSNormGated(32, eps=1e-06, activation=silu)
226
+ (out_proj): Linear(in_features=256, out_features=8, bias=False)
227
+ (in_proj_qkv): Linear(in_features=8, out_features=512, bias=False)
228
+ (in_proj_z): Linear(in_features=8, out_features=256, bias=False)
229
+ (in_proj_b): Linear(in_features=8, out_features=8, bias=False)
230
+ (in_proj_a): Linear(in_features=8, out_features=8, bias=False)
231
+ )
232
+ (mlp): Qwen3_5MoeSparseMoeBlock(
233
+ (gate): Qwen3_5MoeTopKRouter()
234
+ (experts): Qwen3_5MoeExperts(
235
+ (act_fn): SiLUActivation()
236
+ )
237
+ (shared_expert): Qwen3_5MoeMLP(
238
+ (gate_proj): Linear(in_features=8, out_features=32, bias=False)
239
+ (up_proj): Linear(in_features=8, out_features=32, bias=False)
240
+ (down_proj): Linear(in_features=32, out_features=8, bias=False)
241
+ (act_fn): SiLUActivation()
242
+ )
243
+ (shared_expert_gate): Linear(in_features=8, out_features=1, bias=False)
244
+ )
245
+ (input_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
246
+ (post_attention_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
247
+ )
248
+ (3): Qwen3_5MoeDecoderLayer(
249
+ (self_attn): Qwen3_5MoeAttention(
250
+ (q_proj): Linear(in_features=8, out_features=512, bias=False)
251
+ (k_proj): Linear(in_features=8, out_features=128, bias=False)
252
+ (v_proj): Linear(in_features=8, out_features=128, bias=False)
253
+ (o_proj): Linear(in_features=256, out_features=8, bias=False)
254
+ (q_norm): Qwen3_5MoeRMSNorm((32,), eps=1e-06)
255
+ (k_norm): Qwen3_5MoeRMSNorm((32,), eps=1e-06)
256
+ )
257
+ (mlp): Qwen3_5MoeSparseMoeBlock(
258
+ (gate): Qwen3_5MoeTopKRouter()
259
+ (experts): Qwen3_5MoeExperts(
260
+ (act_fn): SiLUActivation()
261
+ )
262
+ (shared_expert): Qwen3_5MoeMLP(
263
+ (gate_proj): Linear(in_features=8, out_features=32, bias=False)
264
+ (up_proj): Linear(in_features=8, out_features=32, bias=False)
265
+ (down_proj): Linear(in_features=32, out_features=8, bias=False)
266
+ (act_fn): SiLUActivation()
267
+ )
268
+ (shared_expert_gate): Linear(in_features=8, out_features=1, bias=False)
269
+ )
270
+ (input_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
271
+ (post_attention_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
272
+ )
273
+ )
274
+ (norm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
275
+ (rotary_emb): Qwen3_5MoeTextRotaryEmbedding()
276
+ )
277
+ )
278
+ (lm_head): Linear(in_features=8, out_features=248320, bias=False)
279
+ (mtp): ModuleDict(
280
+ (pre_fc_norm_embedding): RMSNorm((8,), eps=None, elementwise_affine=True)
281
+ (fc): Linear(in_features=16, out_features=8, bias=False)
282
+ (layers): ModuleList(
283
+ (0): Qwen3_5MoeDecoderLayer(
284
+ (self_attn): Qwen3_5MoeAttention(
285
+ (q_proj): Linear(in_features=8, out_features=512, bias=False)
286
+ (k_proj): Linear(in_features=8, out_features=128, bias=False)
287
+ (v_proj): Linear(in_features=8, out_features=128, bias=False)
288
+ (o_proj): Linear(in_features=256, out_features=8, bias=False)
289
+ (q_norm): Qwen3_5MoeRMSNorm((32,), eps=1e-06)
290
+ (k_norm): Qwen3_5MoeRMSNorm((32,), eps=1e-06)
291
+ )
292
+ (mlp): Qwen3_5MoeSparseMoeBlock(
293
+ (gate): Qwen3_5MoeTopKRouter()
294
+ (experts): Qwen3_5MoeExperts(
295
+ (act_fn): SiLUActivation()
296
+ )
297
+ (shared_expert): Qwen3_5MoeMLP(
298
+ (gate_proj): Linear(in_features=8, out_features=32, bias=False)
299
+ (up_proj): Linear(in_features=8, out_features=32, bias=False)
300
+ (down_proj): Linear(in_features=32, out_features=8, bias=False)
301
+ (act_fn): SiLUActivation()
302
+ )
303
+ (shared_expert_gate): Linear(in_features=8, out_features=1, bias=False)
304
+ )
305
+ (input_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
306
+ (post_attention_layernorm): Qwen3_5MoeRMSNorm((8,), eps=1e-06)
307
+ )
308
+ )
309
+ (norm): RMSNorm((8,), eps=None, elementwise_affine=True)
310
+ (pre_fc_norm_hidden): RMSNorm((8,), eps=None, elementwise_affine=True)
311
+ )
312
+ )
313
+ ```
314
+
315
+ </details>
chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is false %}
150
+ {{- '<think>\n\n</think>\n\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5MoeForConditionalGeneration"
4
+ ],
5
+ "dtype": "bfloat16",
6
+ "image_token_id": 248056,
7
+ "model_type": "qwen3_5_moe",
8
+ "text_config": {
9
+ "attention_bias": false,
10
+ "attention_dropout": 0.0,
11
+ "attn_output_gate": true,
12
+ "bos_token_id": null,
13
+ "dtype": "bfloat16",
14
+ "eos_token_id": 248044,
15
+ "full_attention_interval": 4,
16
+ "head_dim": 32,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 8,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 32,
21
+ "layer_types": [
22
+ "linear_attention",
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "full_attention"
26
+ ],
27
+ "linear_conv_kernel_dim": 4,
28
+ "linear_key_head_dim": 32,
29
+ "linear_num_key_heads": 4,
30
+ "linear_num_value_heads": 8,
31
+ "linear_value_head_dim": 32,
32
+ "mamba_ssm_dtype": "float32",
33
+ "max_position_embeddings": 262144,
34
+ "mlp_only_layers": [],
35
+ "model_type": "qwen3_5_moe_text",
36
+ "moe_intermediate_size": 32,
37
+ "mtp_num_hidden_layers": 1,
38
+ "mtp_use_dedicated_embeddings": false,
39
+ "num_attention_heads": 8,
40
+ "num_experts": 128,
41
+ "num_experts_per_tok": 10,
42
+ "num_hidden_layers": 4,
43
+ "num_key_value_heads": 4,
44
+ "output_router_logits": false,
45
+ "pad_token_id": null,
46
+ "partial_rotary_factor": 0.25,
47
+ "rms_norm_eps": 1e-06,
48
+ "rope_parameters": {
49
+ "mrope_interleaved": true,
50
+ "mrope_section": [
51
+ 1,
52
+ 1,
53
+ 2
54
+ ],
55
+ "partial_rotary_factor": 0.25,
56
+ "rope_theta": 10000000,
57
+ "rope_type": "default"
58
+ },
59
+ "router_aux_loss_coef": 0.001,
60
+ "shared_expert_intermediate_size": 32,
61
+ "tie_word_embeddings": false,
62
+ "use_cache": true,
63
+ "vocab_size": 248320
64
+ },
65
+ "tie_word_embeddings": false,
66
+ "transformers_version": "5.2.0.dev0",
67
+ "video_token_id": 248057,
68
+ "vision_config": {
69
+ "deepstack_visual_indexes": [],
70
+ "depth": 2,
71
+ "hidden_act": "gelu_pytorch_tanh",
72
+ "hidden_size": 64,
73
+ "in_channels": 3,
74
+ "initializer_range": 0.02,
75
+ "intermediate_size": 128,
76
+ "model_type": "qwen3_5_moe",
77
+ "num_heads": 2,
78
+ "num_position_embeddings": 2304,
79
+ "out_hidden_size": 8,
80
+ "patch_size": 16,
81
+ "spatial_merge_size": 2,
82
+ "temporal_patch_size": 2
83
+ },
84
+ "vision_end_token_id": 248054,
85
+ "vision_start_token_id": 248053
86
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 248046,
6
+ 248044
7
+ ],
8
+ "pad_token_id": 248044,
9
+ "temperature": 0.6,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.2.0.dev0",
13
+ "trust_remote_code": true
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0aac8f1e5ef91b3c9c68c394611de2333b4e76fd229ef13864793d5826fa024c
3
+ size 10057952
processor_config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "data_format": "channels_first",
4
+ "do_convert_rgb": true,
5
+ "do_normalize": true,
6
+ "do_rescale": true,
7
+ "do_resize": true,
8
+ "image_mean": [
9
+ 0.5,
10
+ 0.5,
11
+ 0.5
12
+ ],
13
+ "image_processor_type": "Qwen2VLImageProcessorFast",
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "merge_size": 2,
20
+ "patch_size": 16,
21
+ "resample": 3,
22
+ "rescale_factor": 0.00392156862745098,
23
+ "size": {
24
+ "longest_edge": 16777216,
25
+ "shortest_edge": 65536
26
+ },
27
+ "temporal_patch_size": 2
28
+ },
29
+ "processor_class": "Qwen3VLProcessor",
30
+ "video_processor": {
31
+ "data_format": "channels_first",
32
+ "default_to_square": true,
33
+ "do_convert_rgb": true,
34
+ "do_normalize": true,
35
+ "do_rescale": true,
36
+ "do_resize": true,
37
+ "do_sample_frames": true,
38
+ "fps": 2,
39
+ "image_mean": [
40
+ 0.5,
41
+ 0.5,
42
+ 0.5
43
+ ],
44
+ "image_std": [
45
+ 0.5,
46
+ 0.5,
47
+ 0.5
48
+ ],
49
+ "max_frames": 768,
50
+ "merge_size": 2,
51
+ "min_frames": 4,
52
+ "patch_size": 16,
53
+ "resample": 3,
54
+ "rescale_factor": 0.00392156862745098,
55
+ "return_metadata": false,
56
+ "size": {
57
+ "longest_edge": 25165824,
58
+ "shortest_edge": 4096
59
+ },
60
+ "temporal_patch_size": 2,
61
+ "video_processor_type": "Qwen3VLVideoProcessor"
62
+ }
63
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
3
+ size 19989343
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": false,
13
+ "model_max_length": 262144,
14
+ "model_specific_special_tokens": {
15
+ "audio_bos_token": "<|audio_start|>",
16
+ "audio_eos_token": "<|audio_end|>",
17
+ "audio_token": "<|audio_pad|>",
18
+ "image_token": "<|image_pad|>",
19
+ "video_token": "<|video_pad|>",
20
+ "vision_bos_token": "<|vision_start|>",
21
+ "vision_eos_token": "<|vision_end|>"
22
+ },
23
+ "pad_token": "<|endoftext|>",
24
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
25
+ "processor_class": "Qwen3VLProcessor",
26
+ "split_special_tokens": false,
27
+ "tokenizer_class": "TokenizersBackend",
28
+ "unk_token": null,
29
+ "video_token": "<|video_pad|>",
30
+ "vision_bos_token": "<|vision_start|>",
31
+ "vision_eos_token": "<|vision_end|>"
32
+ }