Text Generation
Transformers
Safetensors
minimax_m2
mxfp4
quantized
Mixture of Experts
compressed-tensors
conversational
custom_code
8-bit precision
Instructions to use olka-fi/MiniMax-M2.7-MXFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use olka-fi/MiniMax-M2.7-MXFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="olka-fi/MiniMax-M2.7-MXFP4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("olka-fi/MiniMax-M2.7-MXFP4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("olka-fi/MiniMax-M2.7-MXFP4", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use olka-fi/MiniMax-M2.7-MXFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "olka-fi/MiniMax-M2.7-MXFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "olka-fi/MiniMax-M2.7-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/olka-fi/MiniMax-M2.7-MXFP4
- SGLang
How to use olka-fi/MiniMax-M2.7-MXFP4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "olka-fi/MiniMax-M2.7-MXFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "olka-fi/MiniMax-M2.7-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "olka-fi/MiniMax-M2.7-MXFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "olka-fi/MiniMax-M2.7-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use olka-fi/MiniMax-M2.7-MXFP4 with Docker Model Runner:
docker model run hf.co/olka-fi/MiniMax-M2.7-MXFP4
Add files using upload-large-folder tool
Browse files- .gitattributes +5 -0
- LICENSE +17 -0
- README.md +86 -0
- chat_template.jinja +159 -0
- config.json +681 -0
- configuration_minimax_m2.py +200 -0
- eval_minimax_m27.png +3 -0
- generation_config.json +9 -0
- merges.txt +0 -0
- model-00006-of-00130.safetensors +3 -0
- model-00017-of-00130.safetensors +3 -0
- model-00023-of-00130.safetensors +3 -0
- model-00025-of-00130.safetensors +3 -0
- model-00029-of-00130.safetensors +3 -0
- model-00031-of-00130.safetensors +3 -0
- model-00035-of-00130.safetensors +3 -0
- model-00040-of-00130.safetensors +3 -0
- model-00041-of-00130.safetensors +3 -0
- model-00042-of-00130.safetensors +3 -0
- model-00043-of-00130.safetensors +3 -0
- model-00047-of-00130.safetensors +3 -0
- model-00054-of-00130.safetensors +3 -0
- model-00068-of-00130.safetensors +3 -0
- model-00069-of-00130.safetensors +3 -0
- model-00072-of-00130.safetensors +3 -0
- model-00076-of-00130.safetensors +3 -0
- model-00080-of-00130.safetensors +3 -0
- model-00081-of-00130.safetensors +3 -0
- model-00082-of-00130.safetensors +3 -0
- model-00087-of-00130.safetensors +3 -0
- model-00088-of-00130.safetensors +3 -0
- model-00089-of-00130.safetensors +3 -0
- model-00093-of-00130.safetensors +3 -0
- model-00097-of-00130.safetensors +3 -0
- model-00100-of-00130.safetensors +3 -0
- model-00102-of-00130.safetensors +3 -0
- model-00103-of-00130.safetensors +3 -0
- model-00104-of-00130.safetensors +3 -0
- model-00109-of-00130.safetensors +3 -0
- model-00113-of-00130.safetensors +3 -0
- model-00114-of-00130.safetensors +3 -0
- model-00116-of-00130.safetensors +3 -0
- model-00118-of-00130.safetensors +3 -0
- model-00120-of-00130.safetensors +3 -0
- model-00121-of-00130.safetensors +3 -0
- model.safetensors.index.json +0 -0
- modeling_minimax_m2.py +706 -0
- tokenizer.json +0 -0
- tokenizer_config.json +495 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,8 @@ 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 |
+
figures/agent_harness.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
figures/agent_teams.gif filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
figures/banner.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
figures/mle_bench.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
eval_minimax_m27.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NON-COMMERCIAL LICENSE
|
| 2 |
+
Non-commercial use permitted based on MIT-style terms; commercial use requires prior written authorization.
|
| 3 |
+
Copyright (c) 2026 MiniMax
|
| 4 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software for non-commercial purposes, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or provide copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 5 |
+
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
2. If the Software (or any derivative works thereof) is used for any Commercial Use, you shall prominently display "Built with MiniMax M2.7" on a related website, user interface, blogpost, about page or product documentation.
|
| 7 |
+
3. Any Commercial Use of the Software or any derivative work thereof is prohibited without obtaining a separate, prior written authorization from MiniMax. To request such authorization, please contact api@minimax.io with the subject line "M2.7 licensing".
|
| 8 |
+
4. "Commercial Use" means any use of the Software or any derivative work thereof that is primarily intended for commercial advantage or monetary compensation, which includes, without limitation: (i) offering products or services to third parties for a fee, which utilize, incorporate, or rely on the Software or its derivatives, (ii) the commercial use of APIs provided by or for the Software or its derivatives, including to support or enable commercial products, services, or operations, whether in a cloud-based, hosted, or other similar environment, and (iii) the deployment or provision of the Software or its derivatives that have been subjected to post-training, fine-tuning, instruction-tuning, or any other form of modification, for any commercial purpose.
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 10 |
+
|
| 11 |
+
Appendix: Prohibited Uses
|
| 12 |
+
You agree you will not use, or allow others to use, the Software or any derivatives of the Software to:
|
| 13 |
+
1. Generate or disseminate content prohibited by applicable laws or regulations.
|
| 14 |
+
2. Assist with, engage in or otherwise support any military purpose.
|
| 15 |
+
3. Exploit, harm, or attempt to exploit or harm minors.
|
| 16 |
+
4. Generate or disseminate false or misleading information with the intent to cause harm.
|
| 17 |
+
5. Promote discrimination, hate speech, or harmful behavior against individuals or groups based on race or ethnic origin, religion, disability, age, nationality and national origin, veteran status, sexual orientation, gender or gender identity, caste, immigration status, or any other characteristic that is associated with systemic discrimination or marginalization.
|
README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-generation
|
| 3 |
+
license: other
|
| 4 |
+
license_name: modified-mit
|
| 5 |
+
license_link: https://github.com/MiniMax-AI/MiniMax-M2.7/blob/main/LICENSE
|
| 6 |
+
library_name: transformers
|
| 7 |
+
base_model: MiniMaxAI/MiniMax-M2.7
|
| 8 |
+
tags:
|
| 9 |
+
- mxfp4
|
| 10 |
+
- quantized
|
| 11 |
+
- moe
|
| 12 |
+
- compressed-tensors
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# MiniMax-M2.7-MXFP4
|
| 16 |
+
|
| 17 |
+
MXFP4 quantization of [MiniMax-M2.7](https://huggingface.co/MiniMaxAI/MiniMax-M2.7) (228B params, 62 layers, 256 experts/layer, top-8 sigmoid routing).
|
| 18 |
+
|
| 19 |
+
**All 15,872 MoE expert weights quantized to MXFP4.** Attention, layer norms, embeddings, and router weights kept at original precision.
|
| 20 |
+
|
| 21 |
+
| | Base (FP8) | MXFP4 |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| Size | 215 GB | 119 GB |
|
| 24 |
+
| Perplexity (WikiText-2) | 4.997 | 5.063 (+1.34%) |
|
| 25 |
+
| KL divergence | -- | 0.174 nats/tok (mean), 0.031 (median) |
|
| 26 |
+
| Top-1 agreement | -- | 85.8% |
|
| 27 |
+
| Compression | 1x | 1.81x |
|
| 28 |
+
|
| 29 |
+
## Quality Analysis
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
|
| 33 |
+
**KLD is heavily right-skewed**: median KLD is 0.031 nats/tok (5.6x lower than the mean). 96.6% of tokens have KLD < 1 nat. Only 69 out of 2048 eval tokens show significant divergence -- these are low-confidence positions where the model is already distributing probability across many candidates.
|
| 34 |
+
|
| 35 |
+
**Error is diffuse across experts**: per-expert quantization error analysis of all 15,872 experts shows extremely uniform error (std=0.000271, range 0.110--0.116). The 256-expert top-8 architecture is inherently quantization-tolerant -- each expert contributes ~1/8th of the output, so MXFP4 errors average out across the mixture.
|
| 36 |
+
|
| 37 |
+
## Format
|
| 38 |
+
|
| 39 |
+
MXFP4 block-32 quantization in [compressed-tensors](https://github.com/neuralmagic/compressed-tensors) format:
|
| 40 |
+
|
| 41 |
+
- `weight_packed`: uint8 `[out, in//2]` -- two 4-bit values packed per byte (even=low nibble, odd=high nibble)
|
| 42 |
+
- `weight_scale`: uint8 e8m0 `[out, in//32]` -- one shared exponent per block of 32 elements
|
| 43 |
+
|
| 44 |
+
Quantization is **calibration-free** (no calibration data needed). MXFP4 block-32 scaling is deterministic -- the shared exponent is derived directly from the max magnitude in each block.
|
| 45 |
+
|
| 46 |
+
Quantized with [quant4](https://github.com/olka-fi/quant4).
|
| 47 |
+
|
| 48 |
+
## Serving
|
| 49 |
+
|
| 50 |
+
### vLLM
|
| 51 |
+
|
| 52 |
+
Requires vLLM with MXFP4 compressed-tensors support and the CUTLASS FP4xFP8 kernel for Blackwell GPUs:
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
vllm serve /path/to/MiniMax-M2.7-MXFP4 \
|
| 56 |
+
--tensor-parallel-size 2 \
|
| 57 |
+
--trust-remote-code \
|
| 58 |
+
--max-num-seqs 512 \
|
| 59 |
+
--enable-chunked-prefill \
|
| 60 |
+
--max-num-batched-tokens 16384 \
|
| 61 |
+
--kv-cache-dtype fp8
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Memory Budget
|
| 65 |
+
|
| 66 |
+
At 119 GB, this fits on 2x DGX Spark (2x 120 GB = 240 GB total) with ~100 GB remaining for KV cache, enabling long-context or multi-session serving that would be impossible with the 215 GB FP8 original.
|
| 67 |
+
|
| 68 |
+
## Evaluation Details
|
| 69 |
+
|
| 70 |
+
Evaluated on WikiText-2 test set (2048 tokens) using layer-by-layer streaming inference with `MiniMaxLayerRunner`. Both models run identical forward passes; logits compared token-by-token.
|
| 71 |
+
|
| 72 |
+
| Metric | Value |
|
| 73 |
+
|---|---|
|
| 74 |
+
| Perplexity (ref) | 4.997 |
|
| 75 |
+
| Perplexity (MXFP4) | 5.063 |
|
| 76 |
+
| PPL degradation | +1.34% |
|
| 77 |
+
| KL(ref\|\|target) mean | 0.174 nats/tok |
|
| 78 |
+
| KL(ref\|\|target) median | 0.031 nats/tok |
|
| 79 |
+
| KL(ref\|\|target) P95 | 0.824 nats/tok |
|
| 80 |
+
| KL(ref\|\|target) P99 | 1.827 nats/tok |
|
| 81 |
+
| Top-1 agreement | 85.8% |
|
| 82 |
+
| Tokens with KLD > 1 nat | 69 / 2048 (3.4%) |
|
| 83 |
+
|
| 84 |
+
## Acknowledgments
|
| 85 |
+
|
| 86 |
+
Based on [MiniMax-M2.7](https://huggingface.co/MiniMaxAI/MiniMax-M2.7) by [MiniMax](https://www.minimax.io/). Original model license applies.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
{%- else -%}
|
| 22 |
+
{{- content }}
|
| 23 |
+
{%- endif -%}
|
| 24 |
+
{%- endmacro -%}
|
| 25 |
+
{#- System Message Construction ============================================ -#}
|
| 26 |
+
{%- macro build_system_message(system_message) -%}
|
| 27 |
+
{%- if system_message and system_message.content -%}
|
| 28 |
+
{{- visible_text(system_message.content) }}
|
| 29 |
+
{%- else -%}
|
| 30 |
+
{%- if model_identity is not defined -%}
|
| 31 |
+
{%- set model_identity = "You are a helpful assistant. Your name is MiniMax-M2.7 and is built by MiniMax." -%}
|
| 32 |
+
{%- endif -%}
|
| 33 |
+
{{- model_identity }}
|
| 34 |
+
{%- endif -%}
|
| 35 |
+
|
| 36 |
+
{#- Handle current_date -#}
|
| 37 |
+
{%- if system_message and system_message.current_date -%}
|
| 38 |
+
{{- '\n' ~ 'Current date: ' + system_message.current_date }}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{#- Handle current_location -#}
|
| 41 |
+
{%- if system_message and system_message.current_location -%}
|
| 42 |
+
{{- '\n' ~ 'Current location: ' + system_message.current_location }}
|
| 43 |
+
{%- endif -%}
|
| 44 |
+
{%- endmacro -%}
|
| 45 |
+
{#- Main Template Logic ================================================= -#}
|
| 46 |
+
{#- Extract system message (only first message if it's system) -#}
|
| 47 |
+
{%- set system_message = none -%}
|
| 48 |
+
{%- set conversation_messages = messages -%}
|
| 49 |
+
{%- if messages and messages[0].role == "system" -%}
|
| 50 |
+
{%- set system_message = messages[0] -%}
|
| 51 |
+
{%- set conversation_messages = messages[1:] -%}
|
| 52 |
+
{%- endif -%}
|
| 53 |
+
{#- Get the last user message turn, for interleved thinking -#}
|
| 54 |
+
{%- set ns = namespace(last_user_index=-1) %}
|
| 55 |
+
{% for m in conversation_messages %}
|
| 56 |
+
{%- if m.role == 'user' %}
|
| 57 |
+
{% set ns.last_user_index = loop.index0 -%}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endfor %}
|
| 60 |
+
{#- Render system message -#}
|
| 61 |
+
{{- ']~!b[' ~ ']~b]system' ~ '\n' }}
|
| 62 |
+
{{- build_system_message(system_message) }}
|
| 63 |
+
{#- Render tools if available -#}
|
| 64 |
+
{%- if tools -%}
|
| 65 |
+
{{- '\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' }}
|
| 66 |
+
{{- '\n' ~ '<tools>' ~ '\n' }}
|
| 67 |
+
{{- render_tool_namespace("functions", tools) }}
|
| 68 |
+
{{- '</tools>' ~ '\n\n' }}
|
| 69 |
+
{{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
|
| 70 |
+
{{- '\n' ~ toolcall_begin_token }}
|
| 71 |
+
<invoke name="tool-name-1">
|
| 72 |
+
<parameter name="param-key-1">param-value-1</parameter>
|
| 73 |
+
<parameter name="param-key-2">param-value-2</parameter>
|
| 74 |
+
...
|
| 75 |
+
</invoke>
|
| 76 |
+
{{- '\n' ~ toolcall_end_token }}
|
| 77 |
+
{%- endif -%}
|
| 78 |
+
{{- '[e~[\n' }}
|
| 79 |
+
|
| 80 |
+
{#- Render messages -#}
|
| 81 |
+
{%- set last_tool_call = namespace(name=none) -%}
|
| 82 |
+
{%- for message in conversation_messages -%}
|
| 83 |
+
{%- if message.role == 'assistant' -%}
|
| 84 |
+
{#- Only render reasoning_content if no user message follows -#}
|
| 85 |
+
{{- ']~b]ai' ~ '\n' }}
|
| 86 |
+
|
| 87 |
+
{%- set reasoning_content = '' %}
|
| 88 |
+
{%- set content = visible_text(message.content) %}
|
| 89 |
+
{%- if message.reasoning_content is string %}
|
| 90 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 91 |
+
{%- else %}
|
| 92 |
+
{%- if '</think>' in content %}
|
| 93 |
+
{%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
|
| 94 |
+
{%- set content = content.split('</think>')[-1].strip('\n') %}
|
| 95 |
+
{%- endif %}
|
| 96 |
+
{%- endif %}
|
| 97 |
+
{%- if reasoning_content and loop.index0 > ns.last_user_index -%}
|
| 98 |
+
{{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
|
| 99 |
+
{%- endif -%}
|
| 100 |
+
{%- if content -%}
|
| 101 |
+
{{- content }}
|
| 102 |
+
{%- endif -%}
|
| 103 |
+
{%- if message.tool_calls -%}
|
| 104 |
+
{{- '\n' ~ toolcall_begin_token ~ '\n' }}
|
| 105 |
+
|
| 106 |
+
{%- for tool_call in message.tool_calls -%}
|
| 107 |
+
{%- if tool_call.function %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{{- '<invoke name="' + tool_call.name + '">' }}
|
| 111 |
+
{% set _args = tool_call.arguments %}
|
| 112 |
+
{%- for k, v in _args.items() %}
|
| 113 |
+
{{- '<parameter name="' + k + '">' }}
|
| 114 |
+
{{- v | tojson(ensure_ascii=False) if v is not string else v }}
|
| 115 |
+
{{- '</parameter>' }}
|
| 116 |
+
{% endfor %}
|
| 117 |
+
{{- '</invoke>' ~ '\n' }}
|
| 118 |
+
{%- endfor -%}
|
| 119 |
+
|
| 120 |
+
{{- toolcall_end_token}}
|
| 121 |
+
{%- set last_tool_call.name = message.tool_calls[-1].name -%}
|
| 122 |
+
{%- else -%}
|
| 123 |
+
{%- set last_tool_call.name = none -%}
|
| 124 |
+
{%- endif -%}
|
| 125 |
+
{{- '[e~[' ~ '\n' }}
|
| 126 |
+
|
| 127 |
+
{%- elif message.role == 'tool' -%}
|
| 128 |
+
{%- if last_tool_call.name is none -%}
|
| 129 |
+
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
|
| 130 |
+
{%- endif -%}
|
| 131 |
+
{%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
|
| 132 |
+
{{- ']~b]tool' }}
|
| 133 |
+
{%- endif -%}
|
| 134 |
+
{%- if message.content is string -%}
|
| 135 |
+
{{- '\n<response>' }}
|
| 136 |
+
{{- message.content }}
|
| 137 |
+
{{- '</response>' }}
|
| 138 |
+
{%- else -%}
|
| 139 |
+
{%- for tr in message.content -%}
|
| 140 |
+
{{- '\n<response>' }}
|
| 141 |
+
{{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
|
| 142 |
+
{{- '\n</response>' }}
|
| 143 |
+
{%- endfor -%}
|
| 144 |
+
{%- endif -%}
|
| 145 |
+
{%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
|
| 146 |
+
{{- '[e~[\n' -}}
|
| 147 |
+
{%- endif -%}
|
| 148 |
+
|
| 149 |
+
{%- elif message.role == 'user' -%}
|
| 150 |
+
{{- ']~b]user' ~ '\n' }}
|
| 151 |
+
{{- visible_text(message.content) }}
|
| 152 |
+
{{- '[e~[' ~ '\n' }}
|
| 153 |
+
{%- endif -%}
|
| 154 |
+
{%- endfor -%}
|
| 155 |
+
|
| 156 |
+
{#- Generation prompt -#}
|
| 157 |
+
{%- if add_generation_prompt -%}
|
| 158 |
+
{{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
|
| 159 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,681 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 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 |
+
"dtype": "bfloat16",
|
| 74 |
+
"head_dim": 128,
|
| 75 |
+
"hidden_act": "silu",
|
| 76 |
+
"hidden_size": 3072,
|
| 77 |
+
"intermediate_size": 1536,
|
| 78 |
+
"max_position_embeddings": 196608,
|
| 79 |
+
"model_type": "minimax_m2",
|
| 80 |
+
"mtp_transformer_layers": 1,
|
| 81 |
+
"num_attention_heads": 48,
|
| 82 |
+
"num_experts_per_tok": 8,
|
| 83 |
+
"num_hidden_layers": 62,
|
| 84 |
+
"num_key_value_heads": 8,
|
| 85 |
+
"num_local_experts": 256,
|
| 86 |
+
"num_mtp_modules": 3,
|
| 87 |
+
"qk_norm_type": "per_layer",
|
| 88 |
+
"quantization_config": {
|
| 89 |
+
"quant_method": "compressed-tensors",
|
| 90 |
+
"format": "mxfp4-pack-quantized",
|
| 91 |
+
"config_groups": {
|
| 92 |
+
"group_0": {
|
| 93 |
+
"targets": [
|
| 94 |
+
"Linear"
|
| 95 |
+
],
|
| 96 |
+
"weights": {
|
| 97 |
+
"num_bits": 4,
|
| 98 |
+
"type": "float",
|
| 99 |
+
"strategy": "group",
|
| 100 |
+
"group_size": 32,
|
| 101 |
+
"symmetric": true
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
},
|
| 105 |
+
"ignore": [
|
| 106 |
+
"lm_head",
|
| 107 |
+
"model.embed_tokens",
|
| 108 |
+
"model.layers.0.block_sparse_moe.gate",
|
| 109 |
+
"model.layers.0.input_layernorm",
|
| 110 |
+
"model.layers.0.post_attention_layernorm",
|
| 111 |
+
"model.layers.0.self_attn.k_norm",
|
| 112 |
+
"model.layers.0.self_attn.k_proj",
|
| 113 |
+
"model.layers.0.self_attn.o_proj",
|
| 114 |
+
"model.layers.0.self_attn.q_norm",
|
| 115 |
+
"model.layers.0.self_attn.q_proj",
|
| 116 |
+
"model.layers.0.self_attn.v_proj",
|
| 117 |
+
"model.layers.1.block_sparse_moe.gate",
|
| 118 |
+
"model.layers.1.input_layernorm",
|
| 119 |
+
"model.layers.1.post_attention_layernorm",
|
| 120 |
+
"model.layers.1.self_attn.k_norm",
|
| 121 |
+
"model.layers.1.self_attn.k_proj",
|
| 122 |
+
"model.layers.1.self_attn.o_proj",
|
| 123 |
+
"model.layers.1.self_attn.q_norm",
|
| 124 |
+
"model.layers.1.self_attn.q_proj",
|
| 125 |
+
"model.layers.1.self_attn.v_proj",
|
| 126 |
+
"model.layers.10.block_sparse_moe.gate",
|
| 127 |
+
"model.layers.10.input_layernorm",
|
| 128 |
+
"model.layers.10.post_attention_layernorm",
|
| 129 |
+
"model.layers.10.self_attn.k_norm",
|
| 130 |
+
"model.layers.10.self_attn.k_proj",
|
| 131 |
+
"model.layers.10.self_attn.o_proj",
|
| 132 |
+
"model.layers.10.self_attn.q_norm",
|
| 133 |
+
"model.layers.10.self_attn.q_proj",
|
| 134 |
+
"model.layers.10.self_attn.v_proj",
|
| 135 |
+
"model.layers.11.block_sparse_moe.gate",
|
| 136 |
+
"model.layers.11.input_layernorm",
|
| 137 |
+
"model.layers.11.post_attention_layernorm",
|
| 138 |
+
"model.layers.11.self_attn.k_norm",
|
| 139 |
+
"model.layers.11.self_attn.k_proj",
|
| 140 |
+
"model.layers.11.self_attn.o_proj",
|
| 141 |
+
"model.layers.11.self_attn.q_norm",
|
| 142 |
+
"model.layers.11.self_attn.q_proj",
|
| 143 |
+
"model.layers.11.self_attn.v_proj",
|
| 144 |
+
"model.layers.12.block_sparse_moe.gate",
|
| 145 |
+
"model.layers.12.input_layernorm",
|
| 146 |
+
"model.layers.12.post_attention_layernorm",
|
| 147 |
+
"model.layers.12.self_attn.k_norm",
|
| 148 |
+
"model.layers.12.self_attn.k_proj",
|
| 149 |
+
"model.layers.12.self_attn.o_proj",
|
| 150 |
+
"model.layers.12.self_attn.q_norm",
|
| 151 |
+
"model.layers.12.self_attn.q_proj",
|
| 152 |
+
"model.layers.12.self_attn.v_proj",
|
| 153 |
+
"model.layers.13.block_sparse_moe.gate",
|
| 154 |
+
"model.layers.13.input_layernorm",
|
| 155 |
+
"model.layers.13.post_attention_layernorm",
|
| 156 |
+
"model.layers.13.self_attn.k_norm",
|
| 157 |
+
"model.layers.13.self_attn.k_proj",
|
| 158 |
+
"model.layers.13.self_attn.o_proj",
|
| 159 |
+
"model.layers.13.self_attn.q_norm",
|
| 160 |
+
"model.layers.13.self_attn.q_proj",
|
| 161 |
+
"model.layers.13.self_attn.v_proj",
|
| 162 |
+
"model.layers.14.block_sparse_moe.gate",
|
| 163 |
+
"model.layers.14.input_layernorm",
|
| 164 |
+
"model.layers.14.post_attention_layernorm",
|
| 165 |
+
"model.layers.14.self_attn.k_norm",
|
| 166 |
+
"model.layers.14.self_attn.k_proj",
|
| 167 |
+
"model.layers.14.self_attn.o_proj",
|
| 168 |
+
"model.layers.14.self_attn.q_norm",
|
| 169 |
+
"model.layers.14.self_attn.q_proj",
|
| 170 |
+
"model.layers.14.self_attn.v_proj",
|
| 171 |
+
"model.layers.15.block_sparse_moe.gate",
|
| 172 |
+
"model.layers.15.input_layernorm",
|
| 173 |
+
"model.layers.15.post_attention_layernorm",
|
| 174 |
+
"model.layers.15.self_attn.k_norm",
|
| 175 |
+
"model.layers.15.self_attn.k_proj",
|
| 176 |
+
"model.layers.15.self_attn.o_proj",
|
| 177 |
+
"model.layers.15.self_attn.q_norm",
|
| 178 |
+
"model.layers.15.self_attn.q_proj",
|
| 179 |
+
"model.layers.15.self_attn.v_proj",
|
| 180 |
+
"model.layers.16.block_sparse_moe.gate",
|
| 181 |
+
"model.layers.16.input_layernorm",
|
| 182 |
+
"model.layers.16.post_attention_layernorm",
|
| 183 |
+
"model.layers.16.self_attn.k_norm",
|
| 184 |
+
"model.layers.16.self_attn.k_proj",
|
| 185 |
+
"model.layers.16.self_attn.o_proj",
|
| 186 |
+
"model.layers.16.self_attn.q_norm",
|
| 187 |
+
"model.layers.16.self_attn.q_proj",
|
| 188 |
+
"model.layers.16.self_attn.v_proj",
|
| 189 |
+
"model.layers.17.block_sparse_moe.gate",
|
| 190 |
+
"model.layers.17.input_layernorm",
|
| 191 |
+
"model.layers.17.post_attention_layernorm",
|
| 192 |
+
"model.layers.17.self_attn.k_norm",
|
| 193 |
+
"model.layers.17.self_attn.k_proj",
|
| 194 |
+
"model.layers.17.self_attn.o_proj",
|
| 195 |
+
"model.layers.17.self_attn.q_norm",
|
| 196 |
+
"model.layers.17.self_attn.q_proj",
|
| 197 |
+
"model.layers.17.self_attn.v_proj",
|
| 198 |
+
"model.layers.18.block_sparse_moe.gate",
|
| 199 |
+
"model.layers.18.input_layernorm",
|
| 200 |
+
"model.layers.18.post_attention_layernorm",
|
| 201 |
+
"model.layers.18.self_attn.k_norm",
|
| 202 |
+
"model.layers.18.self_attn.k_proj",
|
| 203 |
+
"model.layers.18.self_attn.o_proj",
|
| 204 |
+
"model.layers.18.self_attn.q_norm",
|
| 205 |
+
"model.layers.18.self_attn.q_proj",
|
| 206 |
+
"model.layers.18.self_attn.v_proj",
|
| 207 |
+
"model.layers.19.block_sparse_moe.gate",
|
| 208 |
+
"model.layers.19.input_layernorm",
|
| 209 |
+
"model.layers.19.post_attention_layernorm",
|
| 210 |
+
"model.layers.19.self_attn.k_norm",
|
| 211 |
+
"model.layers.19.self_attn.k_proj",
|
| 212 |
+
"model.layers.19.self_attn.o_proj",
|
| 213 |
+
"model.layers.19.self_attn.q_norm",
|
| 214 |
+
"model.layers.19.self_attn.q_proj",
|
| 215 |
+
"model.layers.19.self_attn.v_proj",
|
| 216 |
+
"model.layers.2.block_sparse_moe.gate",
|
| 217 |
+
"model.layers.2.input_layernorm",
|
| 218 |
+
"model.layers.2.post_attention_layernorm",
|
| 219 |
+
"model.layers.2.self_attn.k_norm",
|
| 220 |
+
"model.layers.2.self_attn.k_proj",
|
| 221 |
+
"model.layers.2.self_attn.o_proj",
|
| 222 |
+
"model.layers.2.self_attn.q_norm",
|
| 223 |
+
"model.layers.2.self_attn.q_proj",
|
| 224 |
+
"model.layers.2.self_attn.v_proj",
|
| 225 |
+
"model.layers.20.block_sparse_moe.gate",
|
| 226 |
+
"model.layers.20.input_layernorm",
|
| 227 |
+
"model.layers.20.post_attention_layernorm",
|
| 228 |
+
"model.layers.20.self_attn.k_norm",
|
| 229 |
+
"model.layers.20.self_attn.k_proj",
|
| 230 |
+
"model.layers.20.self_attn.o_proj",
|
| 231 |
+
"model.layers.20.self_attn.q_norm",
|
| 232 |
+
"model.layers.20.self_attn.q_proj",
|
| 233 |
+
"model.layers.20.self_attn.v_proj",
|
| 234 |
+
"model.layers.21.block_sparse_moe.gate",
|
| 235 |
+
"model.layers.21.input_layernorm",
|
| 236 |
+
"model.layers.21.post_attention_layernorm",
|
| 237 |
+
"model.layers.21.self_attn.k_norm",
|
| 238 |
+
"model.layers.21.self_attn.k_proj",
|
| 239 |
+
"model.layers.21.self_attn.o_proj",
|
| 240 |
+
"model.layers.21.self_attn.q_norm",
|
| 241 |
+
"model.layers.21.self_attn.q_proj",
|
| 242 |
+
"model.layers.21.self_attn.v_proj",
|
| 243 |
+
"model.layers.22.block_sparse_moe.gate",
|
| 244 |
+
"model.layers.22.input_layernorm",
|
| 245 |
+
"model.layers.22.post_attention_layernorm",
|
| 246 |
+
"model.layers.22.self_attn.k_norm",
|
| 247 |
+
"model.layers.22.self_attn.k_proj",
|
| 248 |
+
"model.layers.22.self_attn.o_proj",
|
| 249 |
+
"model.layers.22.self_attn.q_norm",
|
| 250 |
+
"model.layers.22.self_attn.q_proj",
|
| 251 |
+
"model.layers.22.self_attn.v_proj",
|
| 252 |
+
"model.layers.23.block_sparse_moe.gate",
|
| 253 |
+
"model.layers.23.input_layernorm",
|
| 254 |
+
"model.layers.23.post_attention_layernorm",
|
| 255 |
+
"model.layers.23.self_attn.k_norm",
|
| 256 |
+
"model.layers.23.self_attn.k_proj",
|
| 257 |
+
"model.layers.23.self_attn.o_proj",
|
| 258 |
+
"model.layers.23.self_attn.q_norm",
|
| 259 |
+
"model.layers.23.self_attn.q_proj",
|
| 260 |
+
"model.layers.23.self_attn.v_proj",
|
| 261 |
+
"model.layers.24.block_sparse_moe.gate",
|
| 262 |
+
"model.layers.24.input_layernorm",
|
| 263 |
+
"model.layers.24.post_attention_layernorm",
|
| 264 |
+
"model.layers.24.self_attn.k_norm",
|
| 265 |
+
"model.layers.24.self_attn.k_proj",
|
| 266 |
+
"model.layers.24.self_attn.o_proj",
|
| 267 |
+
"model.layers.24.self_attn.q_norm",
|
| 268 |
+
"model.layers.24.self_attn.q_proj",
|
| 269 |
+
"model.layers.24.self_attn.v_proj",
|
| 270 |
+
"model.layers.25.block_sparse_moe.gate",
|
| 271 |
+
"model.layers.25.input_layernorm",
|
| 272 |
+
"model.layers.25.post_attention_layernorm",
|
| 273 |
+
"model.layers.25.self_attn.k_norm",
|
| 274 |
+
"model.layers.25.self_attn.k_proj",
|
| 275 |
+
"model.layers.25.self_attn.o_proj",
|
| 276 |
+
"model.layers.25.self_attn.q_norm",
|
| 277 |
+
"model.layers.25.self_attn.q_proj",
|
| 278 |
+
"model.layers.25.self_attn.v_proj",
|
| 279 |
+
"model.layers.26.block_sparse_moe.gate",
|
| 280 |
+
"model.layers.26.input_layernorm",
|
| 281 |
+
"model.layers.26.post_attention_layernorm",
|
| 282 |
+
"model.layers.26.self_attn.k_norm",
|
| 283 |
+
"model.layers.26.self_attn.k_proj",
|
| 284 |
+
"model.layers.26.self_attn.o_proj",
|
| 285 |
+
"model.layers.26.self_attn.q_norm",
|
| 286 |
+
"model.layers.26.self_attn.q_proj",
|
| 287 |
+
"model.layers.26.self_attn.v_proj",
|
| 288 |
+
"model.layers.27.block_sparse_moe.gate",
|
| 289 |
+
"model.layers.27.input_layernorm",
|
| 290 |
+
"model.layers.27.post_attention_layernorm",
|
| 291 |
+
"model.layers.27.self_attn.k_norm",
|
| 292 |
+
"model.layers.27.self_attn.k_proj",
|
| 293 |
+
"model.layers.27.self_attn.o_proj",
|
| 294 |
+
"model.layers.27.self_attn.q_norm",
|
| 295 |
+
"model.layers.27.self_attn.q_proj",
|
| 296 |
+
"model.layers.27.self_attn.v_proj",
|
| 297 |
+
"model.layers.28.block_sparse_moe.gate",
|
| 298 |
+
"model.layers.28.input_layernorm",
|
| 299 |
+
"model.layers.28.post_attention_layernorm",
|
| 300 |
+
"model.layers.28.self_attn.k_norm",
|
| 301 |
+
"model.layers.28.self_attn.k_proj",
|
| 302 |
+
"model.layers.28.self_attn.o_proj",
|
| 303 |
+
"model.layers.28.self_attn.q_norm",
|
| 304 |
+
"model.layers.28.self_attn.q_proj",
|
| 305 |
+
"model.layers.28.self_attn.v_proj",
|
| 306 |
+
"model.layers.29.block_sparse_moe.gate",
|
| 307 |
+
"model.layers.29.input_layernorm",
|
| 308 |
+
"model.layers.29.post_attention_layernorm",
|
| 309 |
+
"model.layers.29.self_attn.k_norm",
|
| 310 |
+
"model.layers.29.self_attn.k_proj",
|
| 311 |
+
"model.layers.29.self_attn.o_proj",
|
| 312 |
+
"model.layers.29.self_attn.q_norm",
|
| 313 |
+
"model.layers.29.self_attn.q_proj",
|
| 314 |
+
"model.layers.29.self_attn.v_proj",
|
| 315 |
+
"model.layers.3.block_sparse_moe.gate",
|
| 316 |
+
"model.layers.3.input_layernorm",
|
| 317 |
+
"model.layers.3.post_attention_layernorm",
|
| 318 |
+
"model.layers.3.self_attn.k_norm",
|
| 319 |
+
"model.layers.3.self_attn.k_proj",
|
| 320 |
+
"model.layers.3.self_attn.o_proj",
|
| 321 |
+
"model.layers.3.self_attn.q_norm",
|
| 322 |
+
"model.layers.3.self_attn.q_proj",
|
| 323 |
+
"model.layers.3.self_attn.v_proj",
|
| 324 |
+
"model.layers.30.block_sparse_moe.gate",
|
| 325 |
+
"model.layers.30.input_layernorm",
|
| 326 |
+
"model.layers.30.post_attention_layernorm",
|
| 327 |
+
"model.layers.30.self_attn.k_norm",
|
| 328 |
+
"model.layers.30.self_attn.k_proj",
|
| 329 |
+
"model.layers.30.self_attn.o_proj",
|
| 330 |
+
"model.layers.30.self_attn.q_norm",
|
| 331 |
+
"model.layers.30.self_attn.q_proj",
|
| 332 |
+
"model.layers.30.self_attn.v_proj",
|
| 333 |
+
"model.layers.31.block_sparse_moe.gate",
|
| 334 |
+
"model.layers.31.input_layernorm",
|
| 335 |
+
"model.layers.31.post_attention_layernorm",
|
| 336 |
+
"model.layers.31.self_attn.k_norm",
|
| 337 |
+
"model.layers.31.self_attn.k_proj",
|
| 338 |
+
"model.layers.31.self_attn.o_proj",
|
| 339 |
+
"model.layers.31.self_attn.q_norm",
|
| 340 |
+
"model.layers.31.self_attn.q_proj",
|
| 341 |
+
"model.layers.31.self_attn.v_proj",
|
| 342 |
+
"model.layers.32.block_sparse_moe.gate",
|
| 343 |
+
"model.layers.32.input_layernorm",
|
| 344 |
+
"model.layers.32.post_attention_layernorm",
|
| 345 |
+
"model.layers.32.self_attn.k_norm",
|
| 346 |
+
"model.layers.32.self_attn.k_proj",
|
| 347 |
+
"model.layers.32.self_attn.o_proj",
|
| 348 |
+
"model.layers.32.self_attn.q_norm",
|
| 349 |
+
"model.layers.32.self_attn.q_proj",
|
| 350 |
+
"model.layers.32.self_attn.v_proj",
|
| 351 |
+
"model.layers.33.block_sparse_moe.gate",
|
| 352 |
+
"model.layers.33.input_layernorm",
|
| 353 |
+
"model.layers.33.post_attention_layernorm",
|
| 354 |
+
"model.layers.33.self_attn.k_norm",
|
| 355 |
+
"model.layers.33.self_attn.k_proj",
|
| 356 |
+
"model.layers.33.self_attn.o_proj",
|
| 357 |
+
"model.layers.33.self_attn.q_norm",
|
| 358 |
+
"model.layers.33.self_attn.q_proj",
|
| 359 |
+
"model.layers.33.self_attn.v_proj",
|
| 360 |
+
"model.layers.34.block_sparse_moe.gate",
|
| 361 |
+
"model.layers.34.input_layernorm",
|
| 362 |
+
"model.layers.34.post_attention_layernorm",
|
| 363 |
+
"model.layers.34.self_attn.k_norm",
|
| 364 |
+
"model.layers.34.self_attn.k_proj",
|
| 365 |
+
"model.layers.34.self_attn.o_proj",
|
| 366 |
+
"model.layers.34.self_attn.q_norm",
|
| 367 |
+
"model.layers.34.self_attn.q_proj",
|
| 368 |
+
"model.layers.34.self_attn.v_proj",
|
| 369 |
+
"model.layers.35.block_sparse_moe.gate",
|
| 370 |
+
"model.layers.35.input_layernorm",
|
| 371 |
+
"model.layers.35.post_attention_layernorm",
|
| 372 |
+
"model.layers.35.self_attn.k_norm",
|
| 373 |
+
"model.layers.35.self_attn.k_proj",
|
| 374 |
+
"model.layers.35.self_attn.o_proj",
|
| 375 |
+
"model.layers.35.self_attn.q_norm",
|
| 376 |
+
"model.layers.35.self_attn.q_proj",
|
| 377 |
+
"model.layers.35.self_attn.v_proj",
|
| 378 |
+
"model.layers.36.block_sparse_moe.gate",
|
| 379 |
+
"model.layers.36.input_layernorm",
|
| 380 |
+
"model.layers.36.post_attention_layernorm",
|
| 381 |
+
"model.layers.36.self_attn.k_norm",
|
| 382 |
+
"model.layers.36.self_attn.k_proj",
|
| 383 |
+
"model.layers.36.self_attn.o_proj",
|
| 384 |
+
"model.layers.36.self_attn.q_norm",
|
| 385 |
+
"model.layers.36.self_attn.q_proj",
|
| 386 |
+
"model.layers.36.self_attn.v_proj",
|
| 387 |
+
"model.layers.37.block_sparse_moe.gate",
|
| 388 |
+
"model.layers.37.input_layernorm",
|
| 389 |
+
"model.layers.37.post_attention_layernorm",
|
| 390 |
+
"model.layers.37.self_attn.k_norm",
|
| 391 |
+
"model.layers.37.self_attn.k_proj",
|
| 392 |
+
"model.layers.37.self_attn.o_proj",
|
| 393 |
+
"model.layers.37.self_attn.q_norm",
|
| 394 |
+
"model.layers.37.self_attn.q_proj",
|
| 395 |
+
"model.layers.37.self_attn.v_proj",
|
| 396 |
+
"model.layers.38.block_sparse_moe.gate",
|
| 397 |
+
"model.layers.38.input_layernorm",
|
| 398 |
+
"model.layers.38.post_attention_layernorm",
|
| 399 |
+
"model.layers.38.self_attn.k_norm",
|
| 400 |
+
"model.layers.38.self_attn.k_proj",
|
| 401 |
+
"model.layers.38.self_attn.o_proj",
|
| 402 |
+
"model.layers.38.self_attn.q_norm",
|
| 403 |
+
"model.layers.38.self_attn.q_proj",
|
| 404 |
+
"model.layers.38.self_attn.v_proj",
|
| 405 |
+
"model.layers.39.block_sparse_moe.gate",
|
| 406 |
+
"model.layers.39.input_layernorm",
|
| 407 |
+
"model.layers.39.post_attention_layernorm",
|
| 408 |
+
"model.layers.39.self_attn.k_norm",
|
| 409 |
+
"model.layers.39.self_attn.k_proj",
|
| 410 |
+
"model.layers.39.self_attn.o_proj",
|
| 411 |
+
"model.layers.39.self_attn.q_norm",
|
| 412 |
+
"model.layers.39.self_attn.q_proj",
|
| 413 |
+
"model.layers.39.self_attn.v_proj",
|
| 414 |
+
"model.layers.4.block_sparse_moe.gate",
|
| 415 |
+
"model.layers.4.input_layernorm",
|
| 416 |
+
"model.layers.4.post_attention_layernorm",
|
| 417 |
+
"model.layers.4.self_attn.k_norm",
|
| 418 |
+
"model.layers.4.self_attn.k_proj",
|
| 419 |
+
"model.layers.4.self_attn.o_proj",
|
| 420 |
+
"model.layers.4.self_attn.q_norm",
|
| 421 |
+
"model.layers.4.self_attn.q_proj",
|
| 422 |
+
"model.layers.4.self_attn.v_proj",
|
| 423 |
+
"model.layers.40.block_sparse_moe.gate",
|
| 424 |
+
"model.layers.40.input_layernorm",
|
| 425 |
+
"model.layers.40.post_attention_layernorm",
|
| 426 |
+
"model.layers.40.self_attn.k_norm",
|
| 427 |
+
"model.layers.40.self_attn.k_proj",
|
| 428 |
+
"model.layers.40.self_attn.o_proj",
|
| 429 |
+
"model.layers.40.self_attn.q_norm",
|
| 430 |
+
"model.layers.40.self_attn.q_proj",
|
| 431 |
+
"model.layers.40.self_attn.v_proj",
|
| 432 |
+
"model.layers.41.block_sparse_moe.gate",
|
| 433 |
+
"model.layers.41.input_layernorm",
|
| 434 |
+
"model.layers.41.post_attention_layernorm",
|
| 435 |
+
"model.layers.41.self_attn.k_norm",
|
| 436 |
+
"model.layers.41.self_attn.k_proj",
|
| 437 |
+
"model.layers.41.self_attn.o_proj",
|
| 438 |
+
"model.layers.41.self_attn.q_norm",
|
| 439 |
+
"model.layers.41.self_attn.q_proj",
|
| 440 |
+
"model.layers.41.self_attn.v_proj",
|
| 441 |
+
"model.layers.42.block_sparse_moe.gate",
|
| 442 |
+
"model.layers.42.input_layernorm",
|
| 443 |
+
"model.layers.42.post_attention_layernorm",
|
| 444 |
+
"model.layers.42.self_attn.k_norm",
|
| 445 |
+
"model.layers.42.self_attn.k_proj",
|
| 446 |
+
"model.layers.42.self_attn.o_proj",
|
| 447 |
+
"model.layers.42.self_attn.q_norm",
|
| 448 |
+
"model.layers.42.self_attn.q_proj",
|
| 449 |
+
"model.layers.42.self_attn.v_proj",
|
| 450 |
+
"model.layers.43.block_sparse_moe.gate",
|
| 451 |
+
"model.layers.43.input_layernorm",
|
| 452 |
+
"model.layers.43.post_attention_layernorm",
|
| 453 |
+
"model.layers.43.self_attn.k_norm",
|
| 454 |
+
"model.layers.43.self_attn.k_proj",
|
| 455 |
+
"model.layers.43.self_attn.o_proj",
|
| 456 |
+
"model.layers.43.self_attn.q_norm",
|
| 457 |
+
"model.layers.43.self_attn.q_proj",
|
| 458 |
+
"model.layers.43.self_attn.v_proj",
|
| 459 |
+
"model.layers.44.block_sparse_moe.gate",
|
| 460 |
+
"model.layers.44.input_layernorm",
|
| 461 |
+
"model.layers.44.post_attention_layernorm",
|
| 462 |
+
"model.layers.44.self_attn.k_norm",
|
| 463 |
+
"model.layers.44.self_attn.k_proj",
|
| 464 |
+
"model.layers.44.self_attn.o_proj",
|
| 465 |
+
"model.layers.44.self_attn.q_norm",
|
| 466 |
+
"model.layers.44.self_attn.q_proj",
|
| 467 |
+
"model.layers.44.self_attn.v_proj",
|
| 468 |
+
"model.layers.45.block_sparse_moe.gate",
|
| 469 |
+
"model.layers.45.input_layernorm",
|
| 470 |
+
"model.layers.45.post_attention_layernorm",
|
| 471 |
+
"model.layers.45.self_attn.k_norm",
|
| 472 |
+
"model.layers.45.self_attn.k_proj",
|
| 473 |
+
"model.layers.45.self_attn.o_proj",
|
| 474 |
+
"model.layers.45.self_attn.q_norm",
|
| 475 |
+
"model.layers.45.self_attn.q_proj",
|
| 476 |
+
"model.layers.45.self_attn.v_proj",
|
| 477 |
+
"model.layers.46.block_sparse_moe.gate",
|
| 478 |
+
"model.layers.46.input_layernorm",
|
| 479 |
+
"model.layers.46.post_attention_layernorm",
|
| 480 |
+
"model.layers.46.self_attn.k_norm",
|
| 481 |
+
"model.layers.46.self_attn.k_proj",
|
| 482 |
+
"model.layers.46.self_attn.o_proj",
|
| 483 |
+
"model.layers.46.self_attn.q_norm",
|
| 484 |
+
"model.layers.46.self_attn.q_proj",
|
| 485 |
+
"model.layers.46.self_attn.v_proj",
|
| 486 |
+
"model.layers.47.block_sparse_moe.gate",
|
| 487 |
+
"model.layers.47.input_layernorm",
|
| 488 |
+
"model.layers.47.post_attention_layernorm",
|
| 489 |
+
"model.layers.47.self_attn.k_norm",
|
| 490 |
+
"model.layers.47.self_attn.k_proj",
|
| 491 |
+
"model.layers.47.self_attn.o_proj",
|
| 492 |
+
"model.layers.47.self_attn.q_norm",
|
| 493 |
+
"model.layers.47.self_attn.q_proj",
|
| 494 |
+
"model.layers.47.self_attn.v_proj",
|
| 495 |
+
"model.layers.48.block_sparse_moe.gate",
|
| 496 |
+
"model.layers.48.input_layernorm",
|
| 497 |
+
"model.layers.48.post_attention_layernorm",
|
| 498 |
+
"model.layers.48.self_attn.k_norm",
|
| 499 |
+
"model.layers.48.self_attn.k_proj",
|
| 500 |
+
"model.layers.48.self_attn.o_proj",
|
| 501 |
+
"model.layers.48.self_attn.q_norm",
|
| 502 |
+
"model.layers.48.self_attn.q_proj",
|
| 503 |
+
"model.layers.48.self_attn.v_proj",
|
| 504 |
+
"model.layers.49.block_sparse_moe.gate",
|
| 505 |
+
"model.layers.49.input_layernorm",
|
| 506 |
+
"model.layers.49.post_attention_layernorm",
|
| 507 |
+
"model.layers.49.self_attn.k_norm",
|
| 508 |
+
"model.layers.49.self_attn.k_proj",
|
| 509 |
+
"model.layers.49.self_attn.o_proj",
|
| 510 |
+
"model.layers.49.self_attn.q_norm",
|
| 511 |
+
"model.layers.49.self_attn.q_proj",
|
| 512 |
+
"model.layers.49.self_attn.v_proj",
|
| 513 |
+
"model.layers.5.block_sparse_moe.gate",
|
| 514 |
+
"model.layers.5.input_layernorm",
|
| 515 |
+
"model.layers.5.post_attention_layernorm",
|
| 516 |
+
"model.layers.5.self_attn.k_norm",
|
| 517 |
+
"model.layers.5.self_attn.k_proj",
|
| 518 |
+
"model.layers.5.self_attn.o_proj",
|
| 519 |
+
"model.layers.5.self_attn.q_norm",
|
| 520 |
+
"model.layers.5.self_attn.q_proj",
|
| 521 |
+
"model.layers.5.self_attn.v_proj",
|
| 522 |
+
"model.layers.50.block_sparse_moe.gate",
|
| 523 |
+
"model.layers.50.input_layernorm",
|
| 524 |
+
"model.layers.50.post_attention_layernorm",
|
| 525 |
+
"model.layers.50.self_attn.k_norm",
|
| 526 |
+
"model.layers.50.self_attn.k_proj",
|
| 527 |
+
"model.layers.50.self_attn.o_proj",
|
| 528 |
+
"model.layers.50.self_attn.q_norm",
|
| 529 |
+
"model.layers.50.self_attn.q_proj",
|
| 530 |
+
"model.layers.50.self_attn.v_proj",
|
| 531 |
+
"model.layers.51.block_sparse_moe.gate",
|
| 532 |
+
"model.layers.51.input_layernorm",
|
| 533 |
+
"model.layers.51.post_attention_layernorm",
|
| 534 |
+
"model.layers.51.self_attn.k_norm",
|
| 535 |
+
"model.layers.51.self_attn.k_proj",
|
| 536 |
+
"model.layers.51.self_attn.o_proj",
|
| 537 |
+
"model.layers.51.self_attn.q_norm",
|
| 538 |
+
"model.layers.51.self_attn.q_proj",
|
| 539 |
+
"model.layers.51.self_attn.v_proj",
|
| 540 |
+
"model.layers.52.block_sparse_moe.gate",
|
| 541 |
+
"model.layers.52.input_layernorm",
|
| 542 |
+
"model.layers.52.post_attention_layernorm",
|
| 543 |
+
"model.layers.52.self_attn.k_norm",
|
| 544 |
+
"model.layers.52.self_attn.k_proj",
|
| 545 |
+
"model.layers.52.self_attn.o_proj",
|
| 546 |
+
"model.layers.52.self_attn.q_norm",
|
| 547 |
+
"model.layers.52.self_attn.q_proj",
|
| 548 |
+
"model.layers.52.self_attn.v_proj",
|
| 549 |
+
"model.layers.53.block_sparse_moe.gate",
|
| 550 |
+
"model.layers.53.input_layernorm",
|
| 551 |
+
"model.layers.53.post_attention_layernorm",
|
| 552 |
+
"model.layers.53.self_attn.k_norm",
|
| 553 |
+
"model.layers.53.self_attn.k_proj",
|
| 554 |
+
"model.layers.53.self_attn.o_proj",
|
| 555 |
+
"model.layers.53.self_attn.q_norm",
|
| 556 |
+
"model.layers.53.self_attn.q_proj",
|
| 557 |
+
"model.layers.53.self_attn.v_proj",
|
| 558 |
+
"model.layers.54.block_sparse_moe.gate",
|
| 559 |
+
"model.layers.54.input_layernorm",
|
| 560 |
+
"model.layers.54.post_attention_layernorm",
|
| 561 |
+
"model.layers.54.self_attn.k_norm",
|
| 562 |
+
"model.layers.54.self_attn.k_proj",
|
| 563 |
+
"model.layers.54.self_attn.o_proj",
|
| 564 |
+
"model.layers.54.self_attn.q_norm",
|
| 565 |
+
"model.layers.54.self_attn.q_proj",
|
| 566 |
+
"model.layers.54.self_attn.v_proj",
|
| 567 |
+
"model.layers.55.block_sparse_moe.gate",
|
| 568 |
+
"model.layers.55.input_layernorm",
|
| 569 |
+
"model.layers.55.post_attention_layernorm",
|
| 570 |
+
"model.layers.55.self_attn.k_norm",
|
| 571 |
+
"model.layers.55.self_attn.k_proj",
|
| 572 |
+
"model.layers.55.self_attn.o_proj",
|
| 573 |
+
"model.layers.55.self_attn.q_norm",
|
| 574 |
+
"model.layers.55.self_attn.q_proj",
|
| 575 |
+
"model.layers.55.self_attn.v_proj",
|
| 576 |
+
"model.layers.56.block_sparse_moe.gate",
|
| 577 |
+
"model.layers.56.input_layernorm",
|
| 578 |
+
"model.layers.56.post_attention_layernorm",
|
| 579 |
+
"model.layers.56.self_attn.k_norm",
|
| 580 |
+
"model.layers.56.self_attn.k_proj",
|
| 581 |
+
"model.layers.56.self_attn.o_proj",
|
| 582 |
+
"model.layers.56.self_attn.q_norm",
|
| 583 |
+
"model.layers.56.self_attn.q_proj",
|
| 584 |
+
"model.layers.56.self_attn.v_proj",
|
| 585 |
+
"model.layers.57.block_sparse_moe.gate",
|
| 586 |
+
"model.layers.57.input_layernorm",
|
| 587 |
+
"model.layers.57.post_attention_layernorm",
|
| 588 |
+
"model.layers.57.self_attn.k_norm",
|
| 589 |
+
"model.layers.57.self_attn.k_proj",
|
| 590 |
+
"model.layers.57.self_attn.o_proj",
|
| 591 |
+
"model.layers.57.self_attn.q_norm",
|
| 592 |
+
"model.layers.57.self_attn.q_proj",
|
| 593 |
+
"model.layers.57.self_attn.v_proj",
|
| 594 |
+
"model.layers.58.block_sparse_moe.gate",
|
| 595 |
+
"model.layers.58.input_layernorm",
|
| 596 |
+
"model.layers.58.post_attention_layernorm",
|
| 597 |
+
"model.layers.58.self_attn.k_norm",
|
| 598 |
+
"model.layers.58.self_attn.k_proj",
|
| 599 |
+
"model.layers.58.self_attn.o_proj",
|
| 600 |
+
"model.layers.58.self_attn.q_norm",
|
| 601 |
+
"model.layers.58.self_attn.q_proj",
|
| 602 |
+
"model.layers.58.self_attn.v_proj",
|
| 603 |
+
"model.layers.59.block_sparse_moe.gate",
|
| 604 |
+
"model.layers.59.input_layernorm",
|
| 605 |
+
"model.layers.59.post_attention_layernorm",
|
| 606 |
+
"model.layers.59.self_attn.k_norm",
|
| 607 |
+
"model.layers.59.self_attn.k_proj",
|
| 608 |
+
"model.layers.59.self_attn.o_proj",
|
| 609 |
+
"model.layers.59.self_attn.q_norm",
|
| 610 |
+
"model.layers.59.self_attn.q_proj",
|
| 611 |
+
"model.layers.59.self_attn.v_proj",
|
| 612 |
+
"model.layers.6.block_sparse_moe.gate",
|
| 613 |
+
"model.layers.6.input_layernorm",
|
| 614 |
+
"model.layers.6.post_attention_layernorm",
|
| 615 |
+
"model.layers.6.self_attn.k_norm",
|
| 616 |
+
"model.layers.6.self_attn.k_proj",
|
| 617 |
+
"model.layers.6.self_attn.o_proj",
|
| 618 |
+
"model.layers.6.self_attn.q_norm",
|
| 619 |
+
"model.layers.6.self_attn.q_proj",
|
| 620 |
+
"model.layers.6.self_attn.v_proj",
|
| 621 |
+
"model.layers.60.block_sparse_moe.gate",
|
| 622 |
+
"model.layers.60.input_layernorm",
|
| 623 |
+
"model.layers.60.post_attention_layernorm",
|
| 624 |
+
"model.layers.60.self_attn.k_norm",
|
| 625 |
+
"model.layers.60.self_attn.k_proj",
|
| 626 |
+
"model.layers.60.self_attn.o_proj",
|
| 627 |
+
"model.layers.60.self_attn.q_norm",
|
| 628 |
+
"model.layers.60.self_attn.q_proj",
|
| 629 |
+
"model.layers.60.self_attn.v_proj",
|
| 630 |
+
"model.layers.61.block_sparse_moe.gate",
|
| 631 |
+
"model.layers.61.input_layernorm",
|
| 632 |
+
"model.layers.61.post_attention_layernorm",
|
| 633 |
+
"model.layers.61.self_attn.k_norm",
|
| 634 |
+
"model.layers.61.self_attn.k_proj",
|
| 635 |
+
"model.layers.61.self_attn.o_proj",
|
| 636 |
+
"model.layers.61.self_attn.q_norm",
|
| 637 |
+
"model.layers.61.self_attn.q_proj",
|
| 638 |
+
"model.layers.61.self_attn.v_proj",
|
| 639 |
+
"model.layers.7.block_sparse_moe.gate",
|
| 640 |
+
"model.layers.7.input_layernorm",
|
| 641 |
+
"model.layers.7.post_attention_layernorm",
|
| 642 |
+
"model.layers.7.self_attn.k_norm",
|
| 643 |
+
"model.layers.7.self_attn.k_proj",
|
| 644 |
+
"model.layers.7.self_attn.o_proj",
|
| 645 |
+
"model.layers.7.self_attn.q_norm",
|
| 646 |
+
"model.layers.7.self_attn.q_proj",
|
| 647 |
+
"model.layers.7.self_attn.v_proj",
|
| 648 |
+
"model.layers.8.block_sparse_moe.gate",
|
| 649 |
+
"model.layers.8.input_layernorm",
|
| 650 |
+
"model.layers.8.post_attention_layernorm",
|
| 651 |
+
"model.layers.8.self_attn.k_norm",
|
| 652 |
+
"model.layers.8.self_attn.k_proj",
|
| 653 |
+
"model.layers.8.self_attn.o_proj",
|
| 654 |
+
"model.layers.8.self_attn.q_norm",
|
| 655 |
+
"model.layers.8.self_attn.q_proj",
|
| 656 |
+
"model.layers.8.self_attn.v_proj",
|
| 657 |
+
"model.layers.9.block_sparse_moe.gate",
|
| 658 |
+
"model.layers.9.input_layernorm",
|
| 659 |
+
"model.layers.9.post_attention_layernorm",
|
| 660 |
+
"model.layers.9.self_attn.k_norm",
|
| 661 |
+
"model.layers.9.self_attn.k_proj",
|
| 662 |
+
"model.layers.9.self_attn.o_proj",
|
| 663 |
+
"model.layers.9.self_attn.q_norm",
|
| 664 |
+
"model.layers.9.self_attn.q_proj",
|
| 665 |
+
"model.layers.9.self_attn.v_proj",
|
| 666 |
+
"model.norm"
|
| 667 |
+
]
|
| 668 |
+
},
|
| 669 |
+
"rms_norm_eps": 1e-06,
|
| 670 |
+
"rope_theta": 5000000,
|
| 671 |
+
"rotary_dim": 64,
|
| 672 |
+
"scoring_func": "sigmoid",
|
| 673 |
+
"shared_intermediate_size": 0,
|
| 674 |
+
"tie_word_embeddings": false,
|
| 675 |
+
"transformers_version": "4.46.1",
|
| 676 |
+
"use_cache": true,
|
| 677 |
+
"use_mtp": true,
|
| 678 |
+
"use_qk_norm": true,
|
| 679 |
+
"use_routing_bias": true,
|
| 680 |
+
"vocab_size": 200064
|
| 681 |
+
}
|
configuration_minimax_m2.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 200 |
+
__all__ = ["MiniMaxM2Config"]
|
eval_minimax_m27.png
ADDED
|
Git LFS Details
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 200019,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": 200020,
|
| 5 |
+
"temperature": 1.0,
|
| 6 |
+
"top_p": 0.95,
|
| 7 |
+
"top_k": 40,
|
| 8 |
+
"transformers_version": "4.46.1"
|
| 9 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00006-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:27c4bc34bf378421b3e777ddc15fc5fcf0c915b8f7893b915d4b846503fb36ec
|
| 3 |
+
size 1374848752
|
model-00017-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60c97e2ca2a804908a1873f1f2577586d095ab665b0228d84ea8ffdef25faf74
|
| 3 |
+
size 641796224
|
model-00023-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:802335134efd8d1d4e8356be02f4d7a914e88042c40d039e576e3d7f5fc72442
|
| 3 |
+
size 641796736
|
model-00025-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df354bff0e4e5c2998608d6803c1d89b26466a747780d994b8396525d7d68d68
|
| 3 |
+
size 641796736
|
model-00029-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a93eba5d7d428fbd56a190235afd558d5d9b86214b3c68df451c59707644193b
|
| 3 |
+
size 641796736
|
model-00031-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c185dd40fec4286d021b73e6f3755ffdf063db200675f153a09e4dfcd7558ca1
|
| 3 |
+
size 641796736
|
model-00035-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b111be656572deb7755558e545822620f7543aa5e509cf1bf5b32114efdd9ea
|
| 3 |
+
size 641796736
|
model-00040-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b72b119d217169253d53849e8f4052c74de8601d17ca7d006b070bf1a4598d5d
|
| 3 |
+
size 1374849784
|
model-00041-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed08289c1b9dece5a4377d43706d03ecfa0bd62bb23e871b82752f8dccaacd50
|
| 3 |
+
size 641796736
|
model-00042-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba71cfe116fdad012661a453325e454deb949c7b8c5712f2c7576a4de63c3895
|
| 3 |
+
size 1374849784
|
model-00043-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7087276783c5a16b01799b6e9f59dec45cbbe68d8ccc8fbf96b43643ab81721
|
| 3 |
+
size 641796736
|
model-00047-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5afa05305919543d22c0ba411955aa187308d933f5b43aea6ce6056dcf428ab9
|
| 3 |
+
size 641796736
|
model-00054-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:297267e11651448b11286c99d3962aafcb9ac58f43bd4dad35f675a7985ca579
|
| 3 |
+
size 1374849784
|
model-00068-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b916a861ecf443df625122fbe5899e591e3542c9f14ebd3d9bbbf1ce7d8bd838
|
| 3 |
+
size 1374849784
|
model-00069-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e7ec5912b1ab5fdcbdc7397ec512305457d423664c04afa105f38cfcc1317ba
|
| 3 |
+
size 641796736
|
model-00072-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dced5620d58a0c9b1b69b25c5b050254a95e44a830b4f8321500d23c9e062d42
|
| 3 |
+
size 1374849784
|
model-00076-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c66c8225018192e8d2a29ed4f927acb58151baa8fc4aca89a438810d0fbfc17a
|
| 3 |
+
size 1374849784
|
model-00080-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ada7ca5dd9ff3f6dde9e217af1532bd473908b4beca73f914e6b09edeae60f38
|
| 3 |
+
size 1374849784
|
model-00081-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82852cb3c3f62bccc54e03145890620ea67bfa4f71e6cf2449e82730c679a3f4
|
| 3 |
+
size 641796736
|
model-00082-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:48c5758c26f86e9ac014b91526f670e78715b33b636e3aa67eac227e9c90bcfe
|
| 3 |
+
size 1374849784
|
model-00087-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:816438dc4cc802f8ffd06c6a041bbf495c702f76b2fea4e70fce6dd7a0e65e20
|
| 3 |
+
size 641796736
|
model-00088-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:22461445e666bc16c8d24a879bd210e751a61c2abaf331ac130e1aae814c9f4d
|
| 3 |
+
size 1374849784
|
model-00089-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:313010a6914c8c45077c4e9782be1bb816b281b9b1d6654a88dc47e1dbc1415c
|
| 3 |
+
size 641796736
|
model-00093-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f08c243d1f94bd949cb94b528e6eb0f778d1cce0e367ca8f1568ecd333953759
|
| 3 |
+
size 641796736
|
model-00097-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:555610082b49e56a2c7fd8c742c93cc7e2e0a99a92889abd657641a2c646a838
|
| 3 |
+
size 641796736
|
model-00100-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c3953d9a8630368daa724c1da7ffccc3fc52343d0a6f906f4fb5db73489f7c7
|
| 3 |
+
size 1374849784
|
model-00102-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c6e1d447004a5453fcd0f769e28d780f84c8d098fa8c68914f9fc36b48ba089
|
| 3 |
+
size 1374849784
|
model-00103-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:304e214a0760b4eba893843de7dd5177771314fc5a9b335ea2fa3af308cd4988
|
| 3 |
+
size 641796736
|
model-00104-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:edefe7b589886e0743e6fe759b5fb8454ccb128b25758807d80215ccd470e289
|
| 3 |
+
size 1374849784
|
model-00109-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c6b3b1a2673e4235795b8a72bee9a8ef4c3a7ce35c4929dc2d3e560d2eb8956e
|
| 3 |
+
size 641796736
|
model-00113-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d81fb0cea3a0a94f6c5e163c65032b7b38f95ebfe7da52fd3976ae8c6b6829f
|
| 3 |
+
size 641796736
|
model-00114-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca5473643c038c1a269b9dc5513aaae1395c8e1b5f551e58a4f0b4af9d3a6a45
|
| 3 |
+
size 1374849784
|
model-00116-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2352e09cf6ae165d62af5f045304c47c8ca04e088257d99a7571698a21fc3635
|
| 3 |
+
size 1374849784
|
model-00118-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:180be728f1a47c318f3fcd86de4b8301569d8ecd606ca2448d3bf3549d04a89d
|
| 3 |
+
size 1374849784
|
model-00120-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4459df00cc5581150ba01d53789369a846148e489a2d268bb1c0bcc214b5a2c2
|
| 3 |
+
size 1374849784
|
model-00121-of-00130.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31709b37df1a07fa3d3bd106fcae43a32931223e1061f0d8c23c24f7558d8a7b
|
| 3 |
+
size 641796736
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_minimax_m2.py
ADDED
|
@@ -0,0 +1,706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 collections.abc import Callable
|
| 24 |
+
from typing import Optional, Union, Unpack
|
| 25 |
+
|
| 26 |
+
import torch
|
| 27 |
+
from torch import nn
|
| 28 |
+
|
| 29 |
+
from transformers.activations import ACT2FN
|
| 30 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 31 |
+
from transformers.generation import GenerationMixin
|
| 32 |
+
from transformers.integrations import use_kernel_forward_from_hub
|
| 33 |
+
from transformers.masking_utils import create_causal_mask, create_sliding_window_causal_mask
|
| 34 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
| 35 |
+
from transformers.modeling_layers import (
|
| 36 |
+
GenericForQuestionAnswering,
|
| 37 |
+
GenericForSequenceClassification,
|
| 38 |
+
GenericForTokenClassification,
|
| 39 |
+
GradientCheckpointingLayer,
|
| 40 |
+
)
|
| 41 |
+
from transformers.modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast
|
| 42 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 43 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 44 |
+
from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple
|
| 45 |
+
from transformers.utils.deprecation import deprecate_kwarg
|
| 46 |
+
from transformers.utils.generic import OutputRecorder, check_model_inputs
|
| 47 |
+
from .configuration_minimax_m2 import MiniMaxM2Config
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class MiniMaxM2MLP(nn.Module):
|
| 51 |
+
def __init__(self, config: MiniMaxM2Config):
|
| 52 |
+
super().__init__()
|
| 53 |
+
self.ffn_dim = config.intermediate_size
|
| 54 |
+
self.hidden_dim = config.hidden_size
|
| 55 |
+
|
| 56 |
+
self.w1 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False)
|
| 57 |
+
self.w2 = nn.Linear(self.ffn_dim, self.hidden_dim, bias=False)
|
| 58 |
+
self.w3 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False)
|
| 59 |
+
|
| 60 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 61 |
+
|
| 62 |
+
def forward(self, hidden_states):
|
| 63 |
+
current_hidden_states = self.act_fn(self.w1(hidden_states)) * self.w3(hidden_states)
|
| 64 |
+
current_hidden_states = self.w2(current_hidden_states)
|
| 65 |
+
return current_hidden_states
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class MiniMaxM2Experts(nn.ModuleList):
|
| 69 |
+
"""
|
| 70 |
+
ModuleList of experts.
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
def __init__(self, config: MiniMaxM2Config):
|
| 74 |
+
super().__init__()
|
| 75 |
+
self.top_k = config.num_experts_per_tok
|
| 76 |
+
self.num_experts = config.num_local_experts
|
| 77 |
+
for _ in range(self.num_experts):
|
| 78 |
+
self.append(MiniMaxM2MLP(config))
|
| 79 |
+
|
| 80 |
+
def forward(
|
| 81 |
+
self, hidden_states: torch.Tensor, top_k_index: torch.Tensor, top_k_weights: torch.Tensor
|
| 82 |
+
) -> torch.Tensor:
|
| 83 |
+
"""
|
| 84 |
+
Args:
|
| 85 |
+
hidden_states: (batch_size * sequence_length, hidden_dim)
|
| 86 |
+
selected_experts: (batch_size * sequence_length, top_k)
|
| 87 |
+
routing_weights: (batch_size * sequence_length, top_k)
|
| 88 |
+
Returns:
|
| 89 |
+
(batch_size * sequence_length, hidden_dim)
|
| 90 |
+
"""
|
| 91 |
+
final_hidden_states = torch.zeros_like(hidden_states)
|
| 92 |
+
expert_mask = torch.nn.functional.one_hot(top_k_index, num_classes=self.num_experts).permute(2, 1, 0)
|
| 93 |
+
|
| 94 |
+
expert_hit = torch.greater(expert_mask.sum(dim=(-1, -2)), 0).nonzero()
|
| 95 |
+
for expert_idx in expert_hit:
|
| 96 |
+
idx, top_x = torch.where(expert_mask[expert_idx].squeeze(0))
|
| 97 |
+
current_state = hidden_states[None, top_x].reshape(-1, hidden_states.shape[-1])
|
| 98 |
+
current_hidden_states = self[expert_idx](current_state) * top_k_weights[top_x, idx, None]
|
| 99 |
+
final_hidden_states.index_add_(0, top_x, current_hidden_states.to(hidden_states.dtype))
|
| 100 |
+
return final_hidden_states
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
class MiniMaxM2SparseMoeBlock(nn.Module):
|
| 104 |
+
def __init__(self, config):
|
| 105 |
+
super().__init__()
|
| 106 |
+
self.top_k = config.num_experts_per_tok
|
| 107 |
+
self.jitter_noise = config.router_jitter_noise
|
| 108 |
+
self.gate = nn.Linear(config.hidden_size, config.num_local_experts, bias=False)
|
| 109 |
+
self.experts = MiniMaxM2Experts(config)
|
| 110 |
+
self.register_buffer("e_score_correction_bias", torch.zeros(config.num_local_experts))
|
| 111 |
+
|
| 112 |
+
def route_tokens_to_experts(self, router_logits):
|
| 113 |
+
routing_weights = torch.nn.functional.sigmoid(router_logits.float())
|
| 114 |
+
scores_for_choice = routing_weights + self.e_score_correction_bias
|
| 115 |
+
_, top_k_index = torch.topk(scores_for_choice, self.top_k, dim=-1, sorted=False)
|
| 116 |
+
top_k_weights = routing_weights.gather(1, top_k_index)
|
| 117 |
+
top_k_weights /= top_k_weights.sum(dim=-1, keepdim=True)
|
| 118 |
+
return top_k_index, top_k_weights.to(router_logits.dtype)
|
| 119 |
+
|
| 120 |
+
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
| 121 |
+
batch_size, sequence_length, hidden_dim = hidden_states.shape
|
| 122 |
+
if self.training and self.jitter_noise > 0:
|
| 123 |
+
hidden_states *= torch.empty_like(hidden_states).uniform_(1.0 - self.jitter_noise, 1.0 + self.jitter_noise)
|
| 124 |
+
hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
|
| 125 |
+
router_logits = self.gate(hidden_states)
|
| 126 |
+
top_k_index, top_k_weights = self.route_tokens_to_experts(router_logits)
|
| 127 |
+
hidden_states = self.experts(hidden_states, top_k_index, top_k_weights.to(hidden_states.dtype))
|
| 128 |
+
hidden_states = hidden_states.reshape(batch_size, sequence_length, hidden_dim)
|
| 129 |
+
return hidden_states, router_logits
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
@use_kernel_forward_from_hub("RMSNorm")
|
| 133 |
+
class MiniMaxM2RMSNorm(nn.Module):
|
| 134 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 135 |
+
"""
|
| 136 |
+
MiniMaxM2RMSNorm is equivalent to T5LayerNorm
|
| 137 |
+
"""
|
| 138 |
+
super().__init__()
|
| 139 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 140 |
+
self.variance_epsilon = eps
|
| 141 |
+
|
| 142 |
+
def forward(self, hidden_states):
|
| 143 |
+
input_dtype = hidden_states.dtype
|
| 144 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 145 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 146 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 147 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 148 |
+
|
| 149 |
+
def extra_repr(self):
|
| 150 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 154 |
+
"""
|
| 155 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
| 156 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
| 157 |
+
"""
|
| 158 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 159 |
+
if n_rep == 1:
|
| 160 |
+
return hidden_states
|
| 161 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 162 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def eager_attention_forward(
|
| 166 |
+
module: nn.Module,
|
| 167 |
+
query: torch.Tensor,
|
| 168 |
+
key: torch.Tensor,
|
| 169 |
+
value: torch.Tensor,
|
| 170 |
+
attention_mask: Optional[torch.Tensor],
|
| 171 |
+
scaling: float,
|
| 172 |
+
dropout: float = 0.0,
|
| 173 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 174 |
+
):
|
| 175 |
+
key_states = repeat_kv(key, module.num_key_value_groups)
|
| 176 |
+
value_states = repeat_kv(value, module.num_key_value_groups)
|
| 177 |
+
|
| 178 |
+
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
|
| 179 |
+
if attention_mask is not None:
|
| 180 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 181 |
+
attn_weights = attn_weights + causal_mask
|
| 182 |
+
|
| 183 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 184 |
+
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
|
| 185 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 186 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 187 |
+
|
| 188 |
+
return attn_output, attn_weights
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def rotate_half(x):
|
| 192 |
+
"""Rotates half the hidden dims of the input."""
|
| 193 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 194 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 195 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
|
| 199 |
+
"""Applies Rotary Position Embedding to the query and key tensors.
|
| 200 |
+
|
| 201 |
+
Args:
|
| 202 |
+
q (`torch.Tensor`): The query tensor.
|
| 203 |
+
k (`torch.Tensor`): The key tensor.
|
| 204 |
+
cos (`torch.Tensor`): The cosine part of the rotary embedding.
|
| 205 |
+
sin (`torch.Tensor`): The sine part of the rotary embedding.
|
| 206 |
+
position_ids (`torch.Tensor`, *optional*):
|
| 207 |
+
Deprecated and unused.
|
| 208 |
+
unsqueeze_dim (`int`, *optional*, defaults to 1):
|
| 209 |
+
The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
|
| 210 |
+
sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
|
| 211 |
+
that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
|
| 212 |
+
k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
|
| 213 |
+
cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
|
| 214 |
+
the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
|
| 215 |
+
Returns:
|
| 216 |
+
`tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
|
| 217 |
+
"""
|
| 218 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 219 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 220 |
+
|
| 221 |
+
# Keep half or full tensor for later concatenation
|
| 222 |
+
rotary_dim = cos.shape[-1]
|
| 223 |
+
q_rot, q_pass = q[..., :rotary_dim], q[..., rotary_dim:]
|
| 224 |
+
k_rot, k_pass = k[..., :rotary_dim], k[..., rotary_dim:]
|
| 225 |
+
|
| 226 |
+
# Apply rotary embeddings on the first half or full tensor
|
| 227 |
+
q_embed = (q_rot * cos) + (rotate_half(q_rot) * sin)
|
| 228 |
+
k_embed = (k_rot * cos) + (rotate_half(k_rot) * sin)
|
| 229 |
+
|
| 230 |
+
# Concatenate back to full shape
|
| 231 |
+
q_embed = torch.cat([q_embed, q_pass], dim=-1)
|
| 232 |
+
k_embed = torch.cat([k_embed, k_pass], dim=-1)
|
| 233 |
+
return q_embed, k_embed
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class MiniMaxM2Attention(nn.Module):
|
| 237 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
| 238 |
+
|
| 239 |
+
def __init__(self, config: MiniMaxM2Config, layer_idx: int):
|
| 240 |
+
super().__init__()
|
| 241 |
+
self.config = config
|
| 242 |
+
self.layer_idx = layer_idx
|
| 243 |
+
self.head_dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads
|
| 244 |
+
self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
|
| 245 |
+
self.scaling = self.head_dim**-0.5
|
| 246 |
+
self.attention_dropout = config.attention_dropout
|
| 247 |
+
self.is_causal = True
|
| 248 |
+
self.q_proj = nn.Linear(config.hidden_size, config.num_attention_heads * self.head_dim, bias=False)
|
| 249 |
+
self.k_proj = nn.Linear(config.hidden_size, config.num_key_value_heads * self.head_dim, bias=False)
|
| 250 |
+
self.v_proj = nn.Linear(config.hidden_size, config.num_key_value_heads * self.head_dim, bias=False)
|
| 251 |
+
self.o_proj = nn.Linear(config.num_attention_heads * self.head_dim, config.hidden_size, bias=False)
|
| 252 |
+
|
| 253 |
+
self.use_qk_norm = config.use_qk_norm
|
| 254 |
+
if self.use_qk_norm:
|
| 255 |
+
self.q_norm = MiniMaxM2RMSNorm(self.head_dim * config.num_attention_heads, eps=config.rms_norm_eps)
|
| 256 |
+
self.k_norm = MiniMaxM2RMSNorm(self.head_dim * config.num_key_value_heads, eps=config.rms_norm_eps)
|
| 257 |
+
|
| 258 |
+
@deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")
|
| 259 |
+
def forward(
|
| 260 |
+
self,
|
| 261 |
+
hidden_states: torch.Tensor,
|
| 262 |
+
position_embeddings: tuple[torch.Tensor, torch.Tensor],
|
| 263 |
+
attention_mask: Optional[torch.Tensor],
|
| 264 |
+
past_key_values: Optional[Cache] = None,
|
| 265 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 266 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 267 |
+
) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
|
| 268 |
+
input_shape = hidden_states.shape[:-1]
|
| 269 |
+
hidden_shape = (*input_shape, -1, self.head_dim)
|
| 270 |
+
|
| 271 |
+
query_states = self.q_proj(hidden_states)
|
| 272 |
+
key_states = self.k_proj(hidden_states)
|
| 273 |
+
value_states = self.v_proj(hidden_states)
|
| 274 |
+
|
| 275 |
+
if self.use_qk_norm: # main diff from Llama
|
| 276 |
+
query_states = self.q_norm(query_states)
|
| 277 |
+
key_states = self.k_norm(key_states)
|
| 278 |
+
|
| 279 |
+
key_states = key_states.view(hidden_shape)
|
| 280 |
+
query_states = query_states.view(hidden_shape)
|
| 281 |
+
value_states = value_states.view(hidden_shape)
|
| 282 |
+
|
| 283 |
+
query_states = query_states.transpose(1, 2)
|
| 284 |
+
key_states = key_states.transpose(1, 2)
|
| 285 |
+
value_states = value_states.transpose(1, 2)
|
| 286 |
+
|
| 287 |
+
cos, sin = position_embeddings
|
| 288 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 289 |
+
|
| 290 |
+
if past_key_values is not None:
|
| 291 |
+
# sin and cos are specific to RoPE models; position_ids needed for the static cache
|
| 292 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 293 |
+
key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 294 |
+
|
| 295 |
+
attention_interface: Callable = eager_attention_forward
|
| 296 |
+
if self.config._attn_implementation != "eager":
|
| 297 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 298 |
+
|
| 299 |
+
attn_output, attn_weights = attention_interface(
|
| 300 |
+
self,
|
| 301 |
+
query_states,
|
| 302 |
+
key_states,
|
| 303 |
+
value_states,
|
| 304 |
+
attention_mask,
|
| 305 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 306 |
+
scaling=self.scaling,
|
| 307 |
+
**kwargs,
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 311 |
+
attn_output = self.o_proj(attn_output)
|
| 312 |
+
return attn_output, attn_weights
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
class MiniMaxM2DecoderLayer(GradientCheckpointingLayer):
|
| 316 |
+
def __init__(self, config: MiniMaxM2Config, layer_idx: int):
|
| 317 |
+
super().__init__()
|
| 318 |
+
self.hidden_size = config.hidden_size
|
| 319 |
+
|
| 320 |
+
self.self_attn = MiniMaxM2Attention(config, layer_idx)
|
| 321 |
+
|
| 322 |
+
self.block_sparse_moe = MiniMaxM2SparseMoeBlock(config)
|
| 323 |
+
self.input_layernorm = MiniMaxM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 324 |
+
self.post_attention_layernorm = MiniMaxM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 325 |
+
|
| 326 |
+
@deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")
|
| 327 |
+
def forward(
|
| 328 |
+
self,
|
| 329 |
+
hidden_states: torch.Tensor,
|
| 330 |
+
position_embeddings: tuple[torch.Tensor, torch.Tensor],
|
| 331 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 332 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 333 |
+
past_key_values: Optional[Cache] = None,
|
| 334 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 335 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 336 |
+
) -> torch.FloatTensor:
|
| 337 |
+
residual = hidden_states
|
| 338 |
+
|
| 339 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 340 |
+
|
| 341 |
+
# Self Attention
|
| 342 |
+
hidden_states, _ = self.self_attn(
|
| 343 |
+
hidden_states=hidden_states,
|
| 344 |
+
position_embeddings=position_embeddings,
|
| 345 |
+
attention_mask=attention_mask,
|
| 346 |
+
position_ids=position_ids,
|
| 347 |
+
past_key_values=past_key_values,
|
| 348 |
+
cache_position=cache_position,
|
| 349 |
+
**kwargs,
|
| 350 |
+
)
|
| 351 |
+
hidden_states = residual + hidden_states
|
| 352 |
+
|
| 353 |
+
# Fully Connected
|
| 354 |
+
residual = hidden_states
|
| 355 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 356 |
+
hidden_states, _ = self.block_sparse_moe(hidden_states)
|
| 357 |
+
hidden_states = residual + hidden_states
|
| 358 |
+
|
| 359 |
+
return hidden_states
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
class MiniMaxM2RotaryEmbedding(nn.Module):
|
| 363 |
+
inv_freq: torch.Tensor # fix linting for `register_buffer`
|
| 364 |
+
|
| 365 |
+
def __init__(self, config: MiniMaxM2Config, device=None):
|
| 366 |
+
super().__init__()
|
| 367 |
+
# BC: "rope_type" was originally "type"
|
| 368 |
+
if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict):
|
| 369 |
+
self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
|
| 370 |
+
else:
|
| 371 |
+
self.rope_type = "default"
|
| 372 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 373 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 374 |
+
|
| 375 |
+
self.config = config
|
| 376 |
+
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 377 |
+
|
| 378 |
+
inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
|
| 379 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 380 |
+
self.original_inv_freq = self.inv_freq
|
| 381 |
+
|
| 382 |
+
@torch.no_grad()
|
| 383 |
+
@dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
|
| 384 |
+
def forward(self, x, position_ids):
|
| 385 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
|
| 386 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 387 |
+
|
| 388 |
+
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
|
| 389 |
+
with torch.autocast(device_type=device_type, enabled=False): # Force float32
|
| 390 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
|
| 391 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 392 |
+
cos = emb.cos() * self.attention_scaling
|
| 393 |
+
sin = emb.sin() * self.attention_scaling
|
| 394 |
+
|
| 395 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
@auto_docstring
|
| 399 |
+
class MiniMaxM2PreTrainedModel(PreTrainedModel):
|
| 400 |
+
config: MiniMaxM2Config
|
| 401 |
+
base_model_prefix = "model"
|
| 402 |
+
supports_gradient_checkpointing = True
|
| 403 |
+
_no_split_modules = ["MiniMaxM2DecoderLayer"]
|
| 404 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 405 |
+
_supports_flash_attn = True
|
| 406 |
+
_supports_sdpa = True
|
| 407 |
+
_supports_flex_attn = True
|
| 408 |
+
_can_compile_fullgraph = False # MoE models don't work with torch.compile (`torch.where(condition)` not supported)
|
| 409 |
+
_supports_attention_backend = True
|
| 410 |
+
_can_record_outputs = {
|
| 411 |
+
"router_logits": OutputRecorder(MiniMaxM2SparseMoeBlock, index=1),
|
| 412 |
+
"hidden_states": MiniMaxM2DecoderLayer,
|
| 413 |
+
"attentions": MiniMaxM2Attention,
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
@auto_docstring
|
| 418 |
+
class MiniMaxM2Model(MiniMaxM2PreTrainedModel):
|
| 419 |
+
def __init__(self, config: MiniMaxM2Config):
|
| 420 |
+
super().__init__(config)
|
| 421 |
+
self.padding_idx = config.pad_token_id
|
| 422 |
+
self.vocab_size = config.vocab_size
|
| 423 |
+
|
| 424 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 425 |
+
self.layers = nn.ModuleList(
|
| 426 |
+
[MiniMaxM2DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
|
| 427 |
+
)
|
| 428 |
+
self.norm = MiniMaxM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 429 |
+
self.rotary_emb = MiniMaxM2RotaryEmbedding(config=config)
|
| 430 |
+
self.gradient_checkpointing = False
|
| 431 |
+
|
| 432 |
+
# Initialize weights and apply final processing
|
| 433 |
+
self.post_init()
|
| 434 |
+
|
| 435 |
+
@check_model_inputs
|
| 436 |
+
@auto_docstring
|
| 437 |
+
def forward(
|
| 438 |
+
self,
|
| 439 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 440 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 441 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 442 |
+
past_key_values: Optional[Cache] = None,
|
| 443 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 444 |
+
use_cache: Optional[bool] = None,
|
| 445 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 446 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 447 |
+
) -> MoeModelOutputWithPast:
|
| 448 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 449 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 450 |
+
|
| 451 |
+
if use_cache and past_key_values is None:
|
| 452 |
+
past_key_values = DynamicCache(config=self.config)
|
| 453 |
+
|
| 454 |
+
if inputs_embeds is None:
|
| 455 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 456 |
+
|
| 457 |
+
if cache_position is None:
|
| 458 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 459 |
+
cache_position = torch.arange(
|
| 460 |
+
past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
|
| 461 |
+
)
|
| 462 |
+
if position_ids is None:
|
| 463 |
+
position_ids = cache_position.unsqueeze(0)
|
| 464 |
+
|
| 465 |
+
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 466 |
+
causal_mask = mask_function(
|
| 467 |
+
config=self.config,
|
| 468 |
+
input_embeds=inputs_embeds,
|
| 469 |
+
attention_mask=attention_mask,
|
| 470 |
+
cache_position=cache_position,
|
| 471 |
+
past_key_values=past_key_values,
|
| 472 |
+
position_ids=position_ids,
|
| 473 |
+
)
|
| 474 |
+
|
| 475 |
+
hidden_states = inputs_embeds
|
| 476 |
+
|
| 477 |
+
# create position embeddings to be shared across the decoder layers
|
| 478 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 479 |
+
|
| 480 |
+
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 481 |
+
hidden_states = decoder_layer(
|
| 482 |
+
hidden_states,
|
| 483 |
+
position_embeddings=position_embeddings,
|
| 484 |
+
attention_mask=causal_mask,
|
| 485 |
+
position_ids=position_ids,
|
| 486 |
+
past_key_values=past_key_values,
|
| 487 |
+
use_cache=use_cache,
|
| 488 |
+
cache_position=cache_position,
|
| 489 |
+
**kwargs,
|
| 490 |
+
)
|
| 491 |
+
|
| 492 |
+
hidden_states = self.norm(hidden_states)
|
| 493 |
+
|
| 494 |
+
return MoeModelOutputWithPast( # only diff with Mistral is the output type, we need MoE
|
| 495 |
+
last_hidden_state=hidden_states,
|
| 496 |
+
past_key_values=past_key_values,
|
| 497 |
+
)
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
def load_balancing_loss_func(
|
| 501 |
+
gate_logits: Union[torch.Tensor, tuple[torch.Tensor], None],
|
| 502 |
+
num_experts: Optional[int] = None,
|
| 503 |
+
top_k=2,
|
| 504 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 505 |
+
) -> Union[torch.Tensor, int]:
|
| 506 |
+
r"""
|
| 507 |
+
Computes auxiliary load balancing loss as in Switch Transformer - implemented in Pytorch.
|
| 508 |
+
|
| 509 |
+
See Switch Transformer (https://huggingface.co/papers/2101.03961) for more details. This function implements the loss
|
| 510 |
+
function presented in equations (4) - (6) of the paper. It aims at penalizing cases where the routing between
|
| 511 |
+
experts is too unbalanced.
|
| 512 |
+
|
| 513 |
+
Args:
|
| 514 |
+
gate_logits:
|
| 515 |
+
Logits from the `gate`, should be a tuple of model.config.num_hidden_layers tensors of
|
| 516 |
+
shape [batch_size X sequence_length, num_experts].
|
| 517 |
+
num_experts:
|
| 518 |
+
Number of experts
|
| 519 |
+
top_k:
|
| 520 |
+
The number of experts to route per-token, can be also interpreted as the `top-k` routing
|
| 521 |
+
parameter.
|
| 522 |
+
attention_mask (`torch.Tensor`, *optional*):
|
| 523 |
+
The attention_mask used in forward function
|
| 524 |
+
shape [batch_size X sequence_length] if not None.
|
| 525 |
+
|
| 526 |
+
Returns:
|
| 527 |
+
The auxiliary loss.
|
| 528 |
+
"""
|
| 529 |
+
if gate_logits is None or not isinstance(gate_logits, tuple):
|
| 530 |
+
return 0
|
| 531 |
+
|
| 532 |
+
if isinstance(gate_logits, tuple):
|
| 533 |
+
compute_device = gate_logits[0].device
|
| 534 |
+
concatenated_gate_logits = torch.cat([layer_gate.to(compute_device) for layer_gate in gate_logits], dim=0)
|
| 535 |
+
|
| 536 |
+
routing_weights = torch.nn.functional.softmax(concatenated_gate_logits, dim=-1)
|
| 537 |
+
|
| 538 |
+
_, selected_experts = torch.topk(routing_weights, top_k, dim=-1)
|
| 539 |
+
|
| 540 |
+
expert_mask = torch.nn.functional.one_hot(selected_experts, num_experts)
|
| 541 |
+
|
| 542 |
+
if attention_mask is None:
|
| 543 |
+
# Compute the percentage of tokens routed to each experts
|
| 544 |
+
tokens_per_expert = torch.mean(expert_mask.float(), dim=0)
|
| 545 |
+
|
| 546 |
+
# Compute the average probability of routing to these experts
|
| 547 |
+
router_prob_per_expert = torch.mean(routing_weights, dim=0)
|
| 548 |
+
else:
|
| 549 |
+
batch_size, sequence_length = attention_mask.shape
|
| 550 |
+
num_hidden_layers = concatenated_gate_logits.shape[0] // (batch_size * sequence_length)
|
| 551 |
+
|
| 552 |
+
# Compute the mask that masks all padding tokens as 0 with the same shape of expert_mask
|
| 553 |
+
expert_attention_mask = (
|
| 554 |
+
attention_mask[None, :, :, None, None]
|
| 555 |
+
.expand((num_hidden_layers, batch_size, sequence_length, top_k, num_experts))
|
| 556 |
+
.reshape(-1, top_k, num_experts)
|
| 557 |
+
.to(compute_device)
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
# Compute the percentage of tokens routed to each experts
|
| 561 |
+
tokens_per_expert = torch.sum(expert_mask.float() * expert_attention_mask, dim=0) / torch.sum(
|
| 562 |
+
expert_attention_mask, dim=0
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
# Compute the mask that masks all padding tokens as 0 with the same shape of tokens_per_expert
|
| 566 |
+
router_per_expert_attention_mask = (
|
| 567 |
+
attention_mask[None, :, :, None]
|
| 568 |
+
.expand((num_hidden_layers, batch_size, sequence_length, num_experts))
|
| 569 |
+
.reshape(-1, num_experts)
|
| 570 |
+
.to(compute_device)
|
| 571 |
+
)
|
| 572 |
+
|
| 573 |
+
# Compute the average probability of routing to these experts
|
| 574 |
+
router_prob_per_expert = torch.sum(routing_weights * router_per_expert_attention_mask, dim=0) / torch.sum(
|
| 575 |
+
router_per_expert_attention_mask, dim=0
|
| 576 |
+
)
|
| 577 |
+
|
| 578 |
+
overall_loss = torch.sum(tokens_per_expert * router_prob_per_expert.unsqueeze(0))
|
| 579 |
+
return overall_loss * num_experts
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
@auto_docstring
|
| 583 |
+
class MiniMaxM2ForCausalLM(MiniMaxM2PreTrainedModel, GenerationMixin):
|
| 584 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 585 |
+
_tp_plan = {"lm_head": "colwise_rep"}
|
| 586 |
+
_pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
|
| 587 |
+
|
| 588 |
+
def __init__(self, config):
|
| 589 |
+
super().__init__(config)
|
| 590 |
+
self.model = MiniMaxM2Model(config)
|
| 591 |
+
self.vocab_size = config.vocab_size
|
| 592 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 593 |
+
self.router_aux_loss_coef = config.router_aux_loss_coef
|
| 594 |
+
self.num_experts = config.num_local_experts
|
| 595 |
+
self.num_experts_per_tok = config.num_experts_per_tok
|
| 596 |
+
|
| 597 |
+
# Initialize weights and apply final processing
|
| 598 |
+
self.post_init()
|
| 599 |
+
|
| 600 |
+
@can_return_tuple
|
| 601 |
+
@auto_docstring
|
| 602 |
+
def forward(
|
| 603 |
+
self,
|
| 604 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 605 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 606 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 607 |
+
past_key_values: Optional[Cache] = None,
|
| 608 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 609 |
+
labels: Optional[torch.LongTensor] = None,
|
| 610 |
+
use_cache: Optional[bool] = None,
|
| 611 |
+
output_router_logits: Optional[bool] = None,
|
| 612 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 613 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 614 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 615 |
+
) -> MoeCausalLMOutputWithPast:
|
| 616 |
+
r"""
|
| 617 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 618 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 619 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 620 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 621 |
+
|
| 622 |
+
Example:
|
| 623 |
+
|
| 624 |
+
```python
|
| 625 |
+
>>> from transformers import AutoTokenizer, MiniMaxM2ForCausalLM
|
| 626 |
+
|
| 627 |
+
>>> model = MiniMaxM2ForCausalLM.from_pretrained("mistralai/MiniMaxM2-8x7B-v0.1")
|
| 628 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("mistralai/MiniMaxM2-8x7B-v0.1")
|
| 629 |
+
|
| 630 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
| 631 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
| 632 |
+
|
| 633 |
+
>>> # Generate
|
| 634 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 635 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 636 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
| 637 |
+
```"""
|
| 638 |
+
|
| 639 |
+
output_router_logits = (
|
| 640 |
+
output_router_logits if output_router_logits is not None else self.config.output_router_logits
|
| 641 |
+
)
|
| 642 |
+
|
| 643 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
| 644 |
+
outputs: MoeModelOutputWithPast = self.model(
|
| 645 |
+
input_ids=input_ids,
|
| 646 |
+
attention_mask=attention_mask,
|
| 647 |
+
position_ids=position_ids,
|
| 648 |
+
past_key_values=past_key_values,
|
| 649 |
+
inputs_embeds=inputs_embeds,
|
| 650 |
+
use_cache=use_cache,
|
| 651 |
+
output_router_logits=output_router_logits,
|
| 652 |
+
cache_position=cache_position,
|
| 653 |
+
**kwargs,
|
| 654 |
+
)
|
| 655 |
+
|
| 656 |
+
hidden_states = outputs.last_hidden_state
|
| 657 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 658 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 659 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 660 |
+
|
| 661 |
+
loss = None
|
| 662 |
+
if labels is not None:
|
| 663 |
+
loss = self.loss_function(logits, labels, self.vocab_size, **kwargs)
|
| 664 |
+
|
| 665 |
+
aux_loss = None
|
| 666 |
+
if output_router_logits:
|
| 667 |
+
aux_loss = load_balancing_loss_func(
|
| 668 |
+
outputs.router_logits,
|
| 669 |
+
self.num_experts,
|
| 670 |
+
self.num_experts_per_tok,
|
| 671 |
+
attention_mask,
|
| 672 |
+
)
|
| 673 |
+
if labels is not None:
|
| 674 |
+
loss += self.router_aux_loss_coef * aux_loss.to(loss.device) # make sure to reside in the same device
|
| 675 |
+
|
| 676 |
+
return MoeCausalLMOutputWithPast(
|
| 677 |
+
loss=loss,
|
| 678 |
+
aux_loss=aux_loss,
|
| 679 |
+
logits=logits,
|
| 680 |
+
past_key_values=outputs.past_key_values,
|
| 681 |
+
hidden_states=outputs.hidden_states,
|
| 682 |
+
attentions=outputs.attentions,
|
| 683 |
+
router_logits=outputs.router_logits,
|
| 684 |
+
)
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
class MiniMaxM2ForSequenceClassification(GenericForSequenceClassification, MiniMaxM2PreTrainedModel):
|
| 688 |
+
pass
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
class MiniMaxM2ForTokenClassification(GenericForTokenClassification, MiniMaxM2PreTrainedModel):
|
| 692 |
+
pass
|
| 693 |
+
|
| 694 |
+
|
| 695 |
+
class MiniMaxM2ForQuestionAnswering(GenericForQuestionAnswering, MiniMaxM2PreTrainedModel):
|
| 696 |
+
pass
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
__all__ = [
|
| 700 |
+
"MiniMaxM2ForCausalLM",
|
| 701 |
+
"MiniMaxM2ForQuestionAnswering",
|
| 702 |
+
"MiniMaxM2Model",
|
| 703 |
+
"MiniMaxM2PreTrainedModel",
|
| 704 |
+
"MiniMaxM2ForSequenceClassification",
|
| 705 |
+
"MiniMaxM2ForTokenClassification",
|
| 706 |
+
]
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"200000": {
|
| 4 |
+
"content": "]!p~[",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"200001": {
|
| 12 |
+
"content": "<fim_prefix>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"200002": {
|
| 20 |
+
"content": "<fim_middle>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"200003": {
|
| 28 |
+
"content": "<fim_suffix>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"200004": {
|
| 36 |
+
"content": "<fim_pad>",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"200005": {
|
| 44 |
+
"content": "<reponame>",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"200006": {
|
| 52 |
+
"content": "<filename>",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
},
|
| 59 |
+
"200007": {
|
| 60 |
+
"content": "<gh_stars>",
|
| 61 |
+
"lstrip": false,
|
| 62 |
+
"normalized": false,
|
| 63 |
+
"rstrip": false,
|
| 64 |
+
"single_word": false,
|
| 65 |
+
"special": true
|
| 66 |
+
},
|
| 67 |
+
"200008": {
|
| 68 |
+
"content": "<issue_start>",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false,
|
| 73 |
+
"special": true
|
| 74 |
+
},
|
| 75 |
+
"200009": {
|
| 76 |
+
"content": "<issue_comment>",
|
| 77 |
+
"lstrip": false,
|
| 78 |
+
"normalized": false,
|
| 79 |
+
"rstrip": false,
|
| 80 |
+
"single_word": false,
|
| 81 |
+
"special": true
|
| 82 |
+
},
|
| 83 |
+
"200010": {
|
| 84 |
+
"content": "<issue_closed>",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"200011": {
|
| 92 |
+
"content": "<jupyter_start>",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"200012": {
|
| 100 |
+
"content": "<jupyter_text>",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"200013": {
|
| 108 |
+
"content": "<jupyter_code>",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"200014": {
|
| 116 |
+
"content": "<jupyter_output>",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"200015": {
|
| 124 |
+
"content": "<empty_output>",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"200016": {
|
| 132 |
+
"content": "<commit_before>",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"200017": {
|
| 140 |
+
"content": "<commit_msg>",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"200018": {
|
| 148 |
+
"content": "<commit_after>",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"200019": {
|
| 156 |
+
"content": "]~b]",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"200020": {
|
| 164 |
+
"content": "[e~[",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"200021": {
|
| 172 |
+
"content": "]!d~[",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"200022": {
|
| 180 |
+
"content": "<function_call>",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"200023": {
|
| 188 |
+
"content": "<code_interpreter>",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"200024": {
|
| 196 |
+
"content": "]<]speech[>[",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"200025": {
|
| 204 |
+
"content": "]<]image[>[",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"200026": {
|
| 212 |
+
"content": "]<]video[>[",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"200027": {
|
| 220 |
+
"content": "]<]start of speech[>[",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"200028": {
|
| 228 |
+
"content": "]<]end of speech[>[",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"200029": {
|
| 236 |
+
"content": "]<]start of image[>[",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"200030": {
|
| 244 |
+
"content": "]<]end of image[>[",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"200031": {
|
| 252 |
+
"content": "]<]start of video[>[",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"200032": {
|
| 260 |
+
"content": "]<]end of video[>[",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"200033": {
|
| 268 |
+
"content": "]<]vision pad[>[",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"200034": {
|
| 276 |
+
"content": "]~!b[",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"200035": {
|
| 284 |
+
"content": "<jupyter_error>",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"200036": {
|
| 292 |
+
"content": "<add_file>",
|
| 293 |
+
"single_word": false,
|
| 294 |
+
"lstrip": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"normalized": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"200037": {
|
| 300 |
+
"content": "<delete_file>",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"200038": {
|
| 308 |
+
"content": "<rename_file>",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"200039": {
|
| 316 |
+
"content": "<edit_file>",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"200040": {
|
| 324 |
+
"content": "<commit_message>",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"200041": {
|
| 332 |
+
"content": "<empty_source_file>",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"200042": {
|
| 340 |
+
"content": "<repo_struct>",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"200043": {
|
| 348 |
+
"content": "<code_context>",
|
| 349 |
+
"single_word": false,
|
| 350 |
+
"lstrip": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"normalized": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"200044": {
|
| 356 |
+
"content": "<file_content>",
|
| 357 |
+
"single_word": false,
|
| 358 |
+
"lstrip": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"normalized": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"200045": {
|
| 364 |
+
"content": "<source_files>",
|
| 365 |
+
"single_word": false,
|
| 366 |
+
"lstrip": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"normalized": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"200046": {
|
| 372 |
+
"content": "<pr_start>",
|
| 373 |
+
"single_word": false,
|
| 374 |
+
"lstrip": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"normalized": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"200047": {
|
| 380 |
+
"content": "<review_comment>",
|
| 381 |
+
"single_word": false,
|
| 382 |
+
"lstrip": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"normalized": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"200048": {
|
| 388 |
+
"content": "<filepath>",
|
| 389 |
+
"single_word": false,
|
| 390 |
+
"lstrip": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"normalized": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"200049": {
|
| 396 |
+
"content": "<file_sep>",
|
| 397 |
+
"single_word": false,
|
| 398 |
+
"lstrip": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"normalized": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"200050": {
|
| 404 |
+
"content": "<think>",
|
| 405 |
+
"single_word": false,
|
| 406 |
+
"lstrip": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"normalized": false,
|
| 409 |
+
"special": false
|
| 410 |
+
},
|
| 411 |
+
"200051": {
|
| 412 |
+
"content": "</think>",
|
| 413 |
+
"single_word": false,
|
| 414 |
+
"lstrip": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"normalized": false,
|
| 417 |
+
"special": false
|
| 418 |
+
},
|
| 419 |
+
"200052": {
|
| 420 |
+
"content": "<minimax:tool_call>",
|
| 421 |
+
"single_word": false,
|
| 422 |
+
"lstrip": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"normalized": false,
|
| 425 |
+
"special": false
|
| 426 |
+
},
|
| 427 |
+
"200053": {
|
| 428 |
+
"content": "</minimax:tool_call>",
|
| 429 |
+
"single_word": false,
|
| 430 |
+
"lstrip": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"normalized": false,
|
| 433 |
+
"special": false
|
| 434 |
+
}
|
| 435 |
+
},
|
| 436 |
+
"additional_special_tokens": [
|
| 437 |
+
"<code_interpreter>",
|
| 438 |
+
"<commit_after>",
|
| 439 |
+
"<commit_before>",
|
| 440 |
+
"<commit_msg>",
|
| 441 |
+
"<empty_output>",
|
| 442 |
+
"<filename>",
|
| 443 |
+
"<fim_middle>",
|
| 444 |
+
"<fim_pad>",
|
| 445 |
+
"<fim_prefix>",
|
| 446 |
+
"<fim_suffix>",
|
| 447 |
+
"<function_call>",
|
| 448 |
+
"<gh_stars>",
|
| 449 |
+
"]<]speech[>[",
|
| 450 |
+
"]<]image[>[",
|
| 451 |
+
"]<]video[>[",
|
| 452 |
+
"]<]start of speech[>[",
|
| 453 |
+
"]<]end of speech[>[",
|
| 454 |
+
"]<]start of image[>[",
|
| 455 |
+
"]<]end of image[>[",
|
| 456 |
+
"]<]start of video[>[",
|
| 457 |
+
"]<]end of video[>[",
|
| 458 |
+
"]<]vision pad[>[",
|
| 459 |
+
"]~!b[",
|
| 460 |
+
"<issue_closed>",
|
| 461 |
+
"<issue_comment>",
|
| 462 |
+
"<issue_start>",
|
| 463 |
+
"<jupyter_code>",
|
| 464 |
+
"<jupyter_output>",
|
| 465 |
+
"<jupyter_start>",
|
| 466 |
+
"<jupyter_text>",
|
| 467 |
+
"<reponame>",
|
| 468 |
+
"[e~[",
|
| 469 |
+
"]!d~[",
|
| 470 |
+
"]!p~[",
|
| 471 |
+
"]~b]",
|
| 472 |
+
"<jupyter_error>",
|
| 473 |
+
"<add_file>",
|
| 474 |
+
"<delete_file>",
|
| 475 |
+
"<rename_file>",
|
| 476 |
+
"<edit_file>",
|
| 477 |
+
"<commit_message>",
|
| 478 |
+
"<empty_source_file>",
|
| 479 |
+
"<repo_struct>",
|
| 480 |
+
"<code_context>",
|
| 481 |
+
"<file_content>",
|
| 482 |
+
"<source_files>",
|
| 483 |
+
"<pr_start>",
|
| 484 |
+
"<review_comment>",
|
| 485 |
+
"<filepath>",
|
| 486 |
+
"<file_sep>"
|
| 487 |
+
],
|
| 488 |
+
"add_prefix_space": false,
|
| 489 |
+
"bos_token": "]~!b[",
|
| 490 |
+
"clean_up_tokenization_spaces": false,
|
| 491 |
+
"eos_token": "[e~[",
|
| 492 |
+
"model_max_length": 40960000,
|
| 493 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 494 |
+
"unk_token": "]!d~["
|
| 495 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|