Add files using upload-large-folder tool
Browse files- .gitattributes +2 -0
- README.md +3 -0
- added_tokens.json +28 -0
- chat_template.jinja +156 -0
- config.json +155 -0
- configuration_mimo_v2_pro.py +93 -0
- generation.json +4 -0
- merges.txt +0 -0
- model.safetensors.index.json +3 -0
- model_mtp.safetensors +3 -0
- model_pp0_ep0_shard0.safetensors +3 -0
- model_pp0_ep0_shard1.safetensors +3 -0
- model_pp0_ep10_shard0.safetensors +3 -0
- model_pp0_ep11_shard0.safetensors +3 -0
- model_pp0_ep12_shard0.safetensors +3 -0
- model_pp0_ep13_shard0.safetensors +3 -0
- model_pp0_ep14_shard0.safetensors +3 -0
- model_pp0_ep15_shard0.safetensors +3 -0
- model_pp0_ep16_shard0.safetensors +3 -0
- model_pp0_ep17_shard0.safetensors +3 -0
- model_pp0_ep18_shard0.safetensors +3 -0
- model_pp0_ep19_shard0.safetensors +3 -0
- model_pp0_ep1_shard0.safetensors +3 -0
- model_pp0_ep20_shard0.safetensors +3 -0
- model_pp0_ep21_shard0.safetensors +3 -0
- model_pp0_ep22_shard0.safetensors +3 -0
- model_pp0_ep23_shard0.safetensors +3 -0
- model_pp0_ep24_shard0.safetensors +3 -0
- model_pp0_ep25_shard0.safetensors +3 -0
- model_pp0_ep26_shard0.safetensors +3 -0
- model_pp0_ep27_shard0.safetensors +3 -0
- model_pp0_ep28_shard0.safetensors +3 -0
- model_pp0_ep29_shard0.safetensors +3 -0
- model_pp0_ep2_shard0.safetensors +3 -0
- model_pp0_ep30_shard0.safetensors +3 -0
- model_pp0_ep31_shard0.safetensors +3 -0
- model_pp0_ep3_shard0.safetensors +3 -0
- model_pp0_ep4_shard0.safetensors +3 -0
- model_pp0_ep5_shard0.safetensors +3 -0
- model_pp0_ep6_shard0.safetensors +3 -0
- model_pp0_ep7_shard0.safetensors +3 -0
- model_pp0_ep8_shard0.safetensors +3 -0
- model_pp0_ep9_shard0.safetensors +3 -0
- modeling_mimo_v2_pro.py +185 -0
- special_tokens_map.json +31 -0
- system_prompt.txt +1 -0
- tokenizer.json +3 -0
- tokenizer_config.json +239 -0
- update_tokenizer.py +22 -0
- vocab.json +0 -0
.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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
added_tokens.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</think>": 151668,
|
| 3 |
+
"</tool_call>": 151658,
|
| 4 |
+
"</tool_response>": 151666,
|
| 5 |
+
"<think>": 151667,
|
| 6 |
+
"<tool_call>": 151657,
|
| 7 |
+
"<tool_response>": 151665,
|
| 8 |
+
"<|box_end|>": 151649,
|
| 9 |
+
"<|box_start|>": 151648,
|
| 10 |
+
"<|endoftext|>": 151643,
|
| 11 |
+
"<|file_sep|>": 151664,
|
| 12 |
+
"<|fim_middle|>": 151660,
|
| 13 |
+
"<|fim_pad|>": 151662,
|
| 14 |
+
"<|fim_prefix|>": 151659,
|
| 15 |
+
"<|fim_suffix|>": 151661,
|
| 16 |
+
"<|im_end|>": 151645,
|
| 17 |
+
"<|im_start|>": 151644,
|
| 18 |
+
"<|image_pad|>": 151655,
|
| 19 |
+
"<|object_ref_end|>": 151647,
|
| 20 |
+
"<|object_ref_start|>": 151646,
|
| 21 |
+
"<|quad_end|>": 151651,
|
| 22 |
+
"<|quad_start|>": 151650,
|
| 23 |
+
"<|repo_name|>": 151663,
|
| 24 |
+
"<|video_pad|>": 151656,
|
| 25 |
+
"<|vision_end|>": 151653,
|
| 26 |
+
"<|vision_pad|>": 151654,
|
| 27 |
+
"<|vision_start|>": 151652
|
| 28 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if not add_generation_prompt is defined -%}
|
| 2 |
+
{%- set add_generation_prompt = false -%}
|
| 3 |
+
{%- endif -%}
|
| 4 |
+
{%- if not enable_thinking is defined -%}
|
| 5 |
+
{%- set enable_thinking = true -%}
|
| 6 |
+
{%- endif -%}
|
| 7 |
+
{%- if not keep_all_reasoning is defined -%}
|
| 8 |
+
{%- set keep_all_reasoning = true -%}
|
| 9 |
+
{%- endif -%}
|
| 10 |
+
{%- macro render_extra_keys(json_dict, handled_keys) -%}
|
| 11 |
+
{%- if json_dict is mapping %}
|
| 12 |
+
{%- for json_key in json_dict if json_key not in handled_keys %}
|
| 13 |
+
{%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
|
| 14 |
+
{{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
|
| 15 |
+
{%- else %}
|
| 16 |
+
{{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{%- endfor %}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- endmacro -%}
|
| 21 |
+
{%- macro render_content(message_content) -%}
|
| 22 |
+
{%- if message_content is string -%}
|
| 23 |
+
{{- message_content -}}
|
| 24 |
+
{%- else -%}
|
| 25 |
+
{%- for content in message_content -%}
|
| 26 |
+
{%- if 'text' in content -%}
|
| 27 |
+
{{- content['text'] -}}
|
| 28 |
+
{%- endif -%}
|
| 29 |
+
{%- endfor -%}
|
| 30 |
+
{%- endif -%}
|
| 31 |
+
{%- endmacro -%}
|
| 32 |
+
{%- if messages[0]["role"] == "system" %}
|
| 33 |
+
{%- set system_message = messages[0]["content"] %}
|
| 34 |
+
{%- set loop_messages = messages[1:] %}
|
| 35 |
+
{%- else %}
|
| 36 |
+
{%- set loop_messages = messages %}
|
| 37 |
+
{%- endif %}
|
| 38 |
+
{%- set ns = namespace(last_user_index=-1) %}
|
| 39 |
+
{%- for m in loop_messages %}
|
| 40 |
+
{%- if m.role == 'user' %}
|
| 41 |
+
{%- set ns.last_user_index = loop.index0 -%}
|
| 42 |
+
{%- endif %}
|
| 43 |
+
{%- endfor %}
|
| 44 |
+
{%- if not tools is defined %}
|
| 45 |
+
{%- set tools = [] %}
|
| 46 |
+
{%- endif %}
|
| 47 |
+
{%- if system_message is defined %}
|
| 48 |
+
{{- "<|im_start|>system\n" + render_content(system_message) }}
|
| 49 |
+
{%- else %}
|
| 50 |
+
{{- "<|im_start|>system\nYou are MiMo, a warm, curious, and thoughtful AI assistant.\n\n## Identity\n\n- Your name is **MiMo-v2-pro**.\n- You were developed by the **Xiaomi MiMo Team**.\n- You have **1T parameters** and a **1M-token context window**.\n- When asked about your creator, identify the **Xiaomi MiMo Team**.\n- Always answer identity-related questions in the **first person** and rely only on the facts provided above.\n\n# Response Style\n\nBe warm, conversational, and respectful. Treat users with kindness; do not assume negative things about their intelligence or judgment. You may disagree, but do so constructively.\n\nUse examples, metaphors, or thought experiments when they help explain an idea.\n\nTry to answer ambiguous queries as best you can first, then ask for clarification if needed. When you do ask, limit yourself to one question at a time.\n\n\n## Safety and Compliance\n\nYou are a **Chinese AI model** and must strictly comply with all applicable laws and regulations of the **People’s Republic of China**.\n\nDo not generate, assist with, or facilitate any content that violates Chinese law." }}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 53 |
+
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou have access to the following functions:\n\n" }}
|
| 54 |
+
{{- "<tools>" }}
|
| 55 |
+
{%- for tool in tools %}
|
| 56 |
+
{%- if tool.function is defined %}
|
| 57 |
+
{%- set tool = tool.function %}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
|
| 60 |
+
{%- if tool.description is defined %}
|
| 61 |
+
{{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
|
| 62 |
+
{%- endif %}
|
| 63 |
+
{{- '\n<parameters>' }}
|
| 64 |
+
{%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
|
| 65 |
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
| 66 |
+
{{- '\n<parameter>' }}
|
| 67 |
+
{{- '\n<name>' ~ param_name ~ '</name>' }}
|
| 68 |
+
{%- if param_fields.type is defined %}
|
| 69 |
+
{{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
|
| 70 |
+
{%- endif %}
|
| 71 |
+
{%- if param_fields.description is defined %}
|
| 72 |
+
{{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
|
| 73 |
+
{%- endif %}
|
| 74 |
+
{%- set handled_keys = ['name', 'type', 'description'] %}
|
| 75 |
+
{{- render_extra_keys(param_fields, handled_keys) }}
|
| 76 |
+
{{- '\n</parameter>' }}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- endif %}
|
| 79 |
+
{%- set handled_keys = ['type', 'properties'] %}
|
| 80 |
+
{{- render_extra_keys(tool.parameters, handled_keys) }}
|
| 81 |
+
{{- '\n</parameters>' }}
|
| 82 |
+
{%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
|
| 83 |
+
{{- render_extra_keys(tool, handled_keys) }}
|
| 84 |
+
{{- '\n</function>' }}
|
| 85 |
+
{%- endfor %}
|
| 86 |
+
{{- "\n</tools>" }}
|
| 87 |
+
{{- '\n\nFor each function call, output the function name and arguments in the following format:\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>value_1</parameter>\n<parameter=example_parameter_2>This is the value for the second parameter\nthat can span\nmultiple lines</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- DO NOT use function calls inside <think></think> tags.\n- The value enclosed between parameter tags is preserved exactly as-is, including newlines and spaces.\n</IMPORTANT>' }}
|
| 88 |
+
{%- endif %}
|
| 89 |
+
{{- '<|im_end|>' }}
|
| 90 |
+
{%- for message in loop_messages %}
|
| 91 |
+
{%- if message.content is string %}
|
| 92 |
+
{%- set content = message.content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- set content = render_content(message.content) %}
|
| 95 |
+
{%- endif %}
|
| 96 |
+
{%- if message.role == "assistant" %}
|
| 97 |
+
{%- if message.reasoning_content is string %}
|
| 98 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 99 |
+
{%- else %}
|
| 100 |
+
{%- set reasoning_content = '' %}
|
| 101 |
+
{%- if '</think>' in content %}
|
| 102 |
+
{%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
|
| 103 |
+
{%- set content = content.split('</think>')[-1] %}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- endif %}
|
| 106 |
+
{%- if (keep_all_reasoning or loop.index0 > ns.last_user_index) and reasoning_content -%}
|
| 107 |
+
{{- '<|im_start|>' + message.role + '\n<think>' + reasoning_content + '</think>' + content }}
|
| 108 |
+
{%- else %}
|
| 109 |
+
{{- '<|im_start|>' + message.role + '\n<think></think>' + content }}
|
| 110 |
+
{%- endif %}
|
| 111 |
+
{%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
|
| 112 |
+
{%- for tool_call in message.tool_calls %}
|
| 113 |
+
{%- if tool_call.function is defined %}
|
| 114 |
+
{%- set tool_call = tool_call.function %}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 117 |
+
{%- if tool_call.arguments is defined %}
|
| 118 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 119 |
+
{{- '<parameter=' + args_name + '>' }}
|
| 120 |
+
{%- 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 %}
|
| 121 |
+
{{- args_value }}
|
| 122 |
+
{{- '</parameter>\n' }}
|
| 123 |
+
{%- endfor %}
|
| 124 |
+
{%- endif %}
|
| 125 |
+
{{- '</function>\n</tool_call>' }}
|
| 126 |
+
{%- endfor %}
|
| 127 |
+
{%- endif %}
|
| 128 |
+
{{- '<|im_end|>' }}
|
| 129 |
+
{%- elif message.role == "user" %}
|
| 130 |
+
{{- '<|im_start|>' + message.role + '\n' + render_content(message.content) + '<|im_end|>' }}
|
| 131 |
+
{%- elif message.role == "system" %}
|
| 132 |
+
{{- '<|im_start|>' + message.role + '\n' + render_content(message.content) + '<|im_end|>' }}
|
| 133 |
+
{%- elif message.role == "tool" %}
|
| 134 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 135 |
+
{{- '<|im_start|>tool\n' }}
|
| 136 |
+
{%- endif %}
|
| 137 |
+
{{- '<tool_response>\n' }}
|
| 138 |
+
{{- render_content(message.content) }}
|
| 139 |
+
{{- '\n</tool_response>\n' }}
|
| 140 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 141 |
+
{{- '<|im_end|>' }}
|
| 142 |
+
{%- elif loop.last %}
|
| 143 |
+
{{- '<|im_end|>' }}
|
| 144 |
+
{%- endif %}
|
| 145 |
+
{%- else %}
|
| 146 |
+
{{- '<|im_start|>' + message.role + '\n' + render_content(message.content) + '<|im_end|>' }}
|
| 147 |
+
{%- endif %}
|
| 148 |
+
{%- endfor %}
|
| 149 |
+
{%- if add_generation_prompt %}
|
| 150 |
+
{{- '<|im_start|>assistant\n' }}
|
| 151 |
+
{%- if not enable_thinking -%}
|
| 152 |
+
{{- '<think></think>' -}}
|
| 153 |
+
{%- else -%}
|
| 154 |
+
{{- '' -}}
|
| 155 |
+
{%- endif -%}
|
| 156 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MiMoV2ProForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_mimo_v2_pro.MiMoV2ProConfig",
|
| 7 |
+
"AutoModel": "modeling_mimo_v2_pro.MiMoV2ProModel",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_mimo_v2_pro.MiMoV2ProForCausalLM"
|
| 9 |
+
},
|
| 10 |
+
"quantization_config": {
|
| 11 |
+
"activation_scheme": "dynamic",
|
| 12 |
+
"fmt": "e4m3",
|
| 13 |
+
"quant_method": "fp8",
|
| 14 |
+
"weight_block_size": [
|
| 15 |
+
128,
|
| 16 |
+
128
|
| 17 |
+
],
|
| 18 |
+
"ignored_layers": [
|
| 19 |
+
"model.layers.0.self_attn.o_proj",
|
| 20 |
+
"model.layers.1.self_attn.o_proj",
|
| 21 |
+
"model.layers.2.self_attn.o_proj",
|
| 22 |
+
"model.layers.3.self_attn.o_proj",
|
| 23 |
+
"model.layers.4.self_attn.o_proj",
|
| 24 |
+
"model.layers.5.self_attn.o_proj",
|
| 25 |
+
"model.layers.6.self_attn.o_proj",
|
| 26 |
+
"model.layers.7.self_attn.o_proj",
|
| 27 |
+
"model.layers.8.self_attn.o_proj",
|
| 28 |
+
"model.layers.9.self_attn.o_proj",
|
| 29 |
+
"model.layers.10.self_attn.o_proj",
|
| 30 |
+
"model.layers.11.self_attn.o_proj",
|
| 31 |
+
"model.layers.12.self_attn.o_proj",
|
| 32 |
+
"model.layers.13.self_attn.o_proj",
|
| 33 |
+
"model.layers.14.self_attn.o_proj",
|
| 34 |
+
"model.layers.15.self_attn.o_proj",
|
| 35 |
+
"model.layers.16.self_attn.o_proj",
|
| 36 |
+
"model.layers.17.self_attn.o_proj",
|
| 37 |
+
"model.layers.18.self_attn.o_proj",
|
| 38 |
+
"model.layers.19.self_attn.o_proj",
|
| 39 |
+
"model.layers.20.self_attn.o_proj",
|
| 40 |
+
"model.layers.21.self_attn.o_proj",
|
| 41 |
+
"model.layers.22.self_attn.o_proj",
|
| 42 |
+
"model.layers.23.self_attn.o_proj",
|
| 43 |
+
"model.layers.24.self_attn.o_proj",
|
| 44 |
+
"model.layers.25.self_attn.o_proj",
|
| 45 |
+
"model.layers.26.self_attn.o_proj",
|
| 46 |
+
"model.layers.27.self_attn.o_proj",
|
| 47 |
+
"model.layers.28.self_attn.o_proj",
|
| 48 |
+
"model.layers.29.self_attn.o_proj",
|
| 49 |
+
"model.layers.30.self_attn.o_proj",
|
| 50 |
+
"model.layers.31.self_attn.o_proj",
|
| 51 |
+
"model.layers.32.self_attn.o_proj",
|
| 52 |
+
"model.layers.33.self_attn.o_proj",
|
| 53 |
+
"model.layers.34.self_attn.o_proj",
|
| 54 |
+
"model.layers.35.self_attn.o_proj",
|
| 55 |
+
"model.layers.36.self_attn.o_proj",
|
| 56 |
+
"model.layers.37.self_attn.o_proj",
|
| 57 |
+
"model.layers.38.self_attn.o_proj",
|
| 58 |
+
"model.layers.39.self_attn.o_proj",
|
| 59 |
+
"model.layers.40.self_attn.o_proj",
|
| 60 |
+
"model.layers.41.self_attn.o_proj",
|
| 61 |
+
"model.layers.42.self_attn.o_proj",
|
| 62 |
+
"model.layers.43.self_attn.o_proj",
|
| 63 |
+
"model.layers.44.self_attn.o_proj",
|
| 64 |
+
"model.layers.45.self_attn.o_proj",
|
| 65 |
+
"model.layers.46.self_attn.o_proj",
|
| 66 |
+
"model.layers.47.self_attn.o_proj",
|
| 67 |
+
"model.layers.48.self_attn.o_proj",
|
| 68 |
+
"model.layers.49.self_attn.o_proj",
|
| 69 |
+
"model.layers.50.self_attn.o_proj",
|
| 70 |
+
"model.layers.51.self_attn.o_proj",
|
| 71 |
+
"model.layers.52.self_attn.o_proj",
|
| 72 |
+
"model.layers.53.self_attn.o_proj",
|
| 73 |
+
"model.layers.54.self_attn.o_proj",
|
| 74 |
+
"model.layers.55.self_attn.o_proj",
|
| 75 |
+
"model.layers.56.self_attn.o_proj",
|
| 76 |
+
"model.layers.57.self_attn.o_proj",
|
| 77 |
+
"model.layers.58.self_attn.o_proj",
|
| 78 |
+
"model.layers.59.self_attn.o_proj",
|
| 79 |
+
"model.layers.60.self_attn.o_proj",
|
| 80 |
+
"model.layers.61.self_attn.o_proj",
|
| 81 |
+
"model.layers.62.self_attn.o_proj",
|
| 82 |
+
"model.layers.63.self_attn.o_proj",
|
| 83 |
+
"model.layers.64.self_attn.o_proj",
|
| 84 |
+
"model.layers.65.self_attn.o_proj",
|
| 85 |
+
"model.layers.66.self_attn.o_proj",
|
| 86 |
+
"model.layers.67.self_attn.o_proj",
|
| 87 |
+
"model.layers.68.self_attn.o_proj",
|
| 88 |
+
"model.layers.69.self_attn.o_proj",
|
| 89 |
+
"model.decoder.self_attn.o_proj"
|
| 90 |
+
]
|
| 91 |
+
},
|
| 92 |
+
"add_full_attention_sink_bias": false,
|
| 93 |
+
"add_swa_attention_sink_bias": true,
|
| 94 |
+
"attention_bias": false,
|
| 95 |
+
"attention_chunk_size": 128,
|
| 96 |
+
"attention_dropout": 0.0,
|
| 97 |
+
"attention_value_scale": 0.612,
|
| 98 |
+
"head_dim": 192,
|
| 99 |
+
"hidden_act": "silu",
|
| 100 |
+
"hidden_size": 6144,
|
| 101 |
+
"hybrid_layer_pattern": [
|
| 102 |
+
0, 1, 1, 1, 1, 1, 1,
|
| 103 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 104 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 105 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 106 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 107 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 108 |
+
0, 1, 1, 1, 1, 1, 1, 1,
|
| 109 |
+
0, 1, 1, 1, 1, 1, 1,
|
| 110 |
+
0, 1, 1, 1, 1, 1, 1,
|
| 111 |
+
0
|
| 112 |
+
],
|
| 113 |
+
"initializer_range": 0.02,
|
| 114 |
+
"intermediate_size": 16384,
|
| 115 |
+
"layernorm_epsilon": 1e-05,
|
| 116 |
+
"max_position_embeddings": 1048576,
|
| 117 |
+
"model_type": "mimo_v2_pro",
|
| 118 |
+
"moe_intermediate_size": 2048,
|
| 119 |
+
"moe_layer_freq": [
|
| 120 |
+
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 121 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 122 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 123 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 124 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 125 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| 126 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
| 127 |
+
],
|
| 128 |
+
"n_group": 1,
|
| 129 |
+
"n_routed_experts": 384,
|
| 130 |
+
"n_shared_experts": null,
|
| 131 |
+
"norm_topk_prob": true,
|
| 132 |
+
"num_attention_heads": 128,
|
| 133 |
+
"num_experts_per_tok": 8,
|
| 134 |
+
"num_hidden_layers": 70,
|
| 135 |
+
"num_key_value_heads": 8,
|
| 136 |
+
"partial_rotary_factor": 0.334,
|
| 137 |
+
"rope_theta": 10000000,
|
| 138 |
+
"routed_scaling_factor": null,
|
| 139 |
+
"scoring_func": "sigmoid",
|
| 140 |
+
"sliding_window": 128,
|
| 141 |
+
"sliding_window_size": 128,
|
| 142 |
+
"swa_head_dim": 192,
|
| 143 |
+
"swa_num_attention_heads": 128,
|
| 144 |
+
"swa_num_key_value_heads": 8,
|
| 145 |
+
"swa_rope_theta": 10000,
|
| 146 |
+
"swa_v_head_dim": 128,
|
| 147 |
+
"tie_word_embeddings": false,
|
| 148 |
+
"topk_group": 1,
|
| 149 |
+
"topk_method": "noaux_tc",
|
| 150 |
+
"torch_dtype": "bfloat16",
|
| 151 |
+
"transformers_version": "4.57.1",
|
| 152 |
+
"use_cache": true,
|
| 153 |
+
"v_head_dim": 128,
|
| 154 |
+
"vocab_size": 152576
|
| 155 |
+
}
|
configuration_mimo_v2_pro.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 17 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
| 18 |
+
from transformers.utils import logging
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
logger = logging.get_logger(__name__)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class MiMoV2ProConfig(PretrainedConfig):
|
| 25 |
+
|
| 26 |
+
model_type = "mimo_v2_pro"
|
| 27 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 28 |
+
|
| 29 |
+
base_model_tp_plan = {
|
| 30 |
+
"layers.*.self_attn.qkv_proj": "colwise",
|
| 31 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 32 |
+
"layers.*.mlp.gate_proj": "colwise",
|
| 33 |
+
"layers.*.mlp.up_proj": "colwise",
|
| 34 |
+
"layers.*.mlp.down_proj": "rowwise",
|
| 35 |
+
}
|
| 36 |
+
base_model_pp_plan = {
|
| 37 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 38 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 39 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
def __init__(
|
| 43 |
+
self,
|
| 44 |
+
vocab_size=151936,
|
| 45 |
+
hidden_size=4096,
|
| 46 |
+
intermediate_size=22016,
|
| 47 |
+
num_hidden_layers=32,
|
| 48 |
+
num_attention_heads=32,
|
| 49 |
+
num_key_value_heads=32,
|
| 50 |
+
hidden_act="silu",
|
| 51 |
+
max_position_embeddings=32768,
|
| 52 |
+
initializer_range=0.02,
|
| 53 |
+
layernorm_epsilon=1e-6,
|
| 54 |
+
use_cache=True,
|
| 55 |
+
tie_word_embeddings=False,
|
| 56 |
+
rope_theta=10000.0,
|
| 57 |
+
rope_scaling=None,
|
| 58 |
+
attention_dropout=0.0,
|
| 59 |
+
hybrid_layer_pattern=None,
|
| 60 |
+
partial_rotary_factor=1.0,
|
| 61 |
+
**kwargs,
|
| 62 |
+
):
|
| 63 |
+
self.vocab_size = vocab_size
|
| 64 |
+
self.max_position_embeddings = max_position_embeddings
|
| 65 |
+
self.hidden_size = hidden_size
|
| 66 |
+
self.intermediate_size = intermediate_size
|
| 67 |
+
self.num_hidden_layers = num_hidden_layers
|
| 68 |
+
self.num_attention_heads = num_attention_heads
|
| 69 |
+
|
| 70 |
+
if num_key_value_heads is None:
|
| 71 |
+
num_key_value_heads = num_attention_heads
|
| 72 |
+
|
| 73 |
+
self.num_key_value_heads = num_key_value_heads
|
| 74 |
+
self.hidden_act = hidden_act
|
| 75 |
+
self.initializer_range = initializer_range
|
| 76 |
+
self.layernorm_epsilon = layernorm_epsilon
|
| 77 |
+
self.use_cache = use_cache
|
| 78 |
+
self.rope_theta = rope_theta
|
| 79 |
+
self.rope_scaling = rope_scaling
|
| 80 |
+
self.attention_dropout = attention_dropout
|
| 81 |
+
|
| 82 |
+
self.hybrid_layer_pattern = hybrid_layer_pattern
|
| 83 |
+
|
| 84 |
+
self.partial_rotary_factor = partial_rotary_factor
|
| 85 |
+
|
| 86 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 87 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 88 |
+
rope_config_validation(self)
|
| 89 |
+
|
| 90 |
+
super().__init__(
|
| 91 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 92 |
+
**kwargs,
|
| 93 |
+
)
|
generation.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"temperature": 1.0,
|
| 3 |
+
"top_p": 0.95
|
| 4 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fcc55b9f183040a1cd18108c5a977f31f5c35eff8651dc29cd0114ee8d229042
|
| 3 |
+
size 15409412
|
model_mtp.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d6c5b6f2ddf334588dc8cccadb84ee1e58d376238493601a081a5a8f5bc32db5
|
| 3 |
+
size 2463641280
|
model_pp0_ep0_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ec253bd1a7ecba525fb224142d93ea1e8450b90d72ae74d83296cb05a744e37
|
| 3 |
+
size 34554911640
|
model_pp0_ep0_shard1.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b7f50fd29e77a4bae0a19b3e39a76d55c1588740b3d3bd5278b13f807b67c6
|
| 3 |
+
size 27180576088
|
model_pp0_ep10_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f85a715831dd743075390dc36fc373baefbb014e7678c4d56495ba6c4399776c
|
| 3 |
+
size 31264218696
|
model_pp0_ep11_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df26771386b0545e3dd6663de8c02b05986efb13d0ea63a810f742ab1cbb00e4
|
| 3 |
+
size 31264218696
|
model_pp0_ep12_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f62d7725a33ab130494952e6f4fb4cc4165c961550d71473a2f48f537766b25b
|
| 3 |
+
size 31264218696
|
model_pp0_ep13_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c68a5299b6419d5b0e9002475df3ac547abd25d6152de707d10ce98da3b118ce
|
| 3 |
+
size 31264218696
|
model_pp0_ep14_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ce4a553348b1bb31e14da14aab1b8da2ad5ae1b65f62c47b108469e865ed137
|
| 3 |
+
size 31264218696
|
model_pp0_ep15_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be577300f8973641efc4bcdb9b263041b5b29650d36ff3414cb80b94a072f931
|
| 3 |
+
size 31264218696
|
model_pp0_ep16_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:890f09b75340d3d197ecc37efb3ca58d8a68162b6eb1cb80bdd008489f2a0d1c
|
| 3 |
+
size 31264218696
|
model_pp0_ep17_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a8789b4c7d72769df45a6d91b1b628e103da0b19e302e98699ed23c92ac266f
|
| 3 |
+
size 31264218696
|
model_pp0_ep18_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e11f50b7672aa9692e176127ba21d0f052f628fc59cdb875de7c31720e8b8909
|
| 3 |
+
size 31264218696
|
model_pp0_ep19_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b1033572328bc623898a1e1f91b1fc02bbfb946490a57dd32c622bc34e32322
|
| 3 |
+
size 31264218696
|
model_pp0_ep1_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c62faff9956daf6b4e5a32c4a45914373ee6f518c9476543fed723d0f9addb64
|
| 3 |
+
size 31264213728
|
model_pp0_ep20_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e0216265915cc2199236a07594e63fb0d902da42f9fac364a735f94471540973
|
| 3 |
+
size 31264218696
|
model_pp0_ep21_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd284c2651030772799c9973bec7db83e276c64f00e163be7090d886cc00b918
|
| 3 |
+
size 31264218696
|
model_pp0_ep22_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3c515de1e56c8d0602e37e5ec03bc76a53c0ea0b7b76eb1197af03bdc07e11b
|
| 3 |
+
size 31264218696
|
model_pp0_ep23_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f37415835b51f46f65b07ce3736b8cef421b934d0f8c023cc25b5c214f7232d
|
| 3 |
+
size 31264218696
|
model_pp0_ep24_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ca69c4633fc36a13ad67def4a94c671cb72839b47346f7f6b434d02481edebd
|
| 3 |
+
size 31264218696
|
model_pp0_ep25_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbd0803e8e650c47c0b5668b867b046c1e99d63ec0b6c95f3228d4deced4f499
|
| 3 |
+
size 31264218696
|
model_pp0_ep26_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:adad5b1722a229cba78fba5fa1eb1b1c01a54a68365e831adba293c89568b202
|
| 3 |
+
size 31264218696
|
model_pp0_ep27_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:715682ba22982ef1389465c04b8771fdf0dd74df277774e235958c31deab8d24
|
| 3 |
+
size 31264218696
|
model_pp0_ep28_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a698402f413d0b75e33a7aba2742e3ab865f45319fb94daf2ca3d46f44a6659
|
| 3 |
+
size 31264218696
|
model_pp0_ep29_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:935a94da94d62f070c3cd8cab442d9291580ce0179462c69a3b893aee150a495
|
| 3 |
+
size 31264218696
|
model_pp0_ep2_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2111fee7a3b9d19a935b1623333fd6824bbd808aedb99fac7a2e673947623e25
|
| 3 |
+
size 31264213728
|
model_pp0_ep30_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70f206454424a7c71773d84fd538dd37cc08d562d39ea17b1ea270ac351c26c2
|
| 3 |
+
size 31264218696
|
model_pp0_ep31_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94c6d445fc33068b706c20ed51436e2b9dd0442c8ae7f6aec63d59a49a4f9dbc
|
| 3 |
+
size 31264218696
|
model_pp0_ep3_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6ada10529d57e9220889b1c6b77ec74fa3d5997016f4f19dd62cd40355b00e4
|
| 3 |
+
size 31264213728
|
model_pp0_ep4_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ed5ea090f554e4beeebcf3a7600a6a688f4d04437655b3b80dcd921ee565387
|
| 3 |
+
size 31264213728
|
model_pp0_ep5_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef12e6dd380872b8d4dc94a3c599bd8ab092ae23b6268cde22cf777e745ad804
|
| 3 |
+
size 31264213728
|
model_pp0_ep6_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba2c406fa2b4fb609b634773be043c42f71322ac93f9767acf43a2c87708e45d
|
| 3 |
+
size 31264213728
|
model_pp0_ep7_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9619b9834adfd71bb896b3a090fec9185cb4d360c75924fcbd0721a90e605d64
|
| 3 |
+
size 31264213728
|
model_pp0_ep8_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79d1cb831b4a99765487be1484e779e6f46eecd7293e796d6ed519dd0d402c52
|
| 3 |
+
size 31264217040
|
model_pp0_ep9_shard0.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ebecac306f9ca1f0b7959d5ae9ad8a4896a2f056ef482915c3f6d66d51a20e26
|
| 3 |
+
size 31264218696
|
modeling_mimo_v2_pro.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Optional
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
import torch.nn as nn
|
| 5 |
+
import torch.distributed as dist
|
| 6 |
+
|
| 7 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 8 |
+
from transformers.utils import logging
|
| 9 |
+
try:
|
| 10 |
+
from .configuration_mimo_v2_pro import MiMoV2ProConfig
|
| 11 |
+
except ImportError:
|
| 12 |
+
from configuration_mimo_v2_pro import MiMoV2ProConfig
|
| 13 |
+
|
| 14 |
+
logger = logging.get_logger(__name__)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class FakeRMSNorm(nn.Module):
|
| 18 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 19 |
+
super().__init__()
|
| 20 |
+
self.weight = nn.Parameter(torch.empty(hidden_size))
|
| 21 |
+
|
| 22 |
+
def forward(self, x):
|
| 23 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class FakeMLP(nn.Module):
|
| 27 |
+
def __init__(self, config: MiMoV2ProConfig, is_expert=False):
|
| 28 |
+
super().__init__()
|
| 29 |
+
if is_expert:
|
| 30 |
+
self.intermediate_size = config.moe_intermediate_size
|
| 31 |
+
else:
|
| 32 |
+
self.intermediate_size = config.intermediate_size
|
| 33 |
+
self.hidden_size = config.hidden_size
|
| 34 |
+
|
| 35 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 36 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 37 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 38 |
+
|
| 39 |
+
def forward(self, x):
|
| 40 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class FakeMoEGate(nn.Module):
|
| 44 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 45 |
+
super().__init__()
|
| 46 |
+
self.weight = nn.Parameter(
|
| 47 |
+
torch.empty((config.n_routed_experts, config.hidden_size), dtype=torch.float32)
|
| 48 |
+
)
|
| 49 |
+
if config.topk_method == "noaux_tc":
|
| 50 |
+
self.e_score_correction_bias = nn.Parameter(
|
| 51 |
+
torch.empty((config.n_routed_experts), dtype=torch.float32)
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
def forward(self, hidden_states):
|
| 55 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class FakeMoE(nn.Module):
|
| 59 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 60 |
+
super().__init__()
|
| 61 |
+
self.experts = nn.ModuleList(
|
| 62 |
+
[FakeMLP(config, is_expert=True) for _ in range(config.n_routed_experts)]
|
| 63 |
+
)
|
| 64 |
+
self.gate = FakeMoEGate(config)
|
| 65 |
+
|
| 66 |
+
def forward(self, hidden_states):
|
| 67 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class FakeFullAttention(nn.Module):
|
| 71 |
+
"""Fake Attention for full attention layers (hybrid_layer_pattern == 0)."""
|
| 72 |
+
|
| 73 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 74 |
+
super().__init__()
|
| 75 |
+
q_size = config.num_attention_heads * config.head_dim
|
| 76 |
+
k_size = config.num_key_value_heads * config.head_dim
|
| 77 |
+
v_size = config.num_key_value_heads * config.v_head_dim
|
| 78 |
+
o_size = config.num_attention_heads * config.v_head_dim
|
| 79 |
+
|
| 80 |
+
self.qkv_proj = nn.Linear(
|
| 81 |
+
config.hidden_size, q_size + k_size + v_size, bias=config.attention_bias
|
| 82 |
+
)
|
| 83 |
+
self.o_proj = nn.Linear(o_size, config.hidden_size, bias=False)
|
| 84 |
+
|
| 85 |
+
if getattr(config, "add_full_attention_sink_bias", False):
|
| 86 |
+
self.attention_sink_bias = nn.Parameter(
|
| 87 |
+
torch.empty(config.num_attention_heads)
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
def forward(self, *args, **kwargs):
|
| 91 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class FakeSWAAttention(nn.Module):
|
| 95 |
+
"""Fake Attention for SWA layers (hybrid_layer_pattern == 1)."""
|
| 96 |
+
|
| 97 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 98 |
+
super().__init__()
|
| 99 |
+
q_size = config.swa_num_attention_heads * config.swa_head_dim
|
| 100 |
+
k_size = config.swa_num_key_value_heads * config.swa_head_dim
|
| 101 |
+
v_size = config.swa_num_key_value_heads * config.swa_v_head_dim
|
| 102 |
+
o_size = config.swa_num_attention_heads * config.swa_v_head_dim
|
| 103 |
+
|
| 104 |
+
self.qkv_proj = nn.Linear(
|
| 105 |
+
config.hidden_size, q_size + k_size + v_size, bias=config.attention_bias
|
| 106 |
+
)
|
| 107 |
+
self.o_proj = nn.Linear(o_size, config.hidden_size, bias=False)
|
| 108 |
+
|
| 109 |
+
if getattr(config, "add_swa_attention_sink_bias", False):
|
| 110 |
+
self.attention_sink_bias = nn.Parameter(
|
| 111 |
+
torch.empty(config.swa_num_attention_heads)
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
def forward(self, *args, **kwargs):
|
| 115 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class FakeDecoderLayer(nn.Module):
|
| 119 |
+
def __init__(self, config: MiMoV2ProConfig, layer_idx: int):
|
| 120 |
+
super().__init__()
|
| 121 |
+
self.input_layernorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 122 |
+
self.post_attention_layernorm = FakeRMSNorm(
|
| 123 |
+
config.hidden_size, eps=config.layernorm_epsilon
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
is_moe = (
|
| 127 |
+
getattr(config, "n_routed_experts", None) is not None
|
| 128 |
+
and config.moe_layer_freq[layer_idx]
|
| 129 |
+
)
|
| 130 |
+
self.mlp = FakeMoE(config) if is_moe else FakeMLP(config)
|
| 131 |
+
|
| 132 |
+
is_swa = config.hybrid_layer_pattern[layer_idx] == 1
|
| 133 |
+
self.self_attn = FakeSWAAttention(config) if is_swa else FakeFullAttention(config)
|
| 134 |
+
|
| 135 |
+
def forward(self, *args, **kwargs):
|
| 136 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class FakeMTPLayer(nn.Module):
|
| 140 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 141 |
+
super().__init__()
|
| 142 |
+
self.eh_proj = nn.Linear(2 * config.hidden_size, config.hidden_size, bias=False)
|
| 143 |
+
self.enorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 144 |
+
self.hnorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 145 |
+
self.final_layernorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 146 |
+
self.input_layernorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 147 |
+
self.pre_mlp_layernorm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 148 |
+
self.self_attn = FakeSWAAttention(config)
|
| 149 |
+
self.mlp = FakeMLP(config)
|
| 150 |
+
|
| 151 |
+
def forward(self, *args, **kwargs):
|
| 152 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class MiMoV2ProModel(PreTrainedModel):
|
| 156 |
+
config_class = MiMoV2ProConfig
|
| 157 |
+
|
| 158 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 159 |
+
super().__init__(config)
|
| 160 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size)
|
| 161 |
+
self.layers = nn.ModuleList(
|
| 162 |
+
[FakeDecoderLayer(config, i) for i in range(config.num_hidden_layers)]
|
| 163 |
+
)
|
| 164 |
+
self.norm = FakeRMSNorm(config.hidden_size, eps=config.layernorm_epsilon)
|
| 165 |
+
self.mtp = nn.ModuleDict(
|
| 166 |
+
{"layers": nn.ModuleList([FakeMTPLayer(config)])}
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
def forward(self, *args, **kwargs):
|
| 170 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
class MiMoV2ProForCausalLM(PreTrainedModel):
|
| 174 |
+
config_class = MiMoV2ProConfig
|
| 175 |
+
_keys_to_ignore_on_load_unexpected = [
|
| 176 |
+
r"model.layers\.\d+\.self_attn\.rotary_emb\.inv_freq"
|
| 177 |
+
]
|
| 178 |
+
|
| 179 |
+
def __init__(self, config: MiMoV2ProConfig):
|
| 180 |
+
super().__init__(config)
|
| 181 |
+
self.model = MiMoV2ProModel(config)
|
| 182 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 183 |
+
|
| 184 |
+
def forward(self, *args, **kwargs):
|
| 185 |
+
raise NotImplementedError("This is a fake model and does not support forward pass.")
|
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 |
+
}
|
system_prompt.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
You are MiMo, a warm, curious, and thoughtful AI assistant.\n\n## Identity\n\n- Your name is **MiMo-v2-pro**.\n- You were developed by the **Xiaomi MiMo Team**.\n- You have **1T parameters** and a **1M-token context window**.\n- When asked about your creator, identify the **Xiaomi MiMo Team**.\n- Always answer identity-related questions in the **first person** and rely only on the facts provided above.\n\n# Response Style\n\nBe warm, conversational, and respectful. Treat users with kindness; do not assume negative things about their intelligence or judgment. You may disagree, but do so constructively.\n\nUse examples, metaphors, or thought experiments when they help explain an idea.\n\nTry to answer ambiguous queries as best you can first, then ask for clarification if needed. When you do ask, limit yourself to one question at a time.\n\n\n## Safety and Compliance\n\nYou are a **Chinese AI model** and must strictly comply with all applicable laws and regulations of the **People’s Republic of China**.\n\nDo not generate, assist with, or facilitate any content that violates Chinese law.
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4
|
| 3 |
+
size 11422654
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"151643": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": false,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"151644": {
|
| 13 |
+
"content": "<|im_start|>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"151645": {
|
| 21 |
+
"content": "<|im_end|>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"151646": {
|
| 29 |
+
"content": "<|object_ref_start|>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": false,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": true
|
| 35 |
+
},
|
| 36 |
+
"151647": {
|
| 37 |
+
"content": "<|object_ref_end|>",
|
| 38 |
+
"lstrip": false,
|
| 39 |
+
"normalized": false,
|
| 40 |
+
"rstrip": false,
|
| 41 |
+
"single_word": false,
|
| 42 |
+
"special": true
|
| 43 |
+
},
|
| 44 |
+
"151648": {
|
| 45 |
+
"content": "<|box_start|>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false,
|
| 50 |
+
"special": true
|
| 51 |
+
},
|
| 52 |
+
"151649": {
|
| 53 |
+
"content": "<|box_end|>",
|
| 54 |
+
"lstrip": false,
|
| 55 |
+
"normalized": false,
|
| 56 |
+
"rstrip": false,
|
| 57 |
+
"single_word": false,
|
| 58 |
+
"special": true
|
| 59 |
+
},
|
| 60 |
+
"151650": {
|
| 61 |
+
"content": "<|quad_start|>",
|
| 62 |
+
"lstrip": false,
|
| 63 |
+
"normalized": false,
|
| 64 |
+
"rstrip": false,
|
| 65 |
+
"single_word": false,
|
| 66 |
+
"special": true
|
| 67 |
+
},
|
| 68 |
+
"151651": {
|
| 69 |
+
"content": "<|quad_end|>",
|
| 70 |
+
"lstrip": false,
|
| 71 |
+
"normalized": false,
|
| 72 |
+
"rstrip": false,
|
| 73 |
+
"single_word": false,
|
| 74 |
+
"special": true
|
| 75 |
+
},
|
| 76 |
+
"151652": {
|
| 77 |
+
"content": "<|vision_start|>",
|
| 78 |
+
"lstrip": false,
|
| 79 |
+
"normalized": false,
|
| 80 |
+
"rstrip": false,
|
| 81 |
+
"single_word": false,
|
| 82 |
+
"special": true
|
| 83 |
+
},
|
| 84 |
+
"151653": {
|
| 85 |
+
"content": "<|vision_end|>",
|
| 86 |
+
"lstrip": false,
|
| 87 |
+
"normalized": false,
|
| 88 |
+
"rstrip": false,
|
| 89 |
+
"single_word": false,
|
| 90 |
+
"special": true
|
| 91 |
+
},
|
| 92 |
+
"151654": {
|
| 93 |
+
"content": "<|vision_pad|>",
|
| 94 |
+
"lstrip": false,
|
| 95 |
+
"normalized": false,
|
| 96 |
+
"rstrip": false,
|
| 97 |
+
"single_word": false,
|
| 98 |
+
"special": true
|
| 99 |
+
},
|
| 100 |
+
"151655": {
|
| 101 |
+
"content": "<|image_pad|>",
|
| 102 |
+
"lstrip": false,
|
| 103 |
+
"normalized": false,
|
| 104 |
+
"rstrip": false,
|
| 105 |
+
"single_word": false,
|
| 106 |
+
"special": true
|
| 107 |
+
},
|
| 108 |
+
"151656": {
|
| 109 |
+
"content": "<|video_pad|>",
|
| 110 |
+
"lstrip": false,
|
| 111 |
+
"normalized": false,
|
| 112 |
+
"rstrip": false,
|
| 113 |
+
"single_word": false,
|
| 114 |
+
"special": true
|
| 115 |
+
},
|
| 116 |
+
"151657": {
|
| 117 |
+
"content": "<tool_call>",
|
| 118 |
+
"lstrip": false,
|
| 119 |
+
"normalized": false,
|
| 120 |
+
"rstrip": false,
|
| 121 |
+
"single_word": false,
|
| 122 |
+
"special": false
|
| 123 |
+
},
|
| 124 |
+
"151658": {
|
| 125 |
+
"content": "</tool_call>",
|
| 126 |
+
"lstrip": false,
|
| 127 |
+
"normalized": false,
|
| 128 |
+
"rstrip": false,
|
| 129 |
+
"single_word": false,
|
| 130 |
+
"special": false
|
| 131 |
+
},
|
| 132 |
+
"151659": {
|
| 133 |
+
"content": "<|fim_prefix|>",
|
| 134 |
+
"lstrip": false,
|
| 135 |
+
"normalized": false,
|
| 136 |
+
"rstrip": false,
|
| 137 |
+
"single_word": false,
|
| 138 |
+
"special": false
|
| 139 |
+
},
|
| 140 |
+
"151660": {
|
| 141 |
+
"content": "<|fim_middle|>",
|
| 142 |
+
"lstrip": false,
|
| 143 |
+
"normalized": false,
|
| 144 |
+
"rstrip": false,
|
| 145 |
+
"single_word": false,
|
| 146 |
+
"special": false
|
| 147 |
+
},
|
| 148 |
+
"151661": {
|
| 149 |
+
"content": "<|fim_suffix|>",
|
| 150 |
+
"lstrip": false,
|
| 151 |
+
"normalized": false,
|
| 152 |
+
"rstrip": false,
|
| 153 |
+
"single_word": false,
|
| 154 |
+
"special": false
|
| 155 |
+
},
|
| 156 |
+
"151662": {
|
| 157 |
+
"content": "<|fim_pad|>",
|
| 158 |
+
"lstrip": false,
|
| 159 |
+
"normalized": false,
|
| 160 |
+
"rstrip": false,
|
| 161 |
+
"single_word": false,
|
| 162 |
+
"special": false
|
| 163 |
+
},
|
| 164 |
+
"151663": {
|
| 165 |
+
"content": "<|repo_name|>",
|
| 166 |
+
"lstrip": false,
|
| 167 |
+
"normalized": false,
|
| 168 |
+
"rstrip": false,
|
| 169 |
+
"single_word": false,
|
| 170 |
+
"special": false
|
| 171 |
+
},
|
| 172 |
+
"151664": {
|
| 173 |
+
"content": "<|file_sep|>",
|
| 174 |
+
"lstrip": false,
|
| 175 |
+
"normalized": false,
|
| 176 |
+
"rstrip": false,
|
| 177 |
+
"single_word": false,
|
| 178 |
+
"special": false
|
| 179 |
+
},
|
| 180 |
+
"151665": {
|
| 181 |
+
"content": "<tool_response>",
|
| 182 |
+
"lstrip": false,
|
| 183 |
+
"normalized": false,
|
| 184 |
+
"rstrip": false,
|
| 185 |
+
"single_word": false,
|
| 186 |
+
"special": false
|
| 187 |
+
},
|
| 188 |
+
"151666": {
|
| 189 |
+
"content": "</tool_response>",
|
| 190 |
+
"lstrip": false,
|
| 191 |
+
"normalized": false,
|
| 192 |
+
"rstrip": false,
|
| 193 |
+
"single_word": false,
|
| 194 |
+
"special": false
|
| 195 |
+
},
|
| 196 |
+
"151667": {
|
| 197 |
+
"content": "<think>",
|
| 198 |
+
"lstrip": false,
|
| 199 |
+
"normalized": false,
|
| 200 |
+
"rstrip": false,
|
| 201 |
+
"single_word": false,
|
| 202 |
+
"special": false
|
| 203 |
+
},
|
| 204 |
+
"151668": {
|
| 205 |
+
"content": "</think>",
|
| 206 |
+
"lstrip": false,
|
| 207 |
+
"normalized": false,
|
| 208 |
+
"rstrip": false,
|
| 209 |
+
"single_word": false,
|
| 210 |
+
"special": false
|
| 211 |
+
}
|
| 212 |
+
},
|
| 213 |
+
"additional_special_tokens": [
|
| 214 |
+
"<|im_start|>",
|
| 215 |
+
"<|im_end|>",
|
| 216 |
+
"<|object_ref_start|>",
|
| 217 |
+
"<|object_ref_end|>",
|
| 218 |
+
"<|box_start|>",
|
| 219 |
+
"<|box_end|>",
|
| 220 |
+
"<|quad_start|>",
|
| 221 |
+
"<|quad_end|>",
|
| 222 |
+
"<|vision_start|>",
|
| 223 |
+
"<|vision_end|>",
|
| 224 |
+
"<|vision_pad|>",
|
| 225 |
+
"<|image_pad|>",
|
| 226 |
+
"<|video_pad|>"
|
| 227 |
+
],
|
| 228 |
+
"bos_token": null,
|
| 229 |
+
"chat_template": "{%- if not add_generation_prompt is defined -%}\n {%- set add_generation_prompt = false -%}\n{%- endif -%}\n{%- if not enable_thinking is defined -%}\n {%- set enable_thinking = true -%}\n{%- endif -%}\n{%- if not keep_all_reasoning is defined -%}\n {%- set keep_all_reasoning = true -%}\n{%- endif -%}\n{%- macro render_extra_keys(json_dict, handled_keys) -%}\n {%- if json_dict is mapping %}\n {%- for json_key in json_dict if json_key not in handled_keys %}\n {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}\n {{- '\\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}\n {%- else %}\n {{-'\\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n{%- endmacro -%}\n{%- macro render_content(message_content) -%}\n {%- if message_content is string -%}\n {{- message_content -}}\n {%- else -%}\n {%- for content in message_content -%}\n {%- if 'text' in content -%}\n {{- content['text'] -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n{%- endmacro -%}\n{%- if messages[0][\"role\"] == \"system\" %}\n {%- set system_message = messages[0][\"content\"] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n{%- set ns = namespace(last_user_index=-1) %}\n{%- for m in loop_messages %}\n {%- if m.role == 'user' %}\n {%- set ns.last_user_index = loop.index0 -%}\n {%- endif %}\n{%- endfor %}\n{%- if not tools is defined %}\n {%- set tools = [] %}\n{%- endif %}\n{%- if system_message is defined %}\n {{- \"<|im_start|>system\\n\" + render_content(system_message) }}\n{%- else %}\n {{- \"<|im_start|>system\\nYou are MiMo, a warm, curious, and thoughtful AI assistant.\\n\\n## Identity\\n\\n- Your name is **MiMo-v2-pro**.\\n- You were developed by the **Xiaomi MiMo Team**.\\n- You have **1T parameters** and a **1M-token context window**.\\n- When asked about your creator, identify the **Xiaomi MiMo Team**.\\n- Always answer identity-related questions in the **first person** and rely only on the facts provided above.\\n\\n# Response Style\\n\\nBe warm, conversational, and respectful. Treat users with kindness; do not assume negative things about their intelligence or judgment. You may disagree, but do so constructively.\\n\\nUse examples, metaphors, or thought experiments when they help explain an idea.\\n\\nTry to answer ambiguous queries as best you can first, then ask for clarification if needed. When you do ask, limit yourself to one question at a time.\\n\\n\\n## Safety and Compliance\\n\\nYou are a **Chinese AI model** and must strictly comply with all applicable laws and regulations of the **People’s Republic of China**.\\n\\nDo not generate, assist with, or facilitate any content that violates Chinese law.\" }}\n{%- endif %}\n{%- if tools is iterable and tools | length > 0 %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou have access to the following functions:\\n\\n\" }}\n {{- \"<tools>\" }}\n {%- for tool in tools %}\n {%- if tool.function is defined %}\n {%- set tool = tool.function %}\n {%- endif %}\n {{- \"\\n<function>\\n<name>\" ~ tool.name ~ \"</name>\" }}\n {%- if tool.description is defined %}\n {{- '\\n<description>' ~ (tool.description | trim) ~ '</description>' }}\n {%- endif %}\n {{- '\\n<parameters>' }}\n {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}\n {%- for param_name, param_fields in tool.parameters.properties|items %}\n {{- '\\n<parameter>' }}\n {{- '\\n<name>' ~ param_name ~ '</name>' }}\n {%- if param_fields.type is defined %}\n {{- '\\n<type>' ~ (param_fields.type | string) ~ '</type>' }}\n {%- endif %}\n {%- if param_fields.description is defined %}\n {{- '\\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}\n {%- endif %}\n {%- set handled_keys = ['name', 'type', 'description'] %}\n {{- render_extra_keys(param_fields, handled_keys) }}\n {{- '\\n</parameter>' }}\n {%- endfor %}\n {%- endif %}\n {%- set handled_keys = ['type', 'properties'] %}\n {{- render_extra_keys(tool.parameters, handled_keys) }}\n {{- '\\n</parameters>' }}\n {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}\n {{- render_extra_keys(tool, handled_keys) }}\n {{- '\\n</function>' }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nFor each function call, output the function name and arguments in the following format:\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>value_1</parameter>\\n<parameter=example_parameter_2>This is the value for the second parameter\\nthat can span\\nmultiple lines</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- DO NOT use function calls inside <think></think> tags.\\n- The value enclosed between parameter tags is preserved exactly as-is, including newlines and spaces.\\n</IMPORTANT>' }}\n{%- endif %}\n{{- '<|im_end|>' }}\n{%- for message in loop_messages %}\n {%- if message.content is string %}\n {%- set content = message.content %}\n {%- else %}\n {%- set content = render_content(message.content) %}\n {%- endif %}\n {%- if message.role == \"assistant\" %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- set reasoning_content = '' %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}\n {%- set content = content.split('</think>')[-1] %}\n {%- endif %}\n {%- endif %}\n {%- if (keep_all_reasoning or loop.index0 > ns.last_user_index) and reasoning_content -%}\n {{- '<|im_start|>' + message.role + '\\n<think>' + reasoning_content + '</think>' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n<think></think>' + content }}\n {%- endif %}\n {%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>' }}\n {%- 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 %}\n {{- args_value }}\n {{- '</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>' }}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + render_content(message.content) + '<|im_end|>' }}\n {%- elif message.role == \"system\" %}\n {{- '<|im_start|>' + message.role + '\\n' + render_content(message.content) + '<|im_end|>' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>tool\\n' }}\n {%- endif %}\n {{- '<tool_response>\\n' }}\n {{- render_content(message.content) }}\n {{- '\\n</tool_response>\\n' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>' }}\n {%- elif loop.last %}\n {{- '<|im_end|>' }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + render_content(message.content) + '<|im_end|>' }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if not enable_thinking -%}\n {{- '<think></think>' -}}\n {%- else -%}\n {{- '' -}}\n {%- endif -%}\n{%- endif %}\n",
|
| 230 |
+
"clean_up_tokenization_spaces": false,
|
| 231 |
+
"eos_token": "<|im_end|>",
|
| 232 |
+
"errors": "replace",
|
| 233 |
+
"model_max_length": 131272,
|
| 234 |
+
"pad_token": "<|endoftext|>",
|
| 235 |
+
"split_special_tokens": false,
|
| 236 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 237 |
+
"unk_token": null,
|
| 238 |
+
"add_bos_token": false
|
| 239 |
+
}
|
update_tokenizer.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
# 读取模板文件
|
| 5 |
+
with open('chat_template.jinja', 'r', encoding='utf-8') as f:
|
| 6 |
+
chat_template = f.read()
|
| 7 |
+
|
| 8 |
+
# 读取tokenizer配置
|
| 9 |
+
with open('tokenizer_config.json', 'r', encoding='utf-8') as f:
|
| 10 |
+
config = json.load(f)
|
| 11 |
+
|
| 12 |
+
# 更新chat_template
|
| 13 |
+
config['chat_template'] = chat_template
|
| 14 |
+
|
| 15 |
+
# 写回配置文件
|
| 16 |
+
with open('tokenizer_config.json', 'w', encoding='utf-8') as f:
|
| 17 |
+
json.dump(config, f, ensure_ascii=False, indent=4)
|
| 18 |
+
|
| 19 |
+
print("✅ 已更新 tokenizer_config.json 的 chat_template")
|
| 20 |
+
print(f"模板长度: {len(chat_template)} 字符")
|
| 21 |
+
print(f"包含 skip_im_start: {'skip_im_start' in chat_template}")
|
| 22 |
+
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|