kos000113 commited on
Commit
1f89cd1
·
verified ·
1 Parent(s): d7a8cfe

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,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: transformers
4
+ ---
5
+ <div align="center">
6
+ <picture>
7
+ <source srcset="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/Xiaomi_MiMo_darkmode.png?raw=true" media="(prefers-color-scheme: dark)">
8
+ <img src="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/Xiaomi_MiMo.png?raw=true" width="60%" alt="Xiaomi-MiMo" />
9
+ </picture>
10
+ </div>
11
+
12
+ <h3 align="center">
13
+ <b>
14
+ <span>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>
15
+ <br/>
16
+ Unlocking the Reasoning Potential of Language Model<br/>From Pretraining to Posttraining
17
+ <br/>
18
+ <span>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>
19
+ <br/>
20
+ </b>
21
+ </h3>
22
+
23
+ <br/>
24
+
25
+ <div align="center" style="line-height: 1;">
26
+ |
27
+ <a href="https://huggingface.co/XiaomiMiMo" target="_blank">🤗 HuggingFace</a>
28
+ &nbsp;|
29
+ <a href="https://www.modelscope.cn/organization/XiaomiMiMo" target="_blank">🤖️ ModelScope</a>
30
+ &nbsp;|
31
+ <a href="https://arxiv.org/abs/2505.07608" target="_blank">📔 Technical Report</a>
32
+ &nbsp;|
33
+ <br/>
34
+ </div>
35
+
36
+ <br/>
37
+
38
+ ---
39
+
40
+ ## Updates
41
+
42
+ [2025.05.30] We scaled the SFT dataset from approximately 500K to 6M instances and continuously expanding the RL training window size from 32K to 48K, the performance of [MiMo-7B-RL-0530](https://huggingface.co/XiaomiMiMo/MiMo-7B-RL-0530) on AIME24 can be continuously improved and eventually surpass that of DeepSeek R1 (79.8).
43
+
44
+ <table>
45
+ <thead>
46
+ <tr>
47
+ <th>Benchmark</th>
48
+ <th>MiMo-7B-RL</th>
49
+ <th>MiMo-7B-RL-0530</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+ <tr>
54
+ <td colspan="3"><strong>Mathematics</strong></td>
55
+ <p align="center">
56
+ <td rowspan="11"><img width="80%" src="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/length.jpg?raw=true"></td>
57
+ </p>
58
+ </tr>
59
+ <tr><td>MATH500<br/>(Pass@1)</td><td>95.8</td><td>97.2</td></tr>
60
+ <tr><td>AIME 2024<br/>(Pass@1)</td><td>68.2</td><td>80.1</td></tr>
61
+ <tr><td>AIME 2025<br/>(Pass@1)</td><td>55.4</td><td>70.2</td></tr>
62
+ <tr><td colspan="3"><strong>Code</strong></td></tr>
63
+ <tr><td>LiveCodeBench v5<br/>(Pass@1)</td><td>57.8</td><td>60.9</td></tr>
64
+ <tr><td>LiveCodeBench v6<br/>(Pass@1)</td><td>49.3</td><td>52.2</td></tr>
65
+ <tr><td colspan="3"><strong>STEM</strong></td></tr>
66
+ <tr><td>GPQA-Diamond<br/>(Pass@1)</td><td>54.4</td><td>60.6</td></tr>
67
+ <tr><td colspan="3"><strong>General</strong></td></tr>
68
+ <tr><td>Alignbench1.1<br/>(Evaluated by GPT4.1)</td><td>6.9</td><td>7.4</td></tr>
69
+ </tbody>
70
+ </table>
71
+
72
+ ---
73
+
74
+ ## I. Introduction
75
+
76
+ Currently, most successful RL works, including open-source research, rely on relatively large base models, e.g., 32B models, particularly for enhancing code reasoning capabilities. Moreover, it was widely considered that achieving uniform and simultaneous improvements in both mathematical and code capabilities within a small model is challenging. Nonetheless, we believe that the effectiveness of the RL trained reasoning model relies on the inherent reasoning potential of the base model. To fully unlock the reasoning potential of language models, efforts must focus not only on post-training but also on pre-training strategies tailored to reasoning.
77
+
78
+ In this work, we present MiMo-7B, a series of models trained from scratch and born for reasoning tasks. Our RL experiments from MiMo-7B-Base show that our model possesses extraordinary reasoning potential, even surpassing much larger 32B models. Additionally, we perform RL training on a cold-started SFT model, resulting in MiMo-7B-RL, which demonstrates superior performance on both mathematics and code reasoning tasks, matching the performance of OpenAI o1-mini.
79
+
80
+ <p align="center">
81
+ <img width="80%" src="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/curve.png?raw=true">
82
+ </p>
83
+
84
+ We open-source MiMo-7B series, including checkpoints of the base model, SFT model, RL model trained from base model, and RL model trained from the SFT model.
85
+ We believe this report along with the models will provide valuable insights to develop powerful reasoning LLMs that benefit the larger community.
86
+
87
+ ### 🌟 Highlights
88
+
89
+ - **Pre-Training: Base Model Born for Reasoning**
90
+ - We optimize the data preprocessing pipeline, enhancing text extraction toolkits and applying multi-dimensional data filtering to increase reasoning pattern density in pre-training data. We also employ multiple strategies to generate massive diverse synthetic reasoning data.
91
+ - We adopt a three-stage data mixture strategy for pre-training. Overall, MiMo-7B-Base is pre-trained on approximately 25 trillion tokens.
92
+ - We incorporate Multiple-Token Prediction as an additional training objective, which enhances model performance and accelerates inference.
93
+
94
+ - **Post-Training Recipe: Pioneering Reasoning Model**
95
+ - We curate 130K mathematics and code problems as RL training data, which can be verified by rule-based verifiers. Each problem undergoes careful cleaning and difficulty assessment to ensure quality. We employ only rule-based accuracy rewards to avoid potential reward hacking.
96
+ - To mitigate the sparse reward issue for challenging code problems, we introduce a test difficulty driven code reward. By assigning fine-grained scores for test cases with varying difficulty levels, the policy can be more effectively optimized via dense reward signal.
97
+ - We implement a data re-sampling strategy for easy problems to enhance rollout sampling efficiency and stabilize policy updates, particularly in the later phases of RL training.
98
+
99
+ - **RL Infrastructure**
100
+ - We develop a Seamless Rollout Engine to accelerate RL training and validation. Our design integrates continuous rollout, asynchronous reward computation, and early termination to minimize GPU idle time, achieving $2.29\times$ faster training and $1.96\times$ faster validation.
101
+ - We support MTP in vLLM and enhance the robustness of the inference engine in the RL system.
102
+
103
+ ## II. Model Details
104
+
105
+ The MTP layers of MiMo-7B is tuned during pretraining and SFT and freezed during RL. With one MTP layer for speculative decoding, the acceptance rate is about 90%.
106
+
107
+ <p align="center">
108
+ <img width="80%" src="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/architecture.png?raw=true">
109
+ </p>
110
+
111
+ > Models are available at [https://huggingface.co/XiaomiMiMo](https://huggingface.co/XiaomiMiMo) and [https://www.modelscope.cn/organization/XiaomiMiMo](https://www.modelscope.cn/organization/XiaomiMiMo)
112
+
113
+ | **Model** | **Description** | **Download (HuggingFace)** | **Download (ModelScope)** |
114
+ | :-------------: | :---------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: |
115
+ | MiMo-7B-Base | Base model with extraordinary reasoning potential | [🤗 XiaomiMiMo/MiMo-7B-Base](https://huggingface.co/XiaomiMiMo/MiMo-7B-Base) | [🤖️ XiaomiMiMo/MiMo-7B-Base](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-7B-Base) |
116
+ | MiMo-7B-RL-Zero | RL model trained from base model | [🤗 XiaomiMiMo/MiMo-7B-RL-Zero](https://huggingface.co/XiaomiMiMo/MiMo-7B-RL-Zero) | [🤖️ XiaomiMiMo/MiMo-7B-RL-Zero](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-7B-RL-Zero) |
117
+ | MiMo-7B-SFT | SFT model trained from base model | [🤗 XiaomiMiMo/MiMo-7B-SFT](https://huggingface.co/XiaomiMiMo/MiMo-7B-SFT) | [🤖️ XiaomiMiMo/MiMo-7B-SFT](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-7B-SFT) |
118
+ | MiMo-7B-RL | RL model trained from SFT model, superior performance matching OpenAI o1-mini | [🤗 XiaomiMiMo/MiMo-7B-RL](https://huggingface.co/XiaomiMiMo/MiMo-7B-RL) | [🤖️ XiaomiMiMo/MiMo-7B-RL](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-7B-RL) |
119
+
120
+ ## III. Evaluation Results
121
+
122
+ | Benchmark | GPT-4o-0513 | Claude-3.5-Sonnet-1022 | OpenAI o1-mini | QwQ-32B-Preview | R1-Distill-Qwen-14B | R1-Distill-Qwen-7B | MiMo-7B-RL |
123
+ | ----------------------------- | :---------: | :--------------------: | :------------: | :-------------: | :-----------------: | :----------------: | :--------: |
124
+ | **General** | | | | | | | |
125
+ | GPQA Diamond<br/>(Pass@1) | 49.9 | 65.0 | 60.0 | 54.5 | 59.1 | 49.1 | 54.4 |
126
+ | SuperGPQA<br/>(Pass@1) | 42.4 | 48.2 | 45.2 | 43.6 | 40.6 | 28.9 | 40.5 |
127
+ | DROP<br/>(3-shot F1) | 83.7 | 88.3 | 83.9 | 71.2 | 85.5 | 77.0 | 78.7 |
128
+ | MMLU-Pro<br/>(EM) | 72.6 | 78.0 | 80.3 | 52.0 | 68.8 | 53.5 | 58.6 |
129
+ | IF-Eval<br/>(Prompt Strict) | 84.3 | 86.5 | 84.8 | 40.4 | 78.3 | 60.5 | 61.0 |
130
+ | **Mathematics** | | | | | | | |
131
+ | MATH-500<br/>(Pass@1) | 74.6 | 78.3 | 90.0 | 90.6 | 93.9 | 92.8 | 95.8 |
132
+ | AIME 2024<br/>(Pass@1) | 9.3 | 16.0 | 63.6 | 50.0 | 69.7 | 55.5 | 68.2 |
133
+ | AIME 2025<br/>(Pass@1) | 11.6 | 7.4 | 50.7 | 32.4 | 48.2 | 38.8 | 55.4 |
134
+ | **Code** | | | | | | | |
135
+ | LiveCodeBench v5<br/>(Pass@1) | 32.9 | 38.9 | 53.8 | 41.9 | 53.1 | 37.6 | 57.8 |
136
+ | LiveCodeBench v6<br/>(Pass@1) | 30.9 | 37.2 | 46.8 | 39.1 | 31.9 | 23.9 | 49.3 |
137
+
138
+ MiMo-7B series
139
+
140
+ | Benchmark | MiMo-7B-Base | MiMo-7B-RL-Zero | MiMo-7B-SFT | MiMo-7B-RL |
141
+ | ----------------------------- | :----------: | :-------------: | :---------: | :--------: |
142
+ | **Mathematics** | | | | |
143
+ | MATH500<br/>(Pass@1) | 37.4 | 93.6 | 93.0 | 95.8 |
144
+ | AIME 2024<br/>(Pass@1) | 32.9 | 56.4 | 58.7 | 68.2 |
145
+ | AIME 2025<br/>(Pass@1) | 24.3 | 46.3 | 44.3 | 55.4 |
146
+ | **Code** | | | | |
147
+ | LiveCodeBench v5<br/>(Pass@1) | 32.9 | 49.1 | 52.3 | 57.8 |
148
+ | LiveCodeBench v6<br/>(Pass@1) | 29.1 | 42.9 | 45.5 | 49.3 |
149
+
150
+ > [!IMPORTANT]
151
+ > The evaluations are conducted with `temperature=0.6`.
152
+ >
153
+ > AIME24 and AIME25 are with averaged score of 32 repetitions. LiveCodeBench v5 (20240801-20250201), LiveCodeBench v6 (20250201-20250501), GPQA-Diamond and IF-Eval are with averaged score of 8 repetitions. MATH500 and SuperGPQA are with a single run.
154
+
155
+ ## IV. Deployment
156
+
157
+ ### SGLang Inference
158
+
159
+ Thanks to the [MiMo model support](https://github.com/sgl-project/sglang/pull/5921) and [MTP](https://github.com/sgl-project/sglang/pull/6059) from the SGLang team, we supported MiMo in SGLang mainstream.
160
+
161
+ Example Script
162
+
163
+ ```bash
164
+ # Install the latest SGlang from main branch
165
+ python3 -m uv pip install "sglang[all] @ git+https://github.com/sgl-project/sglang.git/@main#egg=sglang&subdirectory=python"
166
+
167
+ # Launch SGLang Server
168
+ python3 -m sglang.launch_server --model-path XiaomiMiMo/MiMo-7B-RL --host 0.0.0.0 --trust-remote-code
169
+
170
+ # Launch MTP Server
171
+ python3 -m sglang.launch_server --model-path XiaomiMiMo/MiMo-7B-RL --trust-remote-code \
172
+ --speculative-algorithm EAGLE --speculative-num-steps 1 --speculative-eagle-topk 1 \
173
+ --speculative-num-draft-tokens 2 --mem-fraction 0.5
174
+ ```
175
+
176
+ Detailed usage can be found in [SGLang documents](https://docs.sglang.ai/backend/send_request.html).
177
+
178
+ ### vLLM inference
179
+
180
+ 1. [Recommended] We officially support inference with MiMo-MTP using [our fork of vLLM](https://github.com/XiaomiMiMo/vllm/tree/feat_mimo_mtp_stable_073).
181
+
182
+ Example script
183
+
184
+ ```py
185
+ from vllm import LLM, SamplingParams
186
+
187
+ model_path = "/path/to/MiMo"
188
+ llm = LLM(
189
+ model=model_path,
190
+ trust_remote_code=True,
191
+ num_speculative_tokens=1,
192
+ disable_log_stats=False
193
+ )
194
+ sampling_params = SamplingParams(temperature=0.6)
195
+
196
+ conversation = [
197
+ {
198
+ "role": "system",
199
+ "content": ""
200
+ },
201
+ {
202
+ "role": "user",
203
+ "content": "Write an essay about the importance of higher education.",
204
+ },
205
+ ]
206
+
207
+ outputs = llm.chat(conversation,
208
+ sampling_params=sampling_params,
209
+ use_tqdm=False)
210
+
211
+ for output in outputs:
212
+ prompt = output.prompt
213
+ generated_text = output.outputs[0].text
214
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
215
+
216
+ print("=" * 80)
217
+ ```
218
+
219
+ 2. Or, you can register a vLLM loader for MiMo without loading MTP parameters.
220
+
221
+ You can copy the [`registry/register_mimo_in_vllm.py`](https://github.com/XiaomiMiMo/MiMo/blob/main/registry/register_mimo_in_vllm.py) to your directory and import it with
222
+
223
+ ```py
224
+ import register_mimo_in_vllm
225
+
226
+ from vllm import LLM, SamplingParams
227
+
228
+ model_path = "/path/to/MiMo"
229
+ llm = LLM(
230
+ model=model_path,
231
+ trust_remote_code=True,
232
+ # num_speculative_tokens=1,
233
+ disable_log_stats=False
234
+ )
235
+ sampling_params = SamplingParams(temperature=0.6)
236
+ ```
237
+
238
+ ### HuggingFace inference
239
+
240
+ Example script
241
+
242
+ ```py
243
+ from transformers import AutoModel, AutoModelForCausalLM, AutoTokenizer
244
+
245
+ model_id = "XiaomiMiMo/MiMo-7B-RL"
246
+ model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
247
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
248
+ inputs = tokenizer(["Today is"], return_tensors='pt')
249
+ output = model.generate(**inputs, max_new_tokens = 100)
250
+ print(tokenizer.decode(output.tolist()[0]))
251
+ ```
252
+
253
+ ### Recommended environment and prompts
254
+
255
+ - We recommend using [our fork of vLLM](https://github.com/XiaomiMiMo/vllm/tree/feat_mimo_mtp_stable_073) which is developed based on vLLM 0.7.3.
256
+ - We recommend using empty system prompt.
257
+
258
+ > We haven't verified MiMo with other inference engines and welcome contributions based on the model definition in the Huggingface repo 💻.
259
+
260
+ ## V. Citation
261
+
262
+ ```bibtex
263
+ @misc{coreteam2025mimounlockingreasoningpotential,
264
+ title={MiMo: Unlocking the Reasoning Potential of Language Model -- From Pretraining to Posttraining},
265
+ author={LLM-Core-Team Xiaomi},
266
+ year={2025},
267
+ eprint={2505.07608},
268
+ archivePrefix={arXiv},
269
+ primaryClass={cs.CL},
270
+ url={https://arxiv.org/abs/2505.07608},
271
+ }
272
+ ```
273
+
274
+
275
+ ## VI. Contact
276
+
277
+ Please contact us at [mimo@xiaomi.com](mailto:mimo@xiaomi.com) or open an issue if you have any questions.
added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MiMoForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_mimo.MiMoConfig",
9
+ "AutoModel": "modeling_mimo.MiMoModel",
10
+ "AutoModelForCausalLM": "modeling_mimo.MiMoForCausalLM"
11
+ },
12
+ "bos_token_id": 151643,
13
+ "dtype": "float16",
14
+ "eos_token_id": 151645,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 4096,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 11008,
20
+ "layer_types": [
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention",
51
+ "full_attention",
52
+ "full_attention",
53
+ "full_attention",
54
+ "full_attention",
55
+ "full_attention",
56
+ "full_attention"
57
+ ],
58
+ "max_position_embeddings": 32768,
59
+ "max_window_layers": 36,
60
+ "model_type": "mimo",
61
+ "num_attention_heads": 32,
62
+ "num_hidden_layers": 36,
63
+ "num_key_value_heads": 8,
64
+ "num_nextn_predict_layers": 1,
65
+ "quantization_config": {
66
+ "_load_in_4bit": true,
67
+ "_load_in_8bit": false,
68
+ "bnb_4bit_compute_dtype": "float16",
69
+ "bnb_4bit_quant_storage": "uint8",
70
+ "bnb_4bit_quant_type": "nf4",
71
+ "bnb_4bit_use_double_quant": true,
72
+ "llm_int8_enable_fp32_cpu_offload": true,
73
+ "llm_int8_has_fp16_weight": false,
74
+ "llm_int8_skip_modules": null,
75
+ "llm_int8_threshold": 6.0,
76
+ "load_in_4bit": true,
77
+ "load_in_8bit": false,
78
+ "quant_method": "bitsandbytes"
79
+ },
80
+ "rms_norm_eps": 1e-05,
81
+ "rope_scaling": null,
82
+ "rope_theta": 640000,
83
+ "sliding_window": null,
84
+ "tie_word_embeddings": false,
85
+ "tokenizer_class": [
86
+ "Qwen2Tokenizer"
87
+ ],
88
+ "transformers_version": "4.57.3",
89
+ "use_cache": true,
90
+ "use_mrope": false,
91
+ "use_sliding_window": false,
92
+ "vocab_size": 151680
93
+ }
configuration_mimo.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.models.qwen2.configuration_qwen2 import Qwen2Config
2
+
3
+ class MiMoConfig(Qwen2Config):
4
+ model_type = "mimo"
5
+
6
+ def __init__(
7
+ self,
8
+ *args,
9
+ num_nextn_predict_layers=0,
10
+ **kwargs
11
+ ):
12
+ self.num_nextn_predict_layers = num_nextn_predict_layers
13
+ super().__init__(
14
+ *args,
15
+ **kwargs,
16
+ )
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "eos_token_id": 151645,
4
+ "max_new_tokens": 2048,
5
+ "transformers_version": "4.57.3"
6
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3884234c8d75998f39a34ba58ac7f23467abbda5f7fd1f72dbd6409fd67ae1e
3
+ size 4643924123
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:944b02fba1b1114512ed4364dce16b13dee2244b0b3419d1fd1c0cd14b678e47
3
+ size 1242562688
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
modeling_mimo.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+
3
+ import torch
4
+ from torch import nn
5
+ from transformers.cache_utils import Cache
6
+ from transformers.models.qwen2.modeling_qwen2 import (Qwen2Attention,
7
+ Qwen2ForCausalLM,
8
+ Qwen2MLP, Qwen2Model,
9
+ Qwen2RMSNorm)
10
+
11
+ from .configuration_mimo import MiMoConfig
12
+
13
+
14
+ class MiMoMTPLayers(nn.Module):
15
+ def __init__(self, config):
16
+ super().__init__()
17
+ self.input_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
18
+ self.post_attention_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
19
+ self.token_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
20
+ self.hidden_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
21
+ self.input_proj = nn.Linear(config.hidden_size * 2, config.hidden_size, bias=False)
22
+ self.final_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
23
+ self.self_attn = Qwen2Attention(config, layer_idx=0)
24
+ self.mlp = Qwen2MLP(config)
25
+
26
+ def forward(self, input_embeds,
27
+ hidden_states,
28
+ attention_mask,
29
+ position_ids,
30
+ past_key_values: Optional[Cache]=None,
31
+ output_attentions: Optional[bool]=False,
32
+ use_cache: Optional[bool]=False,
33
+ position_embedding: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
34
+ cache_position=None,
35
+ **kwargs):
36
+ input_embeds = self.token_layernorm(input_embeds)
37
+ previous_hidden_states = self.hidden_layernorm(hidden_states)
38
+ hidden_states = self.input_proj(torch.cat([previous_hidden_states, input_embeds], dim=-1))
39
+ residual = hidden_states
40
+ hidden_states = self.input_layernorm(hidden_states)
41
+ hidden_states, _ = self.self_attn(hidden_states,
42
+ attention_mask=attention_mask,
43
+ position_ids=position_ids,
44
+ past_key_values=past_key_values,
45
+ output_attentions=output_attentions,
46
+ use_cache=use_cache,
47
+ cache_position=cache_position,
48
+ position_embedding=position_embedding,
49
+ **kwargs)
50
+ hidden_states = residual + hidden_states
51
+ residual = hidden_states
52
+ hidden_states = self.post_attention_layernorm(hidden_states)
53
+ hidden_states = self.mlp(hidden_states)
54
+ hidden_states = residual + hidden_states
55
+ hidden_states = self.final_layernorm(hidden_states)
56
+ return hidden_states
57
+
58
+
59
+ class MiMoModel(Qwen2Model):
60
+ config_class = MiMoConfig
61
+
62
+ def __init__(self, config: MiMoConfig):
63
+ super().__init__(config)
64
+ self.mtp_layers = nn.ModuleList([MiMoMTPLayers(config) for _ in range(config.num_nextn_predict_layers)])
65
+
66
+
67
+ class MiMoForCausalLM(Qwen2ForCausalLM):
68
+ config_class = MiMoConfig
69
+ def __init__(self, config: MiMoConfig):
70
+ super(Qwen2ForCausalLM, self).__init__(config)
71
+ self.model = MiMoModel(config)
72
+ self.vocab_size = config.vocab_size
73
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
74
+
75
+ self.post_init()
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
3
+ size 11421896
tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|im_end|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff