Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- added_tokens.json +56 -0
- chat_template.jinja +165 -0
- config.json +223 -0
- configuration_minimax_m2.py +214 -0
- generation_config.json +8 -0
- merges.txt +0 -0
- model-00000-of-00125.safetensors +3 -0
- model-00001-of-00125.safetensors +3 -0
- model-00002-of-00125.safetensors +3 -0
- model-00003-of-00125.safetensors +3 -0
- model-00004-of-00125.safetensors +3 -0
- model-00005-of-00125.safetensors +3 -0
- model-00006-of-00125.safetensors +3 -0
- model-00007-of-00125.safetensors +3 -0
- model-00008-of-00125.safetensors +3 -0
- model-00009-of-00125.safetensors +3 -0
- model-00010-of-00125.safetensors +3 -0
- model-00011-of-00125.safetensors +3 -0
- model-00012-of-00125.safetensors +3 -0
- model-00013-of-00125.safetensors +3 -0
- model-00014-of-00125.safetensors +3 -0
- model-00015-of-00125.safetensors +3 -0
- model-00016-of-00125.safetensors +3 -0
- model-00017-of-00125.safetensors +3 -0
- model-00018-of-00125.safetensors +3 -0
- model-00019-of-00125.safetensors +3 -0
- model-00020-of-00125.safetensors +3 -0
- model-00021-of-00125.safetensors +3 -0
- model-00022-of-00125.safetensors +3 -0
- model-00023-of-00125.safetensors +3 -0
- model-00024-of-00125.safetensors +3 -0
- model-00025-of-00125.safetensors +3 -0
- model-00026-of-00125.safetensors +3 -0
- model-00027-of-00125.safetensors +3 -0
- model-00028-of-00125.safetensors +3 -0
- model-00029-of-00125.safetensors +3 -0
- model-00030-of-00125.safetensors +3 -0
- model-00031-of-00125.safetensors +3 -0
- model-00032-of-00125.safetensors +3 -0
- model-00033-of-00125.safetensors +3 -0
- model-00034-of-00125.safetensors +3 -0
- model-00035-of-00125.safetensors +3 -0
- model-00036-of-00125.safetensors +3 -0
- model-00037-of-00125.safetensors +3 -0
- model-00038-of-00125.safetensors +3 -0
- model-00039-of-00125.safetensors +3 -0
- model-00040-of-00125.safetensors +3 -0
- model-00041-of-00125.safetensors +3 -0
- model-00042-of-00125.safetensors +3 -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 |
+
model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
added_tokens.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</minimax:tool_call>": 200053,
|
| 3 |
+
"</think>": 200051,
|
| 4 |
+
"<add_file>": 200036,
|
| 5 |
+
"<code_context>": 200043,
|
| 6 |
+
"<code_interpreter>": 200023,
|
| 7 |
+
"<commit_after>": 200018,
|
| 8 |
+
"<commit_before>": 200016,
|
| 9 |
+
"<commit_message>": 200040,
|
| 10 |
+
"<commit_msg>": 200017,
|
| 11 |
+
"<delete_file>": 200037,
|
| 12 |
+
"<edit_file>": 200039,
|
| 13 |
+
"<empty_output>": 200015,
|
| 14 |
+
"<empty_source_file>": 200041,
|
| 15 |
+
"<file_content>": 200044,
|
| 16 |
+
"<file_sep>": 200049,
|
| 17 |
+
"<filename>": 200006,
|
| 18 |
+
"<filepath>": 200048,
|
| 19 |
+
"<fim_middle>": 200002,
|
| 20 |
+
"<fim_pad>": 200004,
|
| 21 |
+
"<fim_prefix>": 200001,
|
| 22 |
+
"<fim_suffix>": 200003,
|
| 23 |
+
"<function_call>": 200022,
|
| 24 |
+
"<gh_stars>": 200007,
|
| 25 |
+
"<issue_closed>": 200010,
|
| 26 |
+
"<issue_comment>": 200009,
|
| 27 |
+
"<issue_start>": 200008,
|
| 28 |
+
"<jupyter_code>": 200013,
|
| 29 |
+
"<jupyter_error>": 200035,
|
| 30 |
+
"<jupyter_output>": 200014,
|
| 31 |
+
"<jupyter_start>": 200011,
|
| 32 |
+
"<jupyter_text>": 200012,
|
| 33 |
+
"<minimax:tool_call>": 200052,
|
| 34 |
+
"<pr_start>": 200046,
|
| 35 |
+
"<rename_file>": 200038,
|
| 36 |
+
"<repo_struct>": 200042,
|
| 37 |
+
"<reponame>": 200005,
|
| 38 |
+
"<review_comment>": 200047,
|
| 39 |
+
"<source_files>": 200045,
|
| 40 |
+
"<think>": 200050,
|
| 41 |
+
"[e~[": 200020,
|
| 42 |
+
"]!d~[": 200021,
|
| 43 |
+
"]!p~[": 200000,
|
| 44 |
+
"]<]end of image[>[": 200030,
|
| 45 |
+
"]<]end of speech[>[": 200028,
|
| 46 |
+
"]<]end of video[>[": 200032,
|
| 47 |
+
"]<]image[>[": 200025,
|
| 48 |
+
"]<]speech[>[": 200024,
|
| 49 |
+
"]<]start of image[>[": 200029,
|
| 50 |
+
"]<]start of speech[>[": 200027,
|
| 51 |
+
"]<]start of video[>[": 200031,
|
| 52 |
+
"]<]video[>[": 200026,
|
| 53 |
+
"]<]vision pad[>[": 200033,
|
| 54 |
+
"]~!b[": 200034,
|
| 55 |
+
"]~b]": 200019
|
| 56 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{# ----------‑‑‑ special token variables ‑‑‑---------- #}
|
| 2 |
+
{%- set toolcall_begin_token = '<minimax:tool_call>' -%}
|
| 3 |
+
{%- set toolcall_end_token = '</minimax:tool_call>' -%}
|
| 4 |
+
{#- Tool Rendering Functions ============================================== -#}
|
| 5 |
+
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
|
| 6 |
+
{%- for tool in tool_list -%}
|
| 7 |
+
<tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
|
| 8 |
+
{% endfor -%}
|
| 9 |
+
{%- endmacro -%}
|
| 10 |
+
{%- macro visible_text(content) -%}
|
| 11 |
+
{%- if content is string -%}
|
| 12 |
+
{{ content }}
|
| 13 |
+
{%- elif content is iterable and content is not mapping -%}
|
| 14 |
+
{%- for item in content -%}
|
| 15 |
+
{%- if item is mapping and item.type == 'text' -%}
|
| 16 |
+
{{- item.text }}
|
| 17 |
+
{%- elif item is string -%}
|
| 18 |
+
{{- item }}
|
| 19 |
+
{%- endif -%}
|
| 20 |
+
{%- endfor -%}
|
| 21 |
+
{%- elif content is none -%}
|
| 22 |
+
{{- '' }}
|
| 23 |
+
{%- else -%}
|
| 24 |
+
{{- content }}
|
| 25 |
+
{%- endif -%}
|
| 26 |
+
{%- endmacro -%}
|
| 27 |
+
{#- System Message Construction ============================================ -#}
|
| 28 |
+
{%- macro build_system_message(system_message) -%}
|
| 29 |
+
{%- if system_message and system_message.content -%}
|
| 30 |
+
{{- visible_text(system_message.content) }}
|
| 31 |
+
{%- else -%}
|
| 32 |
+
{%- if model_identity is not defined -%}
|
| 33 |
+
{%- set model_identity = "You are a helpful assistant. Your name is MiniMax-M2.1 and is built by MiniMax." -%}
|
| 34 |
+
{%- endif -%}
|
| 35 |
+
{{- model_identity }}
|
| 36 |
+
{%- endif -%}
|
| 37 |
+
|
| 38 |
+
{#- Handle current_date -#}
|
| 39 |
+
{%- if system_message and system_message.current_date -%}
|
| 40 |
+
{{- '\n' ~ 'Current date: ' + system_message.current_date }}
|
| 41 |
+
{%- endif -%}
|
| 42 |
+
{#- Handle current_location -#}
|
| 43 |
+
{%- if system_message and system_message.current_location -%}
|
| 44 |
+
{{- '\n' ~ 'Current location: ' + system_message.current_location }}
|
| 45 |
+
{%- endif -%}
|
| 46 |
+
{%- endmacro -%}
|
| 47 |
+
{#- Main Template Logic ================================================= -#}
|
| 48 |
+
{#- Extract system message (only first message if it's system) -#}
|
| 49 |
+
{%- set system_message = none -%}
|
| 50 |
+
{%- set conversation_messages = messages -%}
|
| 51 |
+
{%- if messages and messages[0].role == "system" -%}
|
| 52 |
+
{%- set system_message = messages[0] -%}
|
| 53 |
+
{%- set conversation_messages = messages[1:] -%}
|
| 54 |
+
{%- endif -%}
|
| 55 |
+
{#- Get the last user message turn, for interleved thinking -#}
|
| 56 |
+
{%- set ns = namespace(last_user_index=-1) %}
|
| 57 |
+
{% for m in conversation_messages %}
|
| 58 |
+
{%- if m.role == 'user' %}
|
| 59 |
+
{% set ns.last_user_index = loop.index0 -%}
|
| 60 |
+
{%- endif %}
|
| 61 |
+
{%- endfor %}
|
| 62 |
+
{#- Render system message -#}
|
| 63 |
+
{{- ']~!b[' ~ ']~b]system' ~ '\n' }}
|
| 64 |
+
{{- build_system_message(system_message) }}
|
| 65 |
+
{#- Render tools if available -#}
|
| 66 |
+
{%- if tools -%}
|
| 67 |
+
{{- '\n\n' ~ '# Tools' ~ '\n' ~ 'You may call one or more tools to assist with the user query.\nHere are the tools available in JSONSchema format:' ~ '\n' }}
|
| 68 |
+
{{- '\n' ~ '<tools>' ~ '\n' }}
|
| 69 |
+
{{- render_tool_namespace("functions", tools) }}
|
| 70 |
+
{{- '</tools>' ~ '\n\n' }}
|
| 71 |
+
{{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
|
| 72 |
+
{{- '\n' ~ toolcall_begin_token }}
|
| 73 |
+
<invoke name="tool-name-1">
|
| 74 |
+
<parameter name="param-key-1">param-value-1</parameter>
|
| 75 |
+
<parameter name="param-key-2">param-value-2</parameter>
|
| 76 |
+
...
|
| 77 |
+
</invoke>
|
| 78 |
+
{{- '\n' ~ toolcall_end_token }}
|
| 79 |
+
{%- endif -%}
|
| 80 |
+
{{- '[e~[\n' }}
|
| 81 |
+
|
| 82 |
+
{#- Render messages -#}
|
| 83 |
+
{%- set last_tool_call = namespace(name=none) -%}
|
| 84 |
+
{%- for message in conversation_messages -%}
|
| 85 |
+
{%- if message.role == 'assistant' -%}
|
| 86 |
+
{#- Only render reasoning_content if no user message follows -#}
|
| 87 |
+
{{- ']~b]ai' ~ '\n' }}
|
| 88 |
+
|
| 89 |
+
{%- set reasoning_content = '' %}
|
| 90 |
+
{%- set content = visible_text(message.content) %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].strip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- if reasoning_content and loop.index0 > ns.last_user_index -%}
|
| 100 |
+
{{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
|
| 101 |
+
{%- endif -%}
|
| 102 |
+
{%- if content -%}
|
| 103 |
+
{{- content }}
|
| 104 |
+
{%- endif -%}
|
| 105 |
+
{%- if message.tool_calls -%}
|
| 106 |
+
{{- '\n' ~ toolcall_begin_token ~ '\n' }}
|
| 107 |
+
|
| 108 |
+
{%- for tool_call in message.tool_calls -%}
|
| 109 |
+
{%- if tool_call.function %}
|
| 110 |
+
{%- set tool_call = tool_call.function %}
|
| 111 |
+
{%- endif %}
|
| 112 |
+
{{- '<invoke name="' + tool_call.name + '">' }}
|
| 113 |
+
{% set _args = tool_call.arguments %}
|
| 114 |
+
{%- for k, v in _args.items() %}
|
| 115 |
+
{{- '<parameter name="' + k + '">' }}
|
| 116 |
+
{{- v | tojson(ensure_ascii=False) if v is not string else v }}
|
| 117 |
+
{{- '</parameter>' }}
|
| 118 |
+
{% endfor %}
|
| 119 |
+
{{- '</invoke>' ~ '\n' }}
|
| 120 |
+
{%- endfor -%}
|
| 121 |
+
|
| 122 |
+
{{- toolcall_end_token}}
|
| 123 |
+
{%- if message.tool_calls[-1].function -%}
|
| 124 |
+
{%- set last_tool_call.name = message.tool_calls[-1].function.name -%}
|
| 125 |
+
{%- else -%}
|
| 126 |
+
{%- set last_tool_call.name = message.tool_calls[-1].name -%}
|
| 127 |
+
{%- endif -%}
|
| 128 |
+
{%- else -%}
|
| 129 |
+
{%- set last_tool_call.name = none -%}
|
| 130 |
+
{%- endif -%}
|
| 131 |
+
{{- '[e~[' ~ '\n' }}
|
| 132 |
+
|
| 133 |
+
{%- elif message.role == 'tool' -%}
|
| 134 |
+
{%- if last_tool_call.name is none -%}
|
| 135 |
+
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
|
| 136 |
+
{%- endif -%}
|
| 137 |
+
{%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
|
| 138 |
+
{{- ']~b]tool' }}
|
| 139 |
+
{%- endif -%}
|
| 140 |
+
{%- if message.content is string -%}
|
| 141 |
+
{{- '\n<response>' }}
|
| 142 |
+
{{- message.content }}
|
| 143 |
+
{{- '</response>' }}
|
| 144 |
+
{%- else -%}
|
| 145 |
+
{%- for tr in message.content -%}
|
| 146 |
+
{{- '\n<response>' }}
|
| 147 |
+
{{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
|
| 148 |
+
{{- '\n</response>' }}
|
| 149 |
+
{%- endfor -%}
|
| 150 |
+
{%- endif -%}
|
| 151 |
+
{%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
|
| 152 |
+
{{- '[e~[\n' -}}
|
| 153 |
+
{%- endif -%}
|
| 154 |
+
|
| 155 |
+
{%- elif message.role == 'user' -%}
|
| 156 |
+
{{- ']~b]user' ~ '\n' }}
|
| 157 |
+
{{- visible_text(message.content) }}
|
| 158 |
+
{{- '[e~[' ~ '\n' }}
|
| 159 |
+
{%- endif -%}
|
| 160 |
+
{%- endfor -%}
|
| 161 |
+
|
| 162 |
+
{#- Generation prompt -#}
|
| 163 |
+
{%- if add_generation_prompt -%}
|
| 164 |
+
{{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
|
| 165 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MiniMaxM2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attn_type_list": [
|
| 6 |
+
1,
|
| 7 |
+
1,
|
| 8 |
+
1,
|
| 9 |
+
1,
|
| 10 |
+
1,
|
| 11 |
+
1,
|
| 12 |
+
1,
|
| 13 |
+
1,
|
| 14 |
+
1,
|
| 15 |
+
1,
|
| 16 |
+
1,
|
| 17 |
+
1,
|
| 18 |
+
1,
|
| 19 |
+
1,
|
| 20 |
+
1,
|
| 21 |
+
1,
|
| 22 |
+
1,
|
| 23 |
+
1,
|
| 24 |
+
1,
|
| 25 |
+
1,
|
| 26 |
+
1,
|
| 27 |
+
1,
|
| 28 |
+
1,
|
| 29 |
+
1,
|
| 30 |
+
1,
|
| 31 |
+
1,
|
| 32 |
+
1,
|
| 33 |
+
1,
|
| 34 |
+
1,
|
| 35 |
+
1,
|
| 36 |
+
1,
|
| 37 |
+
1,
|
| 38 |
+
1,
|
| 39 |
+
1,
|
| 40 |
+
1,
|
| 41 |
+
1,
|
| 42 |
+
1,
|
| 43 |
+
1,
|
| 44 |
+
1,
|
| 45 |
+
1,
|
| 46 |
+
1,
|
| 47 |
+
1,
|
| 48 |
+
1,
|
| 49 |
+
1,
|
| 50 |
+
1,
|
| 51 |
+
1,
|
| 52 |
+
1,
|
| 53 |
+
1,
|
| 54 |
+
1,
|
| 55 |
+
1,
|
| 56 |
+
1,
|
| 57 |
+
1,
|
| 58 |
+
1,
|
| 59 |
+
1,
|
| 60 |
+
1,
|
| 61 |
+
1,
|
| 62 |
+
1,
|
| 63 |
+
1,
|
| 64 |
+
1,
|
| 65 |
+
1,
|
| 66 |
+
1,
|
| 67 |
+
1
|
| 68 |
+
],
|
| 69 |
+
"auto_map": {
|
| 70 |
+
"AutoConfig": "configuration_minimax_m2.MiniMaxM2Config",
|
| 71 |
+
"AutoModelForCausalLM": "modeling_minimax_m2.MiniMaxM2ForCausalLM"
|
| 72 |
+
},
|
| 73 |
+
"head_dim": 128,
|
| 74 |
+
"hidden_act": "silu",
|
| 75 |
+
"hidden_size": 3072,
|
| 76 |
+
"intermediate_size": 1536,
|
| 77 |
+
"max_position_embeddings": 196608,
|
| 78 |
+
"model_type": "minimax_m2",
|
| 79 |
+
"mtp_transformer_layers": 1,
|
| 80 |
+
"num_attention_heads": 48,
|
| 81 |
+
"num_experts_per_tok": 8,
|
| 82 |
+
"num_hidden_layers": 62,
|
| 83 |
+
"num_key_value_heads": 8,
|
| 84 |
+
"num_local_experts": 256,
|
| 85 |
+
"num_mtp_modules": 3,
|
| 86 |
+
"qk_norm_type": "per_layer",
|
| 87 |
+
"quantization_config": {
|
| 88 |
+
"quant_method": "compressed-tensors",
|
| 89 |
+
"format": "mixed-precision",
|
| 90 |
+
"quantization_status": "compressed",
|
| 91 |
+
"config_groups": {
|
| 92 |
+
"group_0": {
|
| 93 |
+
"targets": [
|
| 94 |
+
"Linear",
|
| 95 |
+
"re:.*self_attn\\.(k|q|o|v)_proj$",
|
| 96 |
+
"re:.*self_attn\\.qkv_proj$"
|
| 97 |
+
],
|
| 98 |
+
"weights": {
|
| 99 |
+
"type": "float",
|
| 100 |
+
"num_bits": 8,
|
| 101 |
+
"strategy": "block",
|
| 102 |
+
"block_structure": [
|
| 103 |
+
128,
|
| 104 |
+
128
|
| 105 |
+
],
|
| 106 |
+
"symmetric": true,
|
| 107 |
+
"dynamic": false
|
| 108 |
+
},
|
| 109 |
+
"input_activations": {
|
| 110 |
+
"type": "float",
|
| 111 |
+
"num_bits": 8,
|
| 112 |
+
"strategy": "token",
|
| 113 |
+
"symmetric": true,
|
| 114 |
+
"dynamic": true
|
| 115 |
+
},
|
| 116 |
+
"format": "float-quantized"
|
| 117 |
+
},
|
| 118 |
+
"group_1": {
|
| 119 |
+
"format": "pack-quantized",
|
| 120 |
+
"input_activations": null,
|
| 121 |
+
"output_activations": null,
|
| 122 |
+
"targets": [
|
| 123 |
+
"Linear",
|
| 124 |
+
"re:.*block_sparse_moe\\.experts\\.\\d+\\.(w1|w2|w3)$"
|
| 125 |
+
],
|
| 126 |
+
"weights": {
|
| 127 |
+
"actorder": null,
|
| 128 |
+
"block_structure": null,
|
| 129 |
+
"dynamic": false,
|
| 130 |
+
"group_size": 32,
|
| 131 |
+
"num_bits": 4,
|
| 132 |
+
"observer": "minmax",
|
| 133 |
+
"observer_kwargs": {},
|
| 134 |
+
"strategy": "group",
|
| 135 |
+
"symmetric": true,
|
| 136 |
+
"type": "int"
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
},
|
| 140 |
+
"ignore": [
|
| 141 |
+
"model.layers.0.block_sparse_moe.gate",
|
| 142 |
+
"model.layers.1.block_sparse_moe.gate",
|
| 143 |
+
"model.layers.2.block_sparse_moe.gate",
|
| 144 |
+
"model.layers.3.block_sparse_moe.gate",
|
| 145 |
+
"model.layers.4.block_sparse_moe.gate",
|
| 146 |
+
"model.layers.5.block_sparse_moe.gate",
|
| 147 |
+
"model.layers.6.block_sparse_moe.gate",
|
| 148 |
+
"model.layers.7.block_sparse_moe.gate",
|
| 149 |
+
"model.layers.8.block_sparse_moe.gate",
|
| 150 |
+
"model.layers.9.block_sparse_moe.gate",
|
| 151 |
+
"model.layers.10.block_sparse_moe.gate",
|
| 152 |
+
"model.layers.11.block_sparse_moe.gate",
|
| 153 |
+
"model.layers.12.block_sparse_moe.gate",
|
| 154 |
+
"model.layers.13.block_sparse_moe.gate",
|
| 155 |
+
"model.layers.14.block_sparse_moe.gate",
|
| 156 |
+
"model.layers.15.block_sparse_moe.gate",
|
| 157 |
+
"model.layers.16.block_sparse_moe.gate",
|
| 158 |
+
"model.layers.17.block_sparse_moe.gate",
|
| 159 |
+
"model.layers.18.block_sparse_moe.gate",
|
| 160 |
+
"model.layers.19.block_sparse_moe.gate",
|
| 161 |
+
"model.layers.20.block_sparse_moe.gate",
|
| 162 |
+
"model.layers.21.block_sparse_moe.gate",
|
| 163 |
+
"model.layers.22.block_sparse_moe.gate",
|
| 164 |
+
"model.layers.23.block_sparse_moe.gate",
|
| 165 |
+
"model.layers.24.block_sparse_moe.gate",
|
| 166 |
+
"model.layers.25.block_sparse_moe.gate",
|
| 167 |
+
"model.layers.26.block_sparse_moe.gate",
|
| 168 |
+
"model.layers.27.block_sparse_moe.gate",
|
| 169 |
+
"model.layers.28.block_sparse_moe.gate",
|
| 170 |
+
"model.layers.29.block_sparse_moe.gate",
|
| 171 |
+
"model.layers.30.block_sparse_moe.gate",
|
| 172 |
+
"model.layers.31.block_sparse_moe.gate",
|
| 173 |
+
"model.layers.32.block_sparse_moe.gate",
|
| 174 |
+
"model.layers.33.block_sparse_moe.gate",
|
| 175 |
+
"model.layers.34.block_sparse_moe.gate",
|
| 176 |
+
"model.layers.35.block_sparse_moe.gate",
|
| 177 |
+
"model.layers.36.block_sparse_moe.gate",
|
| 178 |
+
"model.layers.37.block_sparse_moe.gate",
|
| 179 |
+
"model.layers.38.block_sparse_moe.gate",
|
| 180 |
+
"model.layers.39.block_sparse_moe.gate",
|
| 181 |
+
"model.layers.40.block_sparse_moe.gate",
|
| 182 |
+
"model.layers.41.block_sparse_moe.gate",
|
| 183 |
+
"model.layers.42.block_sparse_moe.gate",
|
| 184 |
+
"model.layers.43.block_sparse_moe.gate",
|
| 185 |
+
"model.layers.44.block_sparse_moe.gate",
|
| 186 |
+
"model.layers.45.block_sparse_moe.gate",
|
| 187 |
+
"model.layers.46.block_sparse_moe.gate",
|
| 188 |
+
"model.layers.47.block_sparse_moe.gate",
|
| 189 |
+
"model.layers.48.block_sparse_moe.gate",
|
| 190 |
+
"model.layers.49.block_sparse_moe.gate",
|
| 191 |
+
"model.layers.50.block_sparse_moe.gate",
|
| 192 |
+
"model.layers.51.block_sparse_moe.gate",
|
| 193 |
+
"model.layers.52.block_sparse_moe.gate",
|
| 194 |
+
"model.layers.53.block_sparse_moe.gate",
|
| 195 |
+
"model.layers.54.block_sparse_moe.gate",
|
| 196 |
+
"model.layers.55.block_sparse_moe.gate",
|
| 197 |
+
"model.layers.56.block_sparse_moe.gate",
|
| 198 |
+
"model.layers.57.block_sparse_moe.gate",
|
| 199 |
+
"model.layers.58.block_sparse_moe.gate",
|
| 200 |
+
"model.layers.59.block_sparse_moe.gate",
|
| 201 |
+
"model.layers.60.block_sparse_moe.gate",
|
| 202 |
+
"model.layers.61.block_sparse_moe.gate",
|
| 203 |
+
"lm_head"
|
| 204 |
+
],
|
| 205 |
+
"kv_cache_scheme": null,
|
| 206 |
+
"global_compression_ratio": null,
|
| 207 |
+
"sparsity_config": {},
|
| 208 |
+
"transform_config": {},
|
| 209 |
+
"version": "0.13.1.dev0+g797d301.d20251228"
|
| 210 |
+
},
|
| 211 |
+
"rms_norm_eps": 1e-06,
|
| 212 |
+
"rope_theta": 5000000,
|
| 213 |
+
"rotary_dim": 64,
|
| 214 |
+
"scoring_func": "sigmoid",
|
| 215 |
+
"shared_intermediate_size": 0,
|
| 216 |
+
"tie_word_embeddings": false,
|
| 217 |
+
"transformers_version": "4.46.1",
|
| 218 |
+
"use_cache": true,
|
| 219 |
+
"use_mtp": true,
|
| 220 |
+
"use_qk_norm": true,
|
| 221 |
+
"use_routing_bias": true,
|
| 222 |
+
"vocab_size": 200064
|
| 223 |
+
}
|
configuration_minimax_m2.py
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/minimax_m2/modular_minimax_m2.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_minimax_m2.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 the HuggingFace Team. All rights reserved.
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class MiniMaxM2Config(PretrainedConfig):
|
| 27 |
+
r"""
|
| 28 |
+
This is the configuration class to store the configuration of a [`MiniMaxM2Model`]. It is used to instantiate an
|
| 29 |
+
MiniMaxM2 model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 30 |
+
with the defaults will yield a similar configuration to that of the MiniMaxM2-7B-v0.1 or MiniMaxM2-7B-Instruct-v0.1.
|
| 31 |
+
|
| 32 |
+
[minimax_m2ai/MiniMaxM2-8x7B](https://huggingface.co/minimax_m2ai/MiniMaxM2-8x7B)
|
| 33 |
+
[minimax_m2ai/MiniMaxM2-7B-Instruct-v0.1](https://huggingface.co/minimax_m2ai/MiniMaxM2-7B-Instruct-v0.1)
|
| 34 |
+
|
| 35 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 36 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
Args:
|
| 40 |
+
vocab_size (`int`, *optional*, defaults to 32000):
|
| 41 |
+
Vocabulary size of the MiniMaxM2 model. Defines the number of different tokens that can be represented by the
|
| 42 |
+
`inputs_ids` passed when calling [`MiniMaxM2Model`]
|
| 43 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 44 |
+
Dimension of the hidden representations.
|
| 45 |
+
intermediate_size (`int`, *optional*, defaults to 14336):
|
| 46 |
+
Dimension of the MLP representations.
|
| 47 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 48 |
+
Number of hidden layers in the Transformer encoder.
|
| 49 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 50 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 51 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
| 52 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 53 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 54 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 55 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 56 |
+
by meanpooling all the original heads within that group. For more details, check out [this
|
| 57 |
+
paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `8`.
|
| 58 |
+
head_dim (`int`, *optional*, defaults to `hidden_size // num_attention_heads`):
|
| 59 |
+
The attention head dimension.
|
| 60 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 61 |
+
The non-linear activation function (function or string) in the decoder.
|
| 62 |
+
max_position_embeddings (`int`, *optional*, defaults to `4096*32`):
|
| 63 |
+
The maximum sequence length that this model might ever be used with. MiniMaxM2's sliding window attention
|
| 64 |
+
allows sequence of up to 4096*32 tokens.
|
| 65 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 66 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 67 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-05):
|
| 68 |
+
The epsilon used by the rms normalization layers.
|
| 69 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 70 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 71 |
+
relevant if `config.is_decoder=True`.
|
| 72 |
+
pad_token_id (`int`, *optional*):
|
| 73 |
+
The id of the padding token.
|
| 74 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
| 75 |
+
The id of the "beginning-of-sequence" token.
|
| 76 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
| 77 |
+
The id of the "end-of-sequence" token.
|
| 78 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 79 |
+
Whether the model's input and output word embeddings should be tied.
|
| 80 |
+
rope_theta (`float`, *optional*, defaults to 1000000.0):
|
| 81 |
+
The base period of the RoPE embeddings.
|
| 82 |
+
sliding_window (`int`, *optional*):
|
| 83 |
+
Sliding window attention window size. If not specified, will default to `4096`.
|
| 84 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 85 |
+
The dropout ratio for the attention probabilities.
|
| 86 |
+
num_experts_per_tok (`int`, *optional*, defaults to 2):
|
| 87 |
+
The number of experts to route per-token, can be also interpreted as the `top-k` routing
|
| 88 |
+
parameter
|
| 89 |
+
num_local_experts (`int`, *optional*, defaults to 8):
|
| 90 |
+
Number of experts per Sparse MLP layer.
|
| 91 |
+
output_router_logits (`bool`, *optional*, defaults to `False`):
|
| 92 |
+
Whether or not the router logits should be returned by the model. Enabling this will also
|
| 93 |
+
allow the model to output the auxiliary loss. See [here]() for more details
|
| 94 |
+
router_aux_loss_coef (`float`, *optional*, defaults to 0.001):
|
| 95 |
+
The aux loss factor for the total loss.
|
| 96 |
+
router_jitter_noise (`float`, *optional*, defaults to 0.0):
|
| 97 |
+
Amount of noise to add to the router.
|
| 98 |
+
|
| 99 |
+
```python
|
| 100 |
+
>>> from transformers import MiniMaxM2Model, MiniMaxM2Config
|
| 101 |
+
|
| 102 |
+
>>> # Initializing a MiniMaxM2 7B style configuration
|
| 103 |
+
>>> configuration = MiniMaxM2Config()
|
| 104 |
+
|
| 105 |
+
>>> # Initializing a model from the MiniMaxM2 7B style configuration
|
| 106 |
+
>>> model = MiniMaxM2Model(configuration)
|
| 107 |
+
|
| 108 |
+
>>> # Accessing the model configuration
|
| 109 |
+
>>> configuration = model.config
|
| 110 |
+
```"""
|
| 111 |
+
|
| 112 |
+
model_type = "minimax_m2"
|
| 113 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 114 |
+
base_model_tp_plan = {
|
| 115 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 116 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 117 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 118 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 119 |
+
"layers.*.block_sparse_moe.gate": "colwise_rep", # we need to replicate here to correctly route experts
|
| 120 |
+
"layers.*.block_sparse_moe.experts.*.w1": "colwise",
|
| 121 |
+
"layers.*.block_sparse_moe.experts.*.w2": "rowwise",
|
| 122 |
+
"layers.*.block_sparse_moe.experts.*.w3": "colwise",
|
| 123 |
+
}
|
| 124 |
+
base_model_pp_plan = {
|
| 125 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 126 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 127 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
def __init__(
|
| 131 |
+
self,
|
| 132 |
+
vocab_size=32000,
|
| 133 |
+
hidden_size=4096,
|
| 134 |
+
intermediate_size=14336,
|
| 135 |
+
num_hidden_layers=32,
|
| 136 |
+
num_attention_heads=32,
|
| 137 |
+
num_key_value_heads=8,
|
| 138 |
+
head_dim=None,
|
| 139 |
+
hidden_act="silu",
|
| 140 |
+
max_position_embeddings=4096 * 32,
|
| 141 |
+
initializer_range=0.02,
|
| 142 |
+
rms_norm_eps=1e-5,
|
| 143 |
+
use_cache=True,
|
| 144 |
+
pad_token_id=None,
|
| 145 |
+
bos_token_id=1,
|
| 146 |
+
eos_token_id=2,
|
| 147 |
+
tie_word_embeddings=False,
|
| 148 |
+
rope_theta=1e6,
|
| 149 |
+
sliding_window=None,
|
| 150 |
+
attention_dropout=0.0,
|
| 151 |
+
num_experts_per_tok=2,
|
| 152 |
+
num_local_experts=8,
|
| 153 |
+
output_router_logits=False,
|
| 154 |
+
router_aux_loss_coef=0.001,
|
| 155 |
+
router_jitter_noise=0.0,
|
| 156 |
+
**kwargs,
|
| 157 |
+
):
|
| 158 |
+
self.vocab_size = vocab_size
|
| 159 |
+
self.max_position_embeddings = max_position_embeddings
|
| 160 |
+
self.hidden_size = hidden_size
|
| 161 |
+
self.intermediate_size = intermediate_size
|
| 162 |
+
self.num_hidden_layers = num_hidden_layers
|
| 163 |
+
self.num_attention_heads = num_attention_heads
|
| 164 |
+
self.sliding_window = sliding_window
|
| 165 |
+
|
| 166 |
+
# for backward compatibility
|
| 167 |
+
if num_key_value_heads is None:
|
| 168 |
+
num_key_value_heads = num_attention_heads
|
| 169 |
+
|
| 170 |
+
self.num_key_value_heads = num_key_value_heads
|
| 171 |
+
self.hidden_act = hidden_act
|
| 172 |
+
self.initializer_range = initializer_range
|
| 173 |
+
self.rms_norm_eps = rms_norm_eps
|
| 174 |
+
self.use_cache = use_cache
|
| 175 |
+
self.rope_theta = rope_theta
|
| 176 |
+
self.attention_dropout = attention_dropout
|
| 177 |
+
self.head_dim = head_dim
|
| 178 |
+
|
| 179 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 180 |
+
self.num_local_experts = num_local_experts
|
| 181 |
+
self.output_router_logits = output_router_logits
|
| 182 |
+
self.router_aux_loss_coef = router_aux_loss_coef
|
| 183 |
+
self.router_jitter_noise = router_jitter_noise
|
| 184 |
+
|
| 185 |
+
self.use_qk_norm = kwargs.pop("use_qk_norm", False)
|
| 186 |
+
self.rotary_dim = kwargs.pop("rotary_dim", self.head_dim)
|
| 187 |
+
self.partial_rotary_factor = kwargs.pop("partial_rotary_factor", 1)
|
| 188 |
+
if self.head_dim is not None:
|
| 189 |
+
self.partial_rotary_factor = self.rotary_dim / self.head_dim
|
| 190 |
+
|
| 191 |
+
super().__init__(
|
| 192 |
+
pad_token_id=pad_token_id,
|
| 193 |
+
bos_token_id=bos_token_id,
|
| 194 |
+
eos_token_id=eos_token_id,
|
| 195 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 196 |
+
**kwargs,
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
def __repr__(self):
|
| 200 |
+
"""
|
| 201 |
+
Overriding __repr__ to ensure that quantization_config does not contain Enum objects.
|
| 202 |
+
This prevents SyntaxError in torch.fx generated code which relies on repr() of the config.
|
| 203 |
+
"""
|
| 204 |
+
print("Config sanitized in configuration_minimax_m2.py")
|
| 205 |
+
q_config = getattr(self, "quantization_config", None)
|
| 206 |
+
if isinstance(q_config, dict):
|
| 207 |
+
for k, v in list(q_config.items()):
|
| 208 |
+
if hasattr(v, "value"):
|
| 209 |
+
# Replace Enum with its value
|
| 210 |
+
q_config[k] = v.value
|
| 211 |
+
print(f" Enum: q_config[{k}] = {v.value}")
|
| 212 |
+
return super().__repr__()
|
| 213 |
+
|
| 214 |
+
__all__ = ["MiniMaxM2Config"]
|
generation_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 200019,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": 200020,
|
| 5 |
+
"top_k": 40,
|
| 6 |
+
"top_p": 0.95,
|
| 7 |
+
"transformers_version": "4.57.3"
|
| 8 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00000-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bdb9b6d02da44140a22e421b4bc4a958874836181e5251522f0eb19c5056fe58
|
| 3 |
+
size 2635579896
|
model-00001-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62b2739ac4eb4978f54fdd4fe534c6be206aeeeb05b8e4c53d4177096bf48d87
|
| 3 |
+
size 679579608
|
model-00002-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b13cb97fc90f3eaa3244b5e7001480fc8f2aeba820db41f5b00e2310cfb9af4c
|
| 3 |
+
size 1406386576
|
model-00003-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c05cb968e8d223efabce0d4d7032d1fa5eeabb8eb524cfdc6541971342fe5cfe
|
| 3 |
+
size 679579608
|
model-00004-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:142bafcc2ecbac83d191831d7f76f14582d6bdd927c6a6a4850ce99712a0a7e6
|
| 3 |
+
size 1406386576
|
model-00005-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:978284cf5ef0d43142bb5aca2d4265aa88dbbb19b85d4a375716431bc4e44bd3
|
| 3 |
+
size 679579608
|
model-00006-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ebf3b3479856a2c6e2063ff28ad670e42fbafb18da83783d6badfa19a9a3a860
|
| 3 |
+
size 1406386576
|
model-00007-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:993efeb0903c076600c4181d1c761cc6890a29420eef09e315b7050855fb54fd
|
| 3 |
+
size 679579608
|
model-00008-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d89a59fcb6b68132774f4b91470d3d07b3c5be83ab335eefd276a7e82a5047fd
|
| 3 |
+
size 1406386576
|
model-00009-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8759476d8bd4dd162e513c522f8af6449885bc180023b86d5e4a8a74be970ec5
|
| 3 |
+
size 679579608
|
model-00010-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f79cb22c4d59dc0d3ec02832529bec1129d2010acda34821b97d42ad1e65c77
|
| 3 |
+
size 1406386576
|
model-00011-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:865696447cec428da2cdc63ad3edbe1f1f91d15a3ae8d524a07ccc919cafe484
|
| 3 |
+
size 679579608
|
model-00012-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae5004d60ef7bebf9369a0c840b423d77ba081e4d134d7887fd6ae9ea183ba75
|
| 3 |
+
size 1406386576
|
model-00013-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e546a597795380ef9c181f6aa84126b45beb46bd7701d4188cafa172d65fb8e6
|
| 3 |
+
size 679579608
|
model-00014-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a87fba65c6d953987cc3ff550fa063715fba20cd7c43c5bf21bf0f456c6d351
|
| 3 |
+
size 1406386576
|
model-00015-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e313401b649f4c02a3b21b3037132384ecc2350889272e99d8ef02d7b5b9c1cb
|
| 3 |
+
size 679579608
|
model-00016-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67a9bf695a3eca2c50d3d34faa2cccf6e1491b364dac9436697eaf628bdd9572
|
| 3 |
+
size 1406386576
|
model-00017-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3568bfc90163e3ad507946611bcdce8d5a1813a428bc3c8991d8c158df8a1e82
|
| 3 |
+
size 679579608
|
model-00018-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:721656b73c52e06052a3d4bce67fdb95319471e67f49db7f72dc82d8ffd56d75
|
| 3 |
+
size 1406386576
|
model-00019-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19c5d36dc72b1424c2666a1ba99a3751241e9922ee79df8996b4eb55eff4b86f
|
| 3 |
+
size 679579608
|
model-00020-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f069ef068a89e6cfe46a8fb446252b1608ee43c0936a8d3d8f2ace3323e825d
|
| 3 |
+
size 1406388128
|
model-00021-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b6e2a1c5d6288cf1f3b3ed038e46bd4137a4ed250f4f956d668131b2fccfcbf2
|
| 3 |
+
size 679580376
|
model-00022-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:495dc76bb04bc23a7f4fdc038841412582a9d9a9d45439bea19c6a22eca3327c
|
| 3 |
+
size 1406388128
|
model-00023-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7f5f8d0af589df58f737218b790a45d0d6eb3d8198b0e69814bae1e5c0c58f9
|
| 3 |
+
size 679580376
|
model-00024-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d1a21f6150ff68ce9fae443648d669ad988681613f641e6c845595bbc857ad3b
|
| 3 |
+
size 1406388128
|
model-00025-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1538382239e15bd07588bf67b44151055041e429c57c06936b3d3c70af9157bc
|
| 3 |
+
size 679580376
|
model-00026-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2bad2b9c05ddc717cb370f01438eda5f052ce0e2dc7b4b0e016500af0681a074
|
| 3 |
+
size 1406388128
|
model-00027-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba134558371bd18532abb8cd7496d10e9aec4afb24eef4628176f52d86ed9435
|
| 3 |
+
size 679580376
|
model-00028-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b806437a67a0cf3b47ef809591c0f82a31725db6db8a97ac71cda3eb3034ea15
|
| 3 |
+
size 1406388128
|
model-00029-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed6c0f9b6e3d407ea64d98cdd19112385bf0323a20518f279cc641309c4fea82
|
| 3 |
+
size 679580376
|
model-00030-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4609bfa4bde5c727850f1db88d8d9eb323cd9da4865e81232ed752ac7232f0f1
|
| 3 |
+
size 1406388128
|
model-00031-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d209e93c55fb8708befa0e208d74ed32c2e4f051b68ff84df90e30e218c9db2
|
| 3 |
+
size 679580376
|
model-00032-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d553d47dcac41b17e20a78519f6cb80a8801ec878ffdcae24b10fec879ae8a96
|
| 3 |
+
size 1406388128
|
model-00033-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41af174c967f5e2773bacad3b530b79665b10f26e1ff5d5b97e3aab7ce3ae6f0
|
| 3 |
+
size 679580376
|
model-00034-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07dd4c3b3541bbe7d5f74c96cacdac36043e1ce8d53bf9a0719ac15ee7a988bd
|
| 3 |
+
size 1406388128
|
model-00035-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62eabe5a12b54b6056edf096df6bcecda8e17af00e9cc1eb79170a24c92822c3
|
| 3 |
+
size 679580376
|
model-00036-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a32b42bb61cf3ac2ab3a1370ff3341bd9249f228de4c22a0fe2816a7ba0af93f
|
| 3 |
+
size 1406388128
|
model-00037-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f63260140d6f5bff42c333b9b178fadae496c50abb1b84c60cd341490b832f3
|
| 3 |
+
size 679580376
|
model-00038-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1f68c9d67383106bc82c013e7fececfbbfde8e806cd651771bd08f87835ad421
|
| 3 |
+
size 1406388128
|
model-00039-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c11c712a761ebf5e873284f450407ac538641fc27e6827638a990cdbab45112c
|
| 3 |
+
size 679580376
|
model-00040-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c62502ae6fbaaf20bd79179b9951afd8b9caab7a4ccc94efa4fbb4f61b46ea28
|
| 3 |
+
size 1406388128
|
model-00041-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d185d5b2cf8536c499c7c06888b905f56f3338c84f55825da050184597cbe1f
|
| 3 |
+
size 679580376
|
model-00042-of-00125.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98b38a479f4a0818e2955d50df7e332051458ef040eae68b74c9a48175a89b4e
|
| 3 |
+
size 1406388128
|