Text Generation
MLX
Safetensors
minimax_m3
Mixture of Experts
minimax
minimax-m3
conversational
4-bit precision
Instructions to use pipenetwork/MiniMax-M3-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use pipenetwork/MiniMax-M3-MLX-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("pipenetwork/MiniMax-M3-MLX-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use pipenetwork/MiniMax-M3-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "pipenetwork/MiniMax-M3-MLX-4bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "pipenetwork/MiniMax-M3-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use pipenetwork/MiniMax-M3-MLX-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "pipenetwork/MiniMax-M3-MLX-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default pipenetwork/MiniMax-M3-MLX-4bit
Run Hermes
hermes
- OpenClaw new
How to use pipenetwork/MiniMax-M3-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "pipenetwork/MiniMax-M3-MLX-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "pipenetwork/MiniMax-M3-MLX-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- MLX LM
How to use pipenetwork/MiniMax-M3-MLX-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "pipenetwork/MiniMax-M3-MLX-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "pipenetwork/MiniMax-M3-MLX-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pipenetwork/MiniMax-M3-MLX-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }'
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- LICENSE +17 -0
- README.md +70 -0
- chat_template.jinja +247 -0
- config.json +551 -0
- generation_config.json +8 -0
- minimax_m3.py +323 -0
- model-00002-of-00057.safetensors +3 -0
- model-00003-of-00057.safetensors +3 -0
- model-00005-of-00057.safetensors +3 -0
- model-00006-of-00057.safetensors +3 -0
- model-00007-of-00057.safetensors +3 -0
- model-00009-of-00057.safetensors +3 -0
- model-00010-of-00057.safetensors +3 -0
- model-00011-of-00057.safetensors +3 -0
- model-00012-of-00057.safetensors +3 -0
- model-00014-of-00057.safetensors +3 -0
- model-00015-of-00057.safetensors +3 -0
- model-00017-of-00057.safetensors +3 -0
- model-00018-of-00057.safetensors +3 -0
- model-00020-of-00057.safetensors +3 -0
- model-00022-of-00057.safetensors +3 -0
- model-00023-of-00057.safetensors +3 -0
- model-00024-of-00057.safetensors +3 -0
- model-00025-of-00057.safetensors +3 -0
- model-00026-of-00057.safetensors +3 -0
- model-00027-of-00057.safetensors +3 -0
- model-00028-of-00057.safetensors +3 -0
- model-00029-of-00057.safetensors +3 -0
- model-00031-of-00057.safetensors +3 -0
- model-00032-of-00057.safetensors +3 -0
- model-00034-of-00057.safetensors +3 -0
- model-00035-of-00057.safetensors +3 -0
- model-00037-of-00057.safetensors +3 -0
- model-00038-of-00057.safetensors +3 -0
- model-00041-of-00057.safetensors +3 -0
- model-00042-of-00057.safetensors +3 -0
- model-00043-of-00057.safetensors +3 -0
- model-00044-of-00057.safetensors +3 -0
- model-00046-of-00057.safetensors +3 -0
- model-00047-of-00057.safetensors +3 -0
- model-00048-of-00057.safetensors +3 -0
- model-00049-of-00057.safetensors +3 -0
- model-00050-of-00057.safetensors +3 -0
- model-00053-of-00057.safetensors +3 -0
- model-00055-of-00057.safetensors +3 -0
- model-00056-of-00057.safetensors +3 -0
- model-00057-of-00057.safetensors +3 -0
- model.safetensors.index.json +0 -0
- tokenizer.json +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MINIMAX COMMUNITY LICENSE
|
| 2 |
+
Copyright (c) 2026 MiniMax
|
| 3 |
+
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:
|
| 4 |
+
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 5 |
+
2. If the Software (or any derivative works thereof) is used for any Commercial Use for your products or services:
|
| 6 |
+
1. you shall prominently display “Built with MiniMax M3” on a related website, user interface, blogpost, about page or product documentation.
|
| 7 |
+
2. you shall obtain a separate, prior written authorization from MiniMax by contacting api@minimax.io with the subject line “M3 licensing - authorization request”, if such products and services generate more than 20 million US dollars (or equivalent in other currencies) in yearly revenue; otherwise, you only need to send a one-time notice to api@minimax.io with the subject “M3 licensing — notice”.
|
| 8 |
+
3. “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,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: minimax-community
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model: MiniMaxAI/MiniMax-M3
|
| 6 |
+
base_model_relation: quantized
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
library_name: mlx
|
| 9 |
+
tags:
|
| 10 |
+
- mlx
|
| 11 |
+
- moe
|
| 12 |
+
- minimax
|
| 13 |
+
- minimax-m3
|
| 14 |
+
- text-generation
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# MiniMax-M3-MLX-4bit
|
| 18 |
+
|
| 19 |
+
**Built with MiniMax M3.**
|
| 20 |
+
|
| 21 |
+
This is an **MLX** (Apple Silicon) conversion of
|
| 22 |
+
[MiniMaxAI/MiniMax-M3](https://huggingface.co/MiniMaxAI/MiniMax-M3), quantized to
|
| 23 |
+
**4-bit (balanced default)**.
|
| 24 |
+
|
| 25 |
+
It is a **text-only** extraction of the M3 backbone (the vision tower, multimodal
|
| 26 |
+
projector and multi-token-prediction heads are not included). The model is a
|
| 27 |
+
~427B-parameter Mixture-of-Experts (128 experts, top-4, + 1 shared expert; first
|
| 28 |
+
3 layers dense), with per-head QK-norm, partial RoPE, Gemma-style RMSNorm and the
|
| 29 |
+
SwiGLU-OAI activation.
|
| 30 |
+
|
| 31 |
+
## Attention / context note
|
| 32 |
+
|
| 33 |
+
MiniMax Sparse Attention (MSA) is implemented here as **full causal attention**.
|
| 34 |
+
This is numerically exact for sequences up to 2048 tokens (MSA selects every key
|
| 35 |
+
block at that length) and is the dense, un-approximated attention that MSA
|
| 36 |
+
approximates beyond it — so quality is preserved, at the cost of MSA's
|
| 37 |
+
long-context speed/memory savings.
|
| 38 |
+
|
| 39 |
+
## Use with mlx-lm
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
pip install mlx-lm
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
This build requires the `minimax_m3` model class
|
| 46 |
+
([`mlx_lm/models/minimax_m3.py`](https://huggingface.co/pipenetwork/MiniMax-M3-MLX-4bit/blob/main/minimax_m3.py),
|
| 47 |
+
included in this repo — copy it into your `mlx_lm/models/` directory).
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from mlx_lm import load, generate
|
| 51 |
+
|
| 52 |
+
model, tokenizer = load("pipenetwork/MiniMax-M3-MLX-4bit")
|
| 53 |
+
prompt = tokenizer.apply_chat_template(
|
| 54 |
+
[{"role": "user", "content": "Explain Mixture-of-Experts in one paragraph."}],
|
| 55 |
+
add_generation_prompt=True,
|
| 56 |
+
)
|
| 57 |
+
print(generate(model, tokenizer, prompt=prompt, max_tokens=256, verbose=True))
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## License
|
| 61 |
+
|
| 62 |
+
Released under the **MiniMax Community License** (see `LICENSE`). Use is
|
| 63 |
+
**non-commercial** by default; commercial use requires displaying
|
| 64 |
+
"Built with MiniMax M3" and may require prior authorization from MiniMax — see the
|
| 65 |
+
license text for details.
|
| 66 |
+
|
| 67 |
+
## Provenance
|
| 68 |
+
|
| 69 |
+
Converted from the BF16 checkpoint with `mlx-lm` quantization. Quantization
|
| 70 |
+
config: `{"group_size": 64, "bits": 4, "mode": "affine", "model.layers.3.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.4.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.5.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.6.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.7.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.8.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.9.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.10.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.11.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.12.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.13.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.14.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.15.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.16.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.17.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.18.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.19.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.20.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.21.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.22.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.23.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.24.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.25.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.26.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.27.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.28.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.29.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.30.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.31.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.32.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.33.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.34.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.35.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.36.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.37.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.38.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.39.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.40.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.41.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.42.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.43.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.44.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.45.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.46.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.47.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.48.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.49.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.50.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.51.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.52.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.53.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.54.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.55.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.56.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.57.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.58.block_sparse_moe.gate": {"group_size": 64, "bits": 8}, "model.layers.59.block_sparse_moe.gate": {"group_size": 64, "bits": 8}}`.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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']<]minimax[>[' -%}
|
| 3 |
+
{%- set bod_token = ']~!b[' -%}
|
| 4 |
+
{%- set bos_token = ']~b]' -%}
|
| 5 |
+
{%- set eos_token = '[e~[' -%}
|
| 6 |
+
{%- set toolcall_begin_token = ns_token ~ '<tool_call>' -%}
|
| 7 |
+
{%- set toolcall_end_token = ns_token ~ '</tool_call>' -%}
|
| 8 |
+
{%- set think_begin_token = '<mm:think>' -%}
|
| 9 |
+
{%- set think_end_token = '</mm:think>' -%}
|
| 10 |
+
{%- set image_token = ']<]image[>[' -%}
|
| 11 |
+
{%- set video_token = ']<]video[>[' -%}
|
| 12 |
+
{#- Thinking mode: "enabled" / "disabled" / "adaptive" / not defined -#}
|
| 13 |
+
{#- Recursive XML renderer for tool_call arguments ======================== -#}
|
| 14 |
+
{#- None values are intentionally skipped in mapping iteration so that
|
| 15 |
+
`<key>null</key>` (which would round-trip to the literal string "null")
|
| 16 |
+
never appears in the rendered tool_call. The convention is: omit the
|
| 17 |
+
field entirely. The top-level `_args` loop applies the same rule.
|
| 18 |
+
The `val is none` branch below is a safety net only — upstream cleaning
|
| 19 |
+
(drop_none_in_tool_arguments) should ensure no None ever reaches here. -#}
|
| 20 |
+
{%- macro to_xml(val, ns) -%}
|
| 21 |
+
{%- if val is mapping -%}
|
| 22 |
+
{%- for k, v in val.items() if v is not none -%}
|
| 23 |
+
{{ ns }}<{{ k }}>{{ to_xml(v, ns) }}{{ ns }}</{{ k }}>
|
| 24 |
+
{%- endfor -%}
|
| 25 |
+
{%- elif val is iterable and val is not string -%}
|
| 26 |
+
{%- for item in val -%}
|
| 27 |
+
{{ ns }}<item>{{ to_xml(item, ns) }}{{ ns }}</item>
|
| 28 |
+
{%- endfor -%}
|
| 29 |
+
{%- elif val is none -%}
|
| 30 |
+
{#- Should be unreachable when upstream cleaning is applied. -#}
|
| 31 |
+
{%- elif val is boolean -%}
|
| 32 |
+
{{ val | tojson }}
|
| 33 |
+
{%- else -%}
|
| 34 |
+
{{ val }}
|
| 35 |
+
{%- endif -%}
|
| 36 |
+
{%- endmacro -%}
|
| 37 |
+
{#- Tool Rendering Functions ============================================== -#}
|
| 38 |
+
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
|
| 39 |
+
{%- for tool in tool_list -%}
|
| 40 |
+
<tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
|
| 41 |
+
{% endfor -%}
|
| 42 |
+
{%- endmacro -%}
|
| 43 |
+
{%- macro visible_text(content) -%}
|
| 44 |
+
{%- if content is string -%}
|
| 45 |
+
{{ content }}
|
| 46 |
+
{%- elif content is iterable and content is not mapping -%}
|
| 47 |
+
{%- for item in content -%}
|
| 48 |
+
{%- if item is mapping and item.type == 'text' -%}
|
| 49 |
+
{{- item.text }}
|
| 50 |
+
{%- elif item is mapping and item.type == 'image' -%}
|
| 51 |
+
{{- image_token }}
|
| 52 |
+
{%- elif item is mapping and item.type == 'video' -%}
|
| 53 |
+
{{- video_token}}
|
| 54 |
+
{%- elif item is string -%}
|
| 55 |
+
{{- item }}
|
| 56 |
+
{%- endif -%}
|
| 57 |
+
{%- endfor -%}
|
| 58 |
+
{%- elif content is none -%}
|
| 59 |
+
{{- '' }}
|
| 60 |
+
{%- else -%}
|
| 61 |
+
{{- content }}
|
| 62 |
+
{%- endif -%}
|
| 63 |
+
{%- endmacro -%}
|
| 64 |
+
{#- System Message Construction ============================================ -#}
|
| 65 |
+
{%- macro build_system_message(system_message) -%}
|
| 66 |
+
{%- if system_message and system_message.content -%}
|
| 67 |
+
{{- visible_text(system_message.content) }}
|
| 68 |
+
{%- else -%}
|
| 69 |
+
{{- 'Your model version is MiniMax-M3, developed by MiniMax. Knowledge cutoff: January 2026. Founded in early 2022, MiniMax is a global AI foundation model company committed to advancing the frontiers of AI towards AGI.' }}
|
| 70 |
+
{%- endif -%}
|
| 71 |
+
|
| 72 |
+
{#- Thinking mode instructions -#}
|
| 73 |
+
{{- '\n\n<thinking_instructions>\n' }}
|
| 74 |
+
{{- 'You have a thinking capability that allows you to reason step by step before responding. When thinking is enabled, wrap your reasoning in ' ~ think_begin_token ~ think_end_token ~ ' tags before your response. When thinking is disabled, begin your response directly after the ' ~ think_end_token ~ ' prefix. When thinking is adaptive, decide on your own whether to think for the current turn.\n' }}
|
| 75 |
+
{%- if thinking_mode is defined -%}
|
| 76 |
+
{%- if thinking_mode == "enabled" -%}
|
| 77 |
+
{{- 'Current thinking mode: enabled. You MUST think step by step before every response, including after receiving function/tool results.\n' }}
|
| 78 |
+
{%- elif thinking_mode == "disabled" -%}
|
| 79 |
+
{{- 'Current thinking mode: disabled. Do not output any thinking process.\n' }}
|
| 80 |
+
{%- elif thinking_mode == "adaptive" -%}
|
| 81 |
+
{{- 'Current thinking mode: adaptive. You are encouraged to think for complex decision-making, multi-step reasoning, or when analyzing function/tool results.\n' }}
|
| 82 |
+
{%- endif -%}
|
| 83 |
+
{%- else -%}
|
| 84 |
+
{{- 'Current thinking mode: adaptive. You are encouraged to think for complex decision-making, multi-step reasoning, or when analyzing function/tool results.\n' }}
|
| 85 |
+
{%- endif -%}
|
| 86 |
+
{{- '</thinking_instructions>' }}
|
| 87 |
+
{%- endmacro -%}
|
| 88 |
+
{%- macro build_developer_message(developer_message) -%}
|
| 89 |
+
{%- if developer_message and developer_message.content -%}
|
| 90 |
+
{{- visible_text(developer_message.content) }}
|
| 91 |
+
{%- else -%}
|
| 92 |
+
{%- if model_identity is not defined -%}
|
| 93 |
+
{%- set model_identity = "You are a helpful assistant." -%}
|
| 94 |
+
{%- endif -%}
|
| 95 |
+
{{- model_identity }}
|
| 96 |
+
{%- endif -%}
|
| 97 |
+
{%- endmacro -%}
|
| 98 |
+
{#- Main Template Logic ================================================= -#}
|
| 99 |
+
{#- Role mapping: root -> system sp (high priority), system/developer -> developer sp (low priority) -#}
|
| 100 |
+
{%- set system_message = none -%}
|
| 101 |
+
{%- set developer_message = none -%}
|
| 102 |
+
{%- set conversation_messages = messages -%}
|
| 103 |
+
{%- if messages and messages[0].role == "root" -%}
|
| 104 |
+
{%- set system_message = messages[0] -%}
|
| 105 |
+
{%- set conversation_messages = messages[1:] -%}
|
| 106 |
+
{%- if conversation_messages and conversation_messages[0].role in ["system", "developer"] -%}
|
| 107 |
+
{%- set developer_message = conversation_messages[0] -%}
|
| 108 |
+
{%- set conversation_messages = conversation_messages[1:] -%}
|
| 109 |
+
{%- endif -%}
|
| 110 |
+
{%- elif messages and messages[0].role in ["system", "developer"] -%}
|
| 111 |
+
{%- set developer_message = messages[0] -%}
|
| 112 |
+
{%- set conversation_messages = messages[1:] -%}
|
| 113 |
+
{%- endif -%}
|
| 114 |
+
{#- Render system sp (higher priority, root role only) -#}
|
| 115 |
+
{{- bod_token ~ bos_token ~ 'system' ~ '\n' }}
|
| 116 |
+
{{- build_system_message(system_message) }}
|
| 117 |
+
{{- eos_token ~ '\n' }}
|
| 118 |
+
|
| 119 |
+
{#- Render developer sp (lower priority: system/developer role + tools) -#}
|
| 120 |
+
{{- bos_token ~ 'developer' ~ '\n' }}
|
| 121 |
+
{{- build_developer_message(developer_message) }}
|
| 122 |
+
{%- if tools -%}
|
| 123 |
+
{{- '\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' }}
|
| 124 |
+
{{- '\n' ~ '<tools>' ~ '\n' }}
|
| 125 |
+
{{- render_tool_namespace("functions", tools) }}
|
| 126 |
+
{{- '</tools>' ~ '\n\n' }}
|
| 127 |
+
{{- 'To call tools, wrap all invocations in a single ' ~ toolcall_begin_token ~ toolcall_end_token ~ ' block. Parameter values containing nested objects or arrays are recursively expanded into XML elements. Example:\n' }}
|
| 128 |
+
{{- '\n' ~ toolcall_begin_token ~ '\n' }}
|
| 129 |
+
{{- ns_token + '<invoke name="tool-name-1">' }}
|
| 130 |
+
{{- ns_token + '<param-1>value-1' + ns_token + '</param-1>' }}
|
| 131 |
+
{{- ns_token + '<param-2>' }}
|
| 132 |
+
{{- ns_token + '<item>' }}
|
| 133 |
+
{{- ns_token + '<key-a>val-a' + ns_token + '</key-a>' }}
|
| 134 |
+
{{- ns_token + '<key-b>val-b' + ns_token + '</key-b>' }}
|
| 135 |
+
{{- ns_token + '</item>' }}
|
| 136 |
+
{{- ns_token + '</param-2>' }}
|
| 137 |
+
{{- ns_token + '</invoke>\n' }}
|
| 138 |
+
{{- ns_token + '<invoke name="tool-name-2">' }}
|
| 139 |
+
{{- ns_token + '<param-1>value-1' + ns_token + '</param-1>' }}
|
| 140 |
+
{{- ns_token + '</invoke>\n' }}
|
| 141 |
+
{{- toolcall_end_token }}
|
| 142 |
+
{%- endif -%}
|
| 143 |
+
{{- eos_token ~ '\n' }}
|
| 144 |
+
|
| 145 |
+
{#- Render messages -#}
|
| 146 |
+
{%- set last_tool_call = namespace(name=none) -%}
|
| 147 |
+
{%- for message in conversation_messages -%}
|
| 148 |
+
{%- if message.role == 'assistant' -%}
|
| 149 |
+
{{- bos_token ~ 'ai' ~ '\n' }}
|
| 150 |
+
|
| 151 |
+
{%- set reasoning_content = '' %}
|
| 152 |
+
{%- set content = visible_text(message.content) %}
|
| 153 |
+
{%- if message.reasoning_content is string %}
|
| 154 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 155 |
+
{%- else %}
|
| 156 |
+
{%- if think_end_token in content %}
|
| 157 |
+
{%- set reasoning_content = content.split(think_end_token)[0].strip('\n').split(think_begin_token)[-1].strip('\n') %}
|
| 158 |
+
{%- set content = content.split(think_end_token)[-1].strip('\n') %}
|
| 159 |
+
{%- endif %}
|
| 160 |
+
{%- endif %}
|
| 161 |
+
|
| 162 |
+
{%- if reasoning_content -%}
|
| 163 |
+
{#- Render thinking for every assistant turn (all-turn visible) -#}
|
| 164 |
+
{{- think_begin_token ~ reasoning_content ~ think_end_token }}
|
| 165 |
+
{%- else -%}
|
| 166 |
+
{#- No thinking rendered → prefix with think_end_token -#}
|
| 167 |
+
{{- think_end_token }}
|
| 168 |
+
{%- endif -%}
|
| 169 |
+
|
| 170 |
+
{%- if content -%}
|
| 171 |
+
{{- content }}
|
| 172 |
+
{%- endif -%}
|
| 173 |
+
{%- if message.tool_calls -%}
|
| 174 |
+
{{- toolcall_begin_token ~ '\n' }}
|
| 175 |
+
|
| 176 |
+
{%- for tool_call in message.tool_calls -%}
|
| 177 |
+
{%- if tool_call.function -%}
|
| 178 |
+
{%- set tool_call = tool_call.function -%}
|
| 179 |
+
{%- endif -%}
|
| 180 |
+
{{- ns_token + '<invoke name="' + tool_call.name + '">' }}
|
| 181 |
+
{%- set _args = tool_call.arguments -%}
|
| 182 |
+
{%- for k, v in _args.items() if v is not none %}
|
| 183 |
+
{{- ns_token + '<' + k + '>' -}}
|
| 184 |
+
{{- to_xml(v, ns_token) -}}
|
| 185 |
+
{{- ns_token + '</' + k + '>' }}
|
| 186 |
+
{%- endfor -%}
|
| 187 |
+
{{- ns_token + '</invoke>' ~ '\n' }}
|
| 188 |
+
{%- endfor -%}
|
| 189 |
+
|
| 190 |
+
{{- toolcall_end_token }}
|
| 191 |
+
{%- if message.tool_calls[-1].function -%}
|
| 192 |
+
{%- set last_tool_call.name = message.tool_calls[-1].function.name -%}
|
| 193 |
+
{%- else -%}
|
| 194 |
+
{%- set last_tool_call.name = message.tool_calls[-1].name -%}
|
| 195 |
+
{%- endif -%}
|
| 196 |
+
{%- else -%}
|
| 197 |
+
{%- set last_tool_call.name = none -%}
|
| 198 |
+
{%- endif -%}
|
| 199 |
+
{{- eos_token ~ '\n' }}
|
| 200 |
+
|
| 201 |
+
{%- elif message.role == 'tool' -%}
|
| 202 |
+
{%- if last_tool_call.name is none -%}
|
| 203 |
+
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
|
| 204 |
+
{%- endif -%}
|
| 205 |
+
{%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
|
| 206 |
+
{{- bos_token ~ 'tool' }}
|
| 207 |
+
{%- endif -%}
|
| 208 |
+
{{- '\n<response>' }}
|
| 209 |
+
{%- if message.content is string -%}
|
| 210 |
+
{{- message.content }}
|
| 211 |
+
{%- else -%}
|
| 212 |
+
{%- for tr in message.content -%}
|
| 213 |
+
{%- if tr is mapping and tr.type is defined and tr.type == 'image' -%}
|
| 214 |
+
{{- image_token }}
|
| 215 |
+
{%- elif tr is mapping and tr.type is defined and tr.type == 'video' -%}
|
| 216 |
+
{{- video_token }}
|
| 217 |
+
{%- else -%}
|
| 218 |
+
{{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
|
| 219 |
+
{%- endif -%}
|
| 220 |
+
{%- endfor -%}
|
| 221 |
+
{%- endif -%}
|
| 222 |
+
{{- '</response>' }}
|
| 223 |
+
{%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
|
| 224 |
+
{{- eos_token ~ '\n' -}}
|
| 225 |
+
{%- endif -%}
|
| 226 |
+
|
| 227 |
+
{%- elif message.role == 'user' -%}
|
| 228 |
+
{{- bos_token ~ 'user' ~ '\n' }}
|
| 229 |
+
{{- visible_text(message.content) }}
|
| 230 |
+
{{- eos_token ~ '\n' }}
|
| 231 |
+
{%- endif -%}
|
| 232 |
+
{%- endfor -%}
|
| 233 |
+
|
| 234 |
+
{#- Generation prompt -#}
|
| 235 |
+
{%- if add_generation_prompt -%}
|
| 236 |
+
{{- bos_token ~ 'ai' ~ '\n' }}
|
| 237 |
+
{%- if thinking_mode is defined and thinking_mode == "disabled" -%}
|
| 238 |
+
{{- think_end_token }}
|
| 239 |
+
{%- elif thinking_mode is defined and thinking_mode == "adaptive" -%}
|
| 240 |
+
{#- adaptive: no prefix, let model decide -#}
|
| 241 |
+
{%- elif thinking_mode is defined and thinking_mode == "enabled" -%}
|
| 242 |
+
{#- enabled or not defined: default to think -#}
|
| 243 |
+
{{- think_begin_token }}
|
| 244 |
+
{%- else -%}
|
| 245 |
+
{#- adaptive: no prefix, let model decide -#}
|
| 246 |
+
{%- endif -%}
|
| 247 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,551 @@
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dense_intermediate_size": 12288,
|
| 3 |
+
"eos_token_id": 200020,
|
| 4 |
+
"head_dim": 128,
|
| 5 |
+
"hidden_size": 6144,
|
| 6 |
+
"intermediate_size": 3072,
|
| 7 |
+
"max_position_embeddings": 1048576,
|
| 8 |
+
"mlp_layer_types": [
|
| 9 |
+
"dense",
|
| 10 |
+
"dense",
|
| 11 |
+
"dense",
|
| 12 |
+
"sparse",
|
| 13 |
+
"sparse",
|
| 14 |
+
"sparse",
|
| 15 |
+
"sparse",
|
| 16 |
+
"sparse",
|
| 17 |
+
"sparse",
|
| 18 |
+
"sparse",
|
| 19 |
+
"sparse",
|
| 20 |
+
"sparse",
|
| 21 |
+
"sparse",
|
| 22 |
+
"sparse",
|
| 23 |
+
"sparse",
|
| 24 |
+
"sparse",
|
| 25 |
+
"sparse",
|
| 26 |
+
"sparse",
|
| 27 |
+
"sparse",
|
| 28 |
+
"sparse",
|
| 29 |
+
"sparse",
|
| 30 |
+
"sparse",
|
| 31 |
+
"sparse",
|
| 32 |
+
"sparse",
|
| 33 |
+
"sparse",
|
| 34 |
+
"sparse",
|
| 35 |
+
"sparse",
|
| 36 |
+
"sparse",
|
| 37 |
+
"sparse",
|
| 38 |
+
"sparse",
|
| 39 |
+
"sparse",
|
| 40 |
+
"sparse",
|
| 41 |
+
"sparse",
|
| 42 |
+
"sparse",
|
| 43 |
+
"sparse",
|
| 44 |
+
"sparse",
|
| 45 |
+
"sparse",
|
| 46 |
+
"sparse",
|
| 47 |
+
"sparse",
|
| 48 |
+
"sparse",
|
| 49 |
+
"sparse",
|
| 50 |
+
"sparse",
|
| 51 |
+
"sparse",
|
| 52 |
+
"sparse",
|
| 53 |
+
"sparse",
|
| 54 |
+
"sparse",
|
| 55 |
+
"sparse",
|
| 56 |
+
"sparse",
|
| 57 |
+
"sparse",
|
| 58 |
+
"sparse",
|
| 59 |
+
"sparse",
|
| 60 |
+
"sparse",
|
| 61 |
+
"sparse",
|
| 62 |
+
"sparse",
|
| 63 |
+
"sparse",
|
| 64 |
+
"sparse",
|
| 65 |
+
"sparse",
|
| 66 |
+
"sparse",
|
| 67 |
+
"sparse",
|
| 68 |
+
"sparse"
|
| 69 |
+
],
|
| 70 |
+
"model_type": "minimax_m3",
|
| 71 |
+
"num_attention_heads": 64,
|
| 72 |
+
"num_experts_per_tok": 4,
|
| 73 |
+
"num_hidden_layers": 60,
|
| 74 |
+
"num_key_value_heads": 4,
|
| 75 |
+
"num_local_experts": 128,
|
| 76 |
+
"quantization": {
|
| 77 |
+
"group_size": 64,
|
| 78 |
+
"bits": 4,
|
| 79 |
+
"mode": "affine",
|
| 80 |
+
"model.layers.3.block_sparse_moe.gate": {
|
| 81 |
+
"group_size": 64,
|
| 82 |
+
"bits": 8
|
| 83 |
+
},
|
| 84 |
+
"model.layers.4.block_sparse_moe.gate": {
|
| 85 |
+
"group_size": 64,
|
| 86 |
+
"bits": 8
|
| 87 |
+
},
|
| 88 |
+
"model.layers.5.block_sparse_moe.gate": {
|
| 89 |
+
"group_size": 64,
|
| 90 |
+
"bits": 8
|
| 91 |
+
},
|
| 92 |
+
"model.layers.6.block_sparse_moe.gate": {
|
| 93 |
+
"group_size": 64,
|
| 94 |
+
"bits": 8
|
| 95 |
+
},
|
| 96 |
+
"model.layers.7.block_sparse_moe.gate": {
|
| 97 |
+
"group_size": 64,
|
| 98 |
+
"bits": 8
|
| 99 |
+
},
|
| 100 |
+
"model.layers.8.block_sparse_moe.gate": {
|
| 101 |
+
"group_size": 64,
|
| 102 |
+
"bits": 8
|
| 103 |
+
},
|
| 104 |
+
"model.layers.9.block_sparse_moe.gate": {
|
| 105 |
+
"group_size": 64,
|
| 106 |
+
"bits": 8
|
| 107 |
+
},
|
| 108 |
+
"model.layers.10.block_sparse_moe.gate": {
|
| 109 |
+
"group_size": 64,
|
| 110 |
+
"bits": 8
|
| 111 |
+
},
|
| 112 |
+
"model.layers.11.block_sparse_moe.gate": {
|
| 113 |
+
"group_size": 64,
|
| 114 |
+
"bits": 8
|
| 115 |
+
},
|
| 116 |
+
"model.layers.12.block_sparse_moe.gate": {
|
| 117 |
+
"group_size": 64,
|
| 118 |
+
"bits": 8
|
| 119 |
+
},
|
| 120 |
+
"model.layers.13.block_sparse_moe.gate": {
|
| 121 |
+
"group_size": 64,
|
| 122 |
+
"bits": 8
|
| 123 |
+
},
|
| 124 |
+
"model.layers.14.block_sparse_moe.gate": {
|
| 125 |
+
"group_size": 64,
|
| 126 |
+
"bits": 8
|
| 127 |
+
},
|
| 128 |
+
"model.layers.15.block_sparse_moe.gate": {
|
| 129 |
+
"group_size": 64,
|
| 130 |
+
"bits": 8
|
| 131 |
+
},
|
| 132 |
+
"model.layers.16.block_sparse_moe.gate": {
|
| 133 |
+
"group_size": 64,
|
| 134 |
+
"bits": 8
|
| 135 |
+
},
|
| 136 |
+
"model.layers.17.block_sparse_moe.gate": {
|
| 137 |
+
"group_size": 64,
|
| 138 |
+
"bits": 8
|
| 139 |
+
},
|
| 140 |
+
"model.layers.18.block_sparse_moe.gate": {
|
| 141 |
+
"group_size": 64,
|
| 142 |
+
"bits": 8
|
| 143 |
+
},
|
| 144 |
+
"model.layers.19.block_sparse_moe.gate": {
|
| 145 |
+
"group_size": 64,
|
| 146 |
+
"bits": 8
|
| 147 |
+
},
|
| 148 |
+
"model.layers.20.block_sparse_moe.gate": {
|
| 149 |
+
"group_size": 64,
|
| 150 |
+
"bits": 8
|
| 151 |
+
},
|
| 152 |
+
"model.layers.21.block_sparse_moe.gate": {
|
| 153 |
+
"group_size": 64,
|
| 154 |
+
"bits": 8
|
| 155 |
+
},
|
| 156 |
+
"model.layers.22.block_sparse_moe.gate": {
|
| 157 |
+
"group_size": 64,
|
| 158 |
+
"bits": 8
|
| 159 |
+
},
|
| 160 |
+
"model.layers.23.block_sparse_moe.gate": {
|
| 161 |
+
"group_size": 64,
|
| 162 |
+
"bits": 8
|
| 163 |
+
},
|
| 164 |
+
"model.layers.24.block_sparse_moe.gate": {
|
| 165 |
+
"group_size": 64,
|
| 166 |
+
"bits": 8
|
| 167 |
+
},
|
| 168 |
+
"model.layers.25.block_sparse_moe.gate": {
|
| 169 |
+
"group_size": 64,
|
| 170 |
+
"bits": 8
|
| 171 |
+
},
|
| 172 |
+
"model.layers.26.block_sparse_moe.gate": {
|
| 173 |
+
"group_size": 64,
|
| 174 |
+
"bits": 8
|
| 175 |
+
},
|
| 176 |
+
"model.layers.27.block_sparse_moe.gate": {
|
| 177 |
+
"group_size": 64,
|
| 178 |
+
"bits": 8
|
| 179 |
+
},
|
| 180 |
+
"model.layers.28.block_sparse_moe.gate": {
|
| 181 |
+
"group_size": 64,
|
| 182 |
+
"bits": 8
|
| 183 |
+
},
|
| 184 |
+
"model.layers.29.block_sparse_moe.gate": {
|
| 185 |
+
"group_size": 64,
|
| 186 |
+
"bits": 8
|
| 187 |
+
},
|
| 188 |
+
"model.layers.30.block_sparse_moe.gate": {
|
| 189 |
+
"group_size": 64,
|
| 190 |
+
"bits": 8
|
| 191 |
+
},
|
| 192 |
+
"model.layers.31.block_sparse_moe.gate": {
|
| 193 |
+
"group_size": 64,
|
| 194 |
+
"bits": 8
|
| 195 |
+
},
|
| 196 |
+
"model.layers.32.block_sparse_moe.gate": {
|
| 197 |
+
"group_size": 64,
|
| 198 |
+
"bits": 8
|
| 199 |
+
},
|
| 200 |
+
"model.layers.33.block_sparse_moe.gate": {
|
| 201 |
+
"group_size": 64,
|
| 202 |
+
"bits": 8
|
| 203 |
+
},
|
| 204 |
+
"model.layers.34.block_sparse_moe.gate": {
|
| 205 |
+
"group_size": 64,
|
| 206 |
+
"bits": 8
|
| 207 |
+
},
|
| 208 |
+
"model.layers.35.block_sparse_moe.gate": {
|
| 209 |
+
"group_size": 64,
|
| 210 |
+
"bits": 8
|
| 211 |
+
},
|
| 212 |
+
"model.layers.36.block_sparse_moe.gate": {
|
| 213 |
+
"group_size": 64,
|
| 214 |
+
"bits": 8
|
| 215 |
+
},
|
| 216 |
+
"model.layers.37.block_sparse_moe.gate": {
|
| 217 |
+
"group_size": 64,
|
| 218 |
+
"bits": 8
|
| 219 |
+
},
|
| 220 |
+
"model.layers.38.block_sparse_moe.gate": {
|
| 221 |
+
"group_size": 64,
|
| 222 |
+
"bits": 8
|
| 223 |
+
},
|
| 224 |
+
"model.layers.39.block_sparse_moe.gate": {
|
| 225 |
+
"group_size": 64,
|
| 226 |
+
"bits": 8
|
| 227 |
+
},
|
| 228 |
+
"model.layers.40.block_sparse_moe.gate": {
|
| 229 |
+
"group_size": 64,
|
| 230 |
+
"bits": 8
|
| 231 |
+
},
|
| 232 |
+
"model.layers.41.block_sparse_moe.gate": {
|
| 233 |
+
"group_size": 64,
|
| 234 |
+
"bits": 8
|
| 235 |
+
},
|
| 236 |
+
"model.layers.42.block_sparse_moe.gate": {
|
| 237 |
+
"group_size": 64,
|
| 238 |
+
"bits": 8
|
| 239 |
+
},
|
| 240 |
+
"model.layers.43.block_sparse_moe.gate": {
|
| 241 |
+
"group_size": 64,
|
| 242 |
+
"bits": 8
|
| 243 |
+
},
|
| 244 |
+
"model.layers.44.block_sparse_moe.gate": {
|
| 245 |
+
"group_size": 64,
|
| 246 |
+
"bits": 8
|
| 247 |
+
},
|
| 248 |
+
"model.layers.45.block_sparse_moe.gate": {
|
| 249 |
+
"group_size": 64,
|
| 250 |
+
"bits": 8
|
| 251 |
+
},
|
| 252 |
+
"model.layers.46.block_sparse_moe.gate": {
|
| 253 |
+
"group_size": 64,
|
| 254 |
+
"bits": 8
|
| 255 |
+
},
|
| 256 |
+
"model.layers.47.block_sparse_moe.gate": {
|
| 257 |
+
"group_size": 64,
|
| 258 |
+
"bits": 8
|
| 259 |
+
},
|
| 260 |
+
"model.layers.48.block_sparse_moe.gate": {
|
| 261 |
+
"group_size": 64,
|
| 262 |
+
"bits": 8
|
| 263 |
+
},
|
| 264 |
+
"model.layers.49.block_sparse_moe.gate": {
|
| 265 |
+
"group_size": 64,
|
| 266 |
+
"bits": 8
|
| 267 |
+
},
|
| 268 |
+
"model.layers.50.block_sparse_moe.gate": {
|
| 269 |
+
"group_size": 64,
|
| 270 |
+
"bits": 8
|
| 271 |
+
},
|
| 272 |
+
"model.layers.51.block_sparse_moe.gate": {
|
| 273 |
+
"group_size": 64,
|
| 274 |
+
"bits": 8
|
| 275 |
+
},
|
| 276 |
+
"model.layers.52.block_sparse_moe.gate": {
|
| 277 |
+
"group_size": 64,
|
| 278 |
+
"bits": 8
|
| 279 |
+
},
|
| 280 |
+
"model.layers.53.block_sparse_moe.gate": {
|
| 281 |
+
"group_size": 64,
|
| 282 |
+
"bits": 8
|
| 283 |
+
},
|
| 284 |
+
"model.layers.54.block_sparse_moe.gate": {
|
| 285 |
+
"group_size": 64,
|
| 286 |
+
"bits": 8
|
| 287 |
+
},
|
| 288 |
+
"model.layers.55.block_sparse_moe.gate": {
|
| 289 |
+
"group_size": 64,
|
| 290 |
+
"bits": 8
|
| 291 |
+
},
|
| 292 |
+
"model.layers.56.block_sparse_moe.gate": {
|
| 293 |
+
"group_size": 64,
|
| 294 |
+
"bits": 8
|
| 295 |
+
},
|
| 296 |
+
"model.layers.57.block_sparse_moe.gate": {
|
| 297 |
+
"group_size": 64,
|
| 298 |
+
"bits": 8
|
| 299 |
+
},
|
| 300 |
+
"model.layers.58.block_sparse_moe.gate": {
|
| 301 |
+
"group_size": 64,
|
| 302 |
+
"bits": 8
|
| 303 |
+
},
|
| 304 |
+
"model.layers.59.block_sparse_moe.gate": {
|
| 305 |
+
"group_size": 64,
|
| 306 |
+
"bits": 8
|
| 307 |
+
}
|
| 308 |
+
},
|
| 309 |
+
"quantization_config": {
|
| 310 |
+
"group_size": 64,
|
| 311 |
+
"bits": 4,
|
| 312 |
+
"mode": "affine",
|
| 313 |
+
"model.layers.3.block_sparse_moe.gate": {
|
| 314 |
+
"group_size": 64,
|
| 315 |
+
"bits": 8
|
| 316 |
+
},
|
| 317 |
+
"model.layers.4.block_sparse_moe.gate": {
|
| 318 |
+
"group_size": 64,
|
| 319 |
+
"bits": 8
|
| 320 |
+
},
|
| 321 |
+
"model.layers.5.block_sparse_moe.gate": {
|
| 322 |
+
"group_size": 64,
|
| 323 |
+
"bits": 8
|
| 324 |
+
},
|
| 325 |
+
"model.layers.6.block_sparse_moe.gate": {
|
| 326 |
+
"group_size": 64,
|
| 327 |
+
"bits": 8
|
| 328 |
+
},
|
| 329 |
+
"model.layers.7.block_sparse_moe.gate": {
|
| 330 |
+
"group_size": 64,
|
| 331 |
+
"bits": 8
|
| 332 |
+
},
|
| 333 |
+
"model.layers.8.block_sparse_moe.gate": {
|
| 334 |
+
"group_size": 64,
|
| 335 |
+
"bits": 8
|
| 336 |
+
},
|
| 337 |
+
"model.layers.9.block_sparse_moe.gate": {
|
| 338 |
+
"group_size": 64,
|
| 339 |
+
"bits": 8
|
| 340 |
+
},
|
| 341 |
+
"model.layers.10.block_sparse_moe.gate": {
|
| 342 |
+
"group_size": 64,
|
| 343 |
+
"bits": 8
|
| 344 |
+
},
|
| 345 |
+
"model.layers.11.block_sparse_moe.gate": {
|
| 346 |
+
"group_size": 64,
|
| 347 |
+
"bits": 8
|
| 348 |
+
},
|
| 349 |
+
"model.layers.12.block_sparse_moe.gate": {
|
| 350 |
+
"group_size": 64,
|
| 351 |
+
"bits": 8
|
| 352 |
+
},
|
| 353 |
+
"model.layers.13.block_sparse_moe.gate": {
|
| 354 |
+
"group_size": 64,
|
| 355 |
+
"bits": 8
|
| 356 |
+
},
|
| 357 |
+
"model.layers.14.block_sparse_moe.gate": {
|
| 358 |
+
"group_size": 64,
|
| 359 |
+
"bits": 8
|
| 360 |
+
},
|
| 361 |
+
"model.layers.15.block_sparse_moe.gate": {
|
| 362 |
+
"group_size": 64,
|
| 363 |
+
"bits": 8
|
| 364 |
+
},
|
| 365 |
+
"model.layers.16.block_sparse_moe.gate": {
|
| 366 |
+
"group_size": 64,
|
| 367 |
+
"bits": 8
|
| 368 |
+
},
|
| 369 |
+
"model.layers.17.block_sparse_moe.gate": {
|
| 370 |
+
"group_size": 64,
|
| 371 |
+
"bits": 8
|
| 372 |
+
},
|
| 373 |
+
"model.layers.18.block_sparse_moe.gate": {
|
| 374 |
+
"group_size": 64,
|
| 375 |
+
"bits": 8
|
| 376 |
+
},
|
| 377 |
+
"model.layers.19.block_sparse_moe.gate": {
|
| 378 |
+
"group_size": 64,
|
| 379 |
+
"bits": 8
|
| 380 |
+
},
|
| 381 |
+
"model.layers.20.block_sparse_moe.gate": {
|
| 382 |
+
"group_size": 64,
|
| 383 |
+
"bits": 8
|
| 384 |
+
},
|
| 385 |
+
"model.layers.21.block_sparse_moe.gate": {
|
| 386 |
+
"group_size": 64,
|
| 387 |
+
"bits": 8
|
| 388 |
+
},
|
| 389 |
+
"model.layers.22.block_sparse_moe.gate": {
|
| 390 |
+
"group_size": 64,
|
| 391 |
+
"bits": 8
|
| 392 |
+
},
|
| 393 |
+
"model.layers.23.block_sparse_moe.gate": {
|
| 394 |
+
"group_size": 64,
|
| 395 |
+
"bits": 8
|
| 396 |
+
},
|
| 397 |
+
"model.layers.24.block_sparse_moe.gate": {
|
| 398 |
+
"group_size": 64,
|
| 399 |
+
"bits": 8
|
| 400 |
+
},
|
| 401 |
+
"model.layers.25.block_sparse_moe.gate": {
|
| 402 |
+
"group_size": 64,
|
| 403 |
+
"bits": 8
|
| 404 |
+
},
|
| 405 |
+
"model.layers.26.block_sparse_moe.gate": {
|
| 406 |
+
"group_size": 64,
|
| 407 |
+
"bits": 8
|
| 408 |
+
},
|
| 409 |
+
"model.layers.27.block_sparse_moe.gate": {
|
| 410 |
+
"group_size": 64,
|
| 411 |
+
"bits": 8
|
| 412 |
+
},
|
| 413 |
+
"model.layers.28.block_sparse_moe.gate": {
|
| 414 |
+
"group_size": 64,
|
| 415 |
+
"bits": 8
|
| 416 |
+
},
|
| 417 |
+
"model.layers.29.block_sparse_moe.gate": {
|
| 418 |
+
"group_size": 64,
|
| 419 |
+
"bits": 8
|
| 420 |
+
},
|
| 421 |
+
"model.layers.30.block_sparse_moe.gate": {
|
| 422 |
+
"group_size": 64,
|
| 423 |
+
"bits": 8
|
| 424 |
+
},
|
| 425 |
+
"model.layers.31.block_sparse_moe.gate": {
|
| 426 |
+
"group_size": 64,
|
| 427 |
+
"bits": 8
|
| 428 |
+
},
|
| 429 |
+
"model.layers.32.block_sparse_moe.gate": {
|
| 430 |
+
"group_size": 64,
|
| 431 |
+
"bits": 8
|
| 432 |
+
},
|
| 433 |
+
"model.layers.33.block_sparse_moe.gate": {
|
| 434 |
+
"group_size": 64,
|
| 435 |
+
"bits": 8
|
| 436 |
+
},
|
| 437 |
+
"model.layers.34.block_sparse_moe.gate": {
|
| 438 |
+
"group_size": 64,
|
| 439 |
+
"bits": 8
|
| 440 |
+
},
|
| 441 |
+
"model.layers.35.block_sparse_moe.gate": {
|
| 442 |
+
"group_size": 64,
|
| 443 |
+
"bits": 8
|
| 444 |
+
},
|
| 445 |
+
"model.layers.36.block_sparse_moe.gate": {
|
| 446 |
+
"group_size": 64,
|
| 447 |
+
"bits": 8
|
| 448 |
+
},
|
| 449 |
+
"model.layers.37.block_sparse_moe.gate": {
|
| 450 |
+
"group_size": 64,
|
| 451 |
+
"bits": 8
|
| 452 |
+
},
|
| 453 |
+
"model.layers.38.block_sparse_moe.gate": {
|
| 454 |
+
"group_size": 64,
|
| 455 |
+
"bits": 8
|
| 456 |
+
},
|
| 457 |
+
"model.layers.39.block_sparse_moe.gate": {
|
| 458 |
+
"group_size": 64,
|
| 459 |
+
"bits": 8
|
| 460 |
+
},
|
| 461 |
+
"model.layers.40.block_sparse_moe.gate": {
|
| 462 |
+
"group_size": 64,
|
| 463 |
+
"bits": 8
|
| 464 |
+
},
|
| 465 |
+
"model.layers.41.block_sparse_moe.gate": {
|
| 466 |
+
"group_size": 64,
|
| 467 |
+
"bits": 8
|
| 468 |
+
},
|
| 469 |
+
"model.layers.42.block_sparse_moe.gate": {
|
| 470 |
+
"group_size": 64,
|
| 471 |
+
"bits": 8
|
| 472 |
+
},
|
| 473 |
+
"model.layers.43.block_sparse_moe.gate": {
|
| 474 |
+
"group_size": 64,
|
| 475 |
+
"bits": 8
|
| 476 |
+
},
|
| 477 |
+
"model.layers.44.block_sparse_moe.gate": {
|
| 478 |
+
"group_size": 64,
|
| 479 |
+
"bits": 8
|
| 480 |
+
},
|
| 481 |
+
"model.layers.45.block_sparse_moe.gate": {
|
| 482 |
+
"group_size": 64,
|
| 483 |
+
"bits": 8
|
| 484 |
+
},
|
| 485 |
+
"model.layers.46.block_sparse_moe.gate": {
|
| 486 |
+
"group_size": 64,
|
| 487 |
+
"bits": 8
|
| 488 |
+
},
|
| 489 |
+
"model.layers.47.block_sparse_moe.gate": {
|
| 490 |
+
"group_size": 64,
|
| 491 |
+
"bits": 8
|
| 492 |
+
},
|
| 493 |
+
"model.layers.48.block_sparse_moe.gate": {
|
| 494 |
+
"group_size": 64,
|
| 495 |
+
"bits": 8
|
| 496 |
+
},
|
| 497 |
+
"model.layers.49.block_sparse_moe.gate": {
|
| 498 |
+
"group_size": 64,
|
| 499 |
+
"bits": 8
|
| 500 |
+
},
|
| 501 |
+
"model.layers.50.block_sparse_moe.gate": {
|
| 502 |
+
"group_size": 64,
|
| 503 |
+
"bits": 8
|
| 504 |
+
},
|
| 505 |
+
"model.layers.51.block_sparse_moe.gate": {
|
| 506 |
+
"group_size": 64,
|
| 507 |
+
"bits": 8
|
| 508 |
+
},
|
| 509 |
+
"model.layers.52.block_sparse_moe.gate": {
|
| 510 |
+
"group_size": 64,
|
| 511 |
+
"bits": 8
|
| 512 |
+
},
|
| 513 |
+
"model.layers.53.block_sparse_moe.gate": {
|
| 514 |
+
"group_size": 64,
|
| 515 |
+
"bits": 8
|
| 516 |
+
},
|
| 517 |
+
"model.layers.54.block_sparse_moe.gate": {
|
| 518 |
+
"group_size": 64,
|
| 519 |
+
"bits": 8
|
| 520 |
+
},
|
| 521 |
+
"model.layers.55.block_sparse_moe.gate": {
|
| 522 |
+
"group_size": 64,
|
| 523 |
+
"bits": 8
|
| 524 |
+
},
|
| 525 |
+
"model.layers.56.block_sparse_moe.gate": {
|
| 526 |
+
"group_size": 64,
|
| 527 |
+
"bits": 8
|
| 528 |
+
},
|
| 529 |
+
"model.layers.57.block_sparse_moe.gate": {
|
| 530 |
+
"group_size": 64,
|
| 531 |
+
"bits": 8
|
| 532 |
+
},
|
| 533 |
+
"model.layers.58.block_sparse_moe.gate": {
|
| 534 |
+
"group_size": 64,
|
| 535 |
+
"bits": 8
|
| 536 |
+
},
|
| 537 |
+
"model.layers.59.block_sparse_moe.gate": {
|
| 538 |
+
"group_size": 64,
|
| 539 |
+
"bits": 8
|
| 540 |
+
}
|
| 541 |
+
},
|
| 542 |
+
"rms_norm_eps": 1e-06,
|
| 543 |
+
"rope_theta": 5000000,
|
| 544 |
+
"rotary_dim": 64,
|
| 545 |
+
"routed_scaling_factor": 2.0,
|
| 546 |
+
"shared_intermediate_size": 3072,
|
| 547 |
+
"swiglu_alpha": 1.702,
|
| 548 |
+
"swiglu_limit": 7.0,
|
| 549 |
+
"tie_word_embeddings": false,
|
| 550 |
+
"vocab_size": 200064
|
| 551 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"transform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-only LLM extraction of MiniMaxM3VL).
|
| 3 |
+
#
|
| 4 |
+
# M3 extends MiniMax-M2 with: Gemma-style RMSNorm (scale by 1+w, fp32),
|
| 5 |
+
# per-head QK-norm, partial RoPE (rotary_dim < head_dim), SwiGLU-OAI activation
|
| 6 |
+
# (clamped gate/up with an (up+1) term), a shared expert + routed_scaling_factor
|
| 7 |
+
# in the MoE, and the first few layers being dense MLPs instead of MoE.
|
| 8 |
+
#
|
| 9 |
+
# MiniMax Sparse Attention (MSA) is implemented here as full causal attention.
|
| 10 |
+
# For sequences up to index_topk_blocks * index_block_size (= 2048) tokens the
|
| 11 |
+
# MSA indexer selects *every* key block, so full attention is numerically exact;
|
| 12 |
+
# beyond that it is the dense (un-approximated) attention MSA approximates, so
|
| 13 |
+
# quality is preserved at the cost of long-context speed/memory.
|
| 14 |
+
|
| 15 |
+
from dataclasses import dataclass, field
|
| 16 |
+
from typing import Any, List, Optional
|
| 17 |
+
|
| 18 |
+
import mlx.core as mx
|
| 19 |
+
import mlx.nn as nn
|
| 20 |
+
|
| 21 |
+
from .base import BaseModelArgs, create_attention_mask, scaled_dot_product_attention
|
| 22 |
+
from .switch_layers import SwitchGLU
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@dataclass
|
| 26 |
+
class ModelArgs(BaseModelArgs):
|
| 27 |
+
model_type: str
|
| 28 |
+
hidden_size: int
|
| 29 |
+
intermediate_size: int
|
| 30 |
+
dense_intermediate_size: int
|
| 31 |
+
shared_intermediate_size: int
|
| 32 |
+
num_attention_heads: int
|
| 33 |
+
num_key_value_heads: int
|
| 34 |
+
num_hidden_layers: int
|
| 35 |
+
num_local_experts: int
|
| 36 |
+
num_experts_per_tok: int
|
| 37 |
+
rms_norm_eps: float
|
| 38 |
+
rope_theta: float
|
| 39 |
+
rotary_dim: int
|
| 40 |
+
vocab_size: int
|
| 41 |
+
head_dim: int = 128
|
| 42 |
+
max_position_embeddings: int = 1048576
|
| 43 |
+
routed_scaling_factor: float = 2.0
|
| 44 |
+
swiglu_alpha: float = 1.702
|
| 45 |
+
swiglu_limit: float = 7.0
|
| 46 |
+
scoring_func: str = "sigmoid"
|
| 47 |
+
use_qk_norm: bool = True
|
| 48 |
+
tie_word_embeddings: bool = False
|
| 49 |
+
# Per-layer MLP dispatch: "sparse" -> MoE block, "dense" -> dense MLP.
|
| 50 |
+
mlp_layer_types: Optional[List[str]] = None
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class GemmaRMSNorm(nn.Module):
|
| 54 |
+
"""Gemma-style RMSNorm: normalize in fp32 and scale by ``weight + 1``."""
|
| 55 |
+
|
| 56 |
+
def __init__(self, dims: int, eps: float = 1e-6):
|
| 57 |
+
super().__init__()
|
| 58 |
+
self.weight = mx.zeros((dims,))
|
| 59 |
+
self.eps = eps
|
| 60 |
+
|
| 61 |
+
def _extra_repr(self):
|
| 62 |
+
return f"{self.weight.shape[0]}, eps={self.eps}"
|
| 63 |
+
|
| 64 |
+
def __call__(self, x):
|
| 65 |
+
ot = x.dtype
|
| 66 |
+
x = x.astype(mx.float32)
|
| 67 |
+
x = x * mx.rsqrt(x.square().mean(-1, keepdims=True) + self.eps)
|
| 68 |
+
return (x * (1.0 + self.weight.astype(mx.float32))).astype(ot)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def swiglu_oai(x_gate, x_up, alpha: float, limit: float):
|
| 72 |
+
"""GPT-OSS / MiniMax-M3 clamped SwiGLU: (clamp(up)+1) * gate*sigmoid(alpha*gate)."""
|
| 73 |
+
gate = mx.minimum(x_gate, limit)
|
| 74 |
+
up = mx.clip(x_up, -limit, limit)
|
| 75 |
+
return (up + 1.0) * (gate * mx.sigmoid(gate * alpha))
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class SwiGLUOAI(nn.Module):
|
| 79 |
+
"""Activation callable for SwitchGLU: receives (x_up, x_gate)."""
|
| 80 |
+
|
| 81 |
+
def __init__(self, alpha: float, limit: float):
|
| 82 |
+
super().__init__()
|
| 83 |
+
self.alpha = alpha
|
| 84 |
+
self.limit = limit
|
| 85 |
+
|
| 86 |
+
def __call__(self, x_up, x_gate):
|
| 87 |
+
return swiglu_oai(x_gate, x_up, self.alpha, self.limit)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class MiniMaxM3MLP(nn.Module):
|
| 91 |
+
"""Dense SwiGLU-OAI MLP (used by the first dense layers and the shared expert)."""
|
| 92 |
+
|
| 93 |
+
def __init__(self, args: ModelArgs, intermediate_size: int):
|
| 94 |
+
super().__init__()
|
| 95 |
+
self.alpha = args.swiglu_alpha
|
| 96 |
+
self.limit = args.swiglu_limit
|
| 97 |
+
self.gate_proj = nn.Linear(args.hidden_size, intermediate_size, bias=False)
|
| 98 |
+
self.up_proj = nn.Linear(args.hidden_size, intermediate_size, bias=False)
|
| 99 |
+
self.down_proj = nn.Linear(intermediate_size, args.hidden_size, bias=False)
|
| 100 |
+
|
| 101 |
+
def __call__(self, x):
|
| 102 |
+
return self.down_proj(
|
| 103 |
+
swiglu_oai(self.gate_proj(x), self.up_proj(x), self.alpha, self.limit)
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class MiniMaxM3Attention(nn.Module):
|
| 108 |
+
def __init__(self, args: ModelArgs):
|
| 109 |
+
super().__init__()
|
| 110 |
+
self.num_attention_heads = args.num_attention_heads
|
| 111 |
+
self.num_key_value_heads = args.num_key_value_heads
|
| 112 |
+
self.head_dim = head_dim = args.head_dim
|
| 113 |
+
self.scale = head_dim**-0.5
|
| 114 |
+
|
| 115 |
+
self.q_proj = nn.Linear(
|
| 116 |
+
args.hidden_size, self.num_attention_heads * head_dim, bias=False
|
| 117 |
+
)
|
| 118 |
+
self.k_proj = nn.Linear(
|
| 119 |
+
args.hidden_size, self.num_key_value_heads * head_dim, bias=False
|
| 120 |
+
)
|
| 121 |
+
self.v_proj = nn.Linear(
|
| 122 |
+
args.hidden_size, self.num_key_value_heads * head_dim, bias=False
|
| 123 |
+
)
|
| 124 |
+
self.o_proj = nn.Linear(
|
| 125 |
+
self.num_attention_heads * head_dim, args.hidden_size, bias=False
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
# M3 uses per-head Gemma QK-norm over the head dimension.
|
| 129 |
+
self.q_norm = GemmaRMSNorm(head_dim, eps=args.rms_norm_eps)
|
| 130 |
+
self.k_norm = GemmaRMSNorm(head_dim, eps=args.rms_norm_eps)
|
| 131 |
+
|
| 132 |
+
self.rope = nn.RoPE(args.rotary_dim, traditional=False, base=args.rope_theta)
|
| 133 |
+
|
| 134 |
+
def __call__(self, x, mask=None, cache=None):
|
| 135 |
+
B, L, _ = x.shape
|
| 136 |
+
|
| 137 |
+
queries = self.q_proj(x).reshape(B, L, self.num_attention_heads, self.head_dim)
|
| 138 |
+
keys = self.k_proj(x).reshape(B, L, self.num_key_value_heads, self.head_dim)
|
| 139 |
+
values = self.v_proj(x).reshape(B, L, self.num_key_value_heads, self.head_dim)
|
| 140 |
+
|
| 141 |
+
# Per-head QK-norm over the head dim, before transpose / RoPE.
|
| 142 |
+
queries = self.q_norm(queries).transpose(0, 2, 1, 3)
|
| 143 |
+
keys = self.k_norm(keys).transpose(0, 2, 1, 3)
|
| 144 |
+
values = values.transpose(0, 2, 1, 3)
|
| 145 |
+
|
| 146 |
+
if cache is not None:
|
| 147 |
+
queries = self.rope(queries, offset=cache.offset)
|
| 148 |
+
keys = self.rope(keys, offset=cache.offset)
|
| 149 |
+
keys, values = cache.update_and_fetch(keys, values)
|
| 150 |
+
else:
|
| 151 |
+
queries = self.rope(queries)
|
| 152 |
+
keys = self.rope(keys)
|
| 153 |
+
|
| 154 |
+
output = scaled_dot_product_attention(
|
| 155 |
+
queries, keys, values, cache=cache, scale=self.scale, mask=mask
|
| 156 |
+
)
|
| 157 |
+
output = output.transpose(0, 2, 1, 3).reshape(B, L, -1)
|
| 158 |
+
return self.o_proj(output)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class MiniMaxM3SparseMoeBlock(nn.Module):
|
| 162 |
+
def __init__(self, args: ModelArgs):
|
| 163 |
+
super().__init__()
|
| 164 |
+
self.num_experts_per_tok = args.num_experts_per_tok
|
| 165 |
+
self.routed_scaling_factor = args.routed_scaling_factor
|
| 166 |
+
|
| 167 |
+
self.gate = nn.Linear(args.hidden_size, args.num_local_experts, bias=False)
|
| 168 |
+
self.e_score_correction_bias = mx.zeros((args.num_local_experts,))
|
| 169 |
+
self.switch_mlp = SwitchGLU(
|
| 170 |
+
args.hidden_size,
|
| 171 |
+
args.intermediate_size,
|
| 172 |
+
args.num_local_experts,
|
| 173 |
+
activation=SwiGLUOAI(args.swiglu_alpha, args.swiglu_limit),
|
| 174 |
+
)
|
| 175 |
+
self.shared_experts = MiniMaxM3MLP(args, args.shared_intermediate_size)
|
| 176 |
+
|
| 177 |
+
def __call__(self, x):
|
| 178 |
+
gates = self.gate(x.astype(mx.float32))
|
| 179 |
+
scores = mx.sigmoid(gates)
|
| 180 |
+
orig_scores = scores
|
| 181 |
+
scores = scores + self.e_score_correction_bias
|
| 182 |
+
|
| 183 |
+
k = self.num_experts_per_tok
|
| 184 |
+
inds = mx.argpartition(-scores, kth=k - 1, axis=-1)[..., :k]
|
| 185 |
+
weights = mx.take_along_axis(orig_scores, inds, axis=-1)
|
| 186 |
+
weights = weights / (mx.sum(weights, axis=-1, keepdims=True) + 1e-20)
|
| 187 |
+
weights = (weights * self.routed_scaling_factor).astype(x.dtype)
|
| 188 |
+
|
| 189 |
+
y = self.switch_mlp(x, inds)
|
| 190 |
+
y = (y * weights[..., None]).sum(axis=-2)
|
| 191 |
+
return y + self.shared_experts(x)
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
class MiniMaxM3DecoderLayer(nn.Module):
|
| 195 |
+
def __init__(self, args: ModelArgs, layer_idx: int):
|
| 196 |
+
super().__init__()
|
| 197 |
+
self.self_attn = MiniMaxM3Attention(args)
|
| 198 |
+
self.is_sparse = (args.mlp_layer_types or ["sparse"] * args.num_hidden_layers)[
|
| 199 |
+
layer_idx
|
| 200 |
+
] == "sparse"
|
| 201 |
+
if self.is_sparse:
|
| 202 |
+
self.block_sparse_moe = MiniMaxM3SparseMoeBlock(args)
|
| 203 |
+
else:
|
| 204 |
+
self.mlp = MiniMaxM3MLP(args, args.dense_intermediate_size)
|
| 205 |
+
self.input_layernorm = GemmaRMSNorm(args.hidden_size, eps=args.rms_norm_eps)
|
| 206 |
+
self.post_attention_layernorm = GemmaRMSNorm(
|
| 207 |
+
args.hidden_size, eps=args.rms_norm_eps
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
def __call__(self, x, mask=None, cache=None):
|
| 211 |
+
r = x + self.self_attn(self.input_layernorm(x), mask, cache)
|
| 212 |
+
mlp = self.block_sparse_moe if self.is_sparse else self.mlp
|
| 213 |
+
return r + mlp(self.post_attention_layernorm(r))
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class MiniMaxM3Model(nn.Module):
|
| 217 |
+
def __init__(self, args: ModelArgs):
|
| 218 |
+
super().__init__()
|
| 219 |
+
self.embed_tokens = nn.Embedding(args.vocab_size, args.hidden_size)
|
| 220 |
+
self.layers = [
|
| 221 |
+
MiniMaxM3DecoderLayer(args, i) for i in range(args.num_hidden_layers)
|
| 222 |
+
]
|
| 223 |
+
self.norm = GemmaRMSNorm(args.hidden_size, eps=args.rms_norm_eps)
|
| 224 |
+
|
| 225 |
+
def __call__(self, inputs, mask=None, cache=None):
|
| 226 |
+
h = self.embed_tokens(inputs)
|
| 227 |
+
if cache is None:
|
| 228 |
+
cache = [None] * len(self.layers)
|
| 229 |
+
if mask is None:
|
| 230 |
+
mask = create_attention_mask(h, cache[0])
|
| 231 |
+
for layer, c in zip(self.layers, cache):
|
| 232 |
+
h = layer(h, mask, c)
|
| 233 |
+
return self.norm(h)
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class Model(nn.Module):
|
| 237 |
+
def __init__(self, args: ModelArgs):
|
| 238 |
+
super().__init__()
|
| 239 |
+
self.args = args
|
| 240 |
+
self.model_type = args.model_type
|
| 241 |
+
self.model = MiniMaxM3Model(args)
|
| 242 |
+
if not args.tie_word_embeddings:
|
| 243 |
+
self.lm_head = nn.Linear(args.hidden_size, args.vocab_size, bias=False)
|
| 244 |
+
|
| 245 |
+
def __call__(self, inputs, mask=None, cache=None):
|
| 246 |
+
out = self.model(inputs, mask, cache)
|
| 247 |
+
if self.args.tie_word_embeddings:
|
| 248 |
+
return self.model.embed_tokens.as_linear(out)
|
| 249 |
+
return self.lm_head(out)
|
| 250 |
+
|
| 251 |
+
def sanitize(self, weights):
|
| 252 |
+
skip_prefixes = (
|
| 253 |
+
"vision_tower",
|
| 254 |
+
"multi_modal_projector",
|
| 255 |
+
"patch_merge_mlp",
|
| 256 |
+
"model.vision_tower",
|
| 257 |
+
"model.multi_modal_projector",
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
def keep(k):
|
| 261 |
+
if k.startswith(skip_prefixes):
|
| 262 |
+
return False
|
| 263 |
+
if ".self_attn.index_" in k: # MSA lightning indexer — dropped
|
| 264 |
+
return False
|
| 265 |
+
if ".mtp." in k or k.startswith("mtp.") or "model.mtp" in k:
|
| 266 |
+
return False
|
| 267 |
+
return True
|
| 268 |
+
|
| 269 |
+
def rename(k):
|
| 270 |
+
if k.startswith("language_model.model."):
|
| 271 |
+
return "model." + k[len("language_model.model.") :]
|
| 272 |
+
if k.startswith("language_model.lm_head."):
|
| 273 |
+
return "lm_head." + k[len("language_model.lm_head.") :]
|
| 274 |
+
if k.startswith("language_model."):
|
| 275 |
+
return k[len("language_model.") :]
|
| 276 |
+
return k
|
| 277 |
+
|
| 278 |
+
renamed = {}
|
| 279 |
+
for k, v in weights.items():
|
| 280 |
+
if not keep(k):
|
| 281 |
+
continue
|
| 282 |
+
renamed[rename(k)] = v
|
| 283 |
+
weights = renamed
|
| 284 |
+
|
| 285 |
+
# Stack per-expert w1/w2/w3 into SwitchGLU's batched experts.
|
| 286 |
+
if (
|
| 287 |
+
"model.layers.0.block_sparse_moe.switch_mlp.gate_proj.weight"
|
| 288 |
+
not in weights
|
| 289 |
+
):
|
| 290 |
+
mapping = {"w1": "gate_proj", "w2": "down_proj", "w3": "up_proj"}
|
| 291 |
+
for l in range(self.args.num_hidden_layers):
|
| 292 |
+
prefix = f"model.layers.{l}.block_sparse_moe"
|
| 293 |
+
if f"{prefix}.experts.0.w1.weight" not in weights:
|
| 294 |
+
continue
|
| 295 |
+
for orig, new in mapping.items():
|
| 296 |
+
stacked = mx.stack(
|
| 297 |
+
[
|
| 298 |
+
weights.pop(f"{prefix}.experts.{e}.{orig}.weight")
|
| 299 |
+
for e in range(self.args.num_local_experts)
|
| 300 |
+
]
|
| 301 |
+
)
|
| 302 |
+
weights[f"{prefix}.switch_mlp.{new}.weight"] = stacked
|
| 303 |
+
|
| 304 |
+
return weights
|
| 305 |
+
|
| 306 |
+
@property
|
| 307 |
+
def layers(self):
|
| 308 |
+
return self.model.layers
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def cast_predicate(self):
|
| 312 |
+
# Keep the router correction bias in fp32.
|
| 313 |
+
return lambda k: "e_score_correction_bias" not in k
|
| 314 |
+
|
| 315 |
+
@property
|
| 316 |
+
def quant_predicate(self):
|
| 317 |
+
def predicate(path, _):
|
| 318 |
+
# Routers stay high-precision (small, sensitive to quantization).
|
| 319 |
+
if path.endswith("block_sparse_moe.gate"):
|
| 320 |
+
return {"group_size": 64, "bits": 8}
|
| 321 |
+
return True
|
| 322 |
+
|
| 323 |
+
return predicate
|
model-00002-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14d532266305ebb15e241966706fabac6611fdd318f3a1de7911d779f13fb4ec
|
| 3 |
+
size 4338215150
|
model-00003-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07589e24a50538c74de9a6fc4cc48b86df544aac22990212fa6e3cfe050f7815
|
| 3 |
+
size 4169791141
|
model-00005-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9badf36907d6a180fbd11b120724d4fec248efa9f3a725d813b4683fd8841f44
|
| 3 |
+
size 4169791085
|
model-00006-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f82d96042372d50e32839294bc56d544c2c9e10cefe50b72f0eb9dfb99714371
|
| 3 |
+
size 4169791125
|
model-00007-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c611bdf6835a683f8011b38b2e3542e18a89ad19b30a54215d92ba32436bf7d8
|
| 3 |
+
size 4169791171
|
model-00009-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4709515ac8441574da5e56f7919ee8473f3b9a0b81b7f102d1b093e54fe803ee
|
| 3 |
+
size 4169791127
|
model-00010-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e1e6d6f1c4d8482cfeca2995c741c399a8472dc6afee0abca0643d726c66767
|
| 3 |
+
size 4169791181
|
model-00011-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:331581fbbe54bc442dbbf76e287479d872d764bd0000b2693132465cc5d8e724
|
| 3 |
+
size 4169791131
|
model-00012-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0df71364b4612a2eb9541d08cc88c06376b5902b0f4c2223a8d754672c3377db
|
| 3 |
+
size 4169791135
|
model-00014-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe8df3488deafe37b92a92181c57eae70065a2f56559ad6e578d39a282c03f55
|
| 3 |
+
size 4169791171
|
model-00015-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28c27d50c3409a12ad26f40997542230ac8de0b209fea1fe49c62f650fdeae35
|
| 3 |
+
size 4169791187
|
model-00017-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d3a5a6d40d5c250053887468d6b32de737b63c937ac9b0efc45076f0d419bc5
|
| 3 |
+
size 4169791127
|
model-00018-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f44ddcea8eb8502314af8b929550001a7e645a6ff0ec47604feb5e015cef4061
|
| 3 |
+
size 4169791143
|
model-00020-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f418ff7fb1e81cb46bbd56cc554d5b0f8ea54ce7278f114857a764e4cd0695d
|
| 3 |
+
size 4169791139
|
model-00022-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e16fd1dcc30fdaab9c9a920268983f4d262401c4303d25d85759d3d6a3da1b04
|
| 3 |
+
size 4169791203
|
model-00023-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35f5aee4b74886e647847c1f148a4e75ee60588aaaeec642a6badcc354ef32ea
|
| 3 |
+
size 4169791197
|
model-00024-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f57bd21e76438f259ad40516df0a8f23caa3b4acba392e985129765cf6fbad6
|
| 3 |
+
size 4169791179
|
model-00025-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ebffd2fa363c1c062b39c82d06ca1e0491200d3dbefc7a8e020aefbe096412a
|
| 3 |
+
size 4169791149
|
model-00026-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90f45ca455bb08acb14d41b59d4f16eccd5e1b62cc496a734f214072cb5d8e04
|
| 3 |
+
size 4169791149
|
model-00027-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca2c196cce644265f61d2d8ec8daa372e7e460a42c6ac2c5c855760b0d35bf38
|
| 3 |
+
size 4169791141
|
model-00028-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:611ae33ba7cf532929f5869598b2d7021bd5fbe77169eabdc83c5500ea8fea40
|
| 3 |
+
size 4169791169
|
model-00029-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:974ea6c2923cd4c155a4e018d88f92d04227e94a1ac68bf69352be8d99a1572d
|
| 3 |
+
size 4169791137
|
model-00031-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:809a23076ea10e11f1ff9292e04b09fb96d99f819ee6c055c5f71e5b40dce9ae
|
| 3 |
+
size 4169791149
|
model-00032-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb2348b9df14a074b1d75c0697971c349d886ee2219e262f9151673a1b830d4e
|
| 3 |
+
size 4169791121
|
model-00034-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5abf9deba808570847ed5eb40b8603a5c749aeea3ce7194714f3dd20d99383b6
|
| 3 |
+
size 4169791159
|
model-00035-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:591f010b487049e3f2ba3d799c0b30031b75fe7bbfe89af7f778d0db9b40a0ab
|
| 3 |
+
size 4169791121
|
model-00037-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05136fbd18919beb91883e88462017a34f6ae302ae3a3c20c9bfcac727e5712e
|
| 3 |
+
size 4169791183
|
model-00038-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37e5d0518591eff0f26b8b1682976ede5a6b978d2b795468edf8ae4da7c49b55
|
| 3 |
+
size 4169791201
|
model-00041-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9234d24fdf6c4dcf713f492e5ea474c444d1c43b1a3050034603a41b9048a14
|
| 3 |
+
size 4169791145
|
model-00042-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41f8bed1028f0aa2d99a97e63ce126cef3344f564f3ce452736f5d75df0a6a95
|
| 3 |
+
size 4169791203
|
model-00043-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6d5648b1d645abc0fb14fdf61ccf67d6c0195ac997d3fbda43a48374184f1c8
|
| 3 |
+
size 4169791169
|
model-00044-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94e5aed0456d28644f40674c711b2c8b99cb985c1f6c610802ade3a673446b54
|
| 3 |
+
size 4169791129
|
model-00046-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a91c292c02c8ec228eb18a5948ffe4bc49288284deb621d672163c8a9b8180ac
|
| 3 |
+
size 4169791147
|
model-00047-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cb89b230bba8ddd42e4f06fac5c5d8b5777c74c7ce327192247e45a2fabcf263
|
| 3 |
+
size 4169791123
|
model-00048-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f627deaab1441d08ae53962215bb6cdf41afb1196d55321cd90467136cc67fe
|
| 3 |
+
size 4169791151
|
model-00049-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:880c976864896cc7d7ff8e41f1a193d3034c289efbb0b2388295b727ed4422e9
|
| 3 |
+
size 4169791187
|
model-00050-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e7b4e24a2568a2d6ea709da49206b7e0b9fd45267927515a8e089fd4be5b7361
|
| 3 |
+
size 4169791129
|
model-00053-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7b64706dd5c5e9f1648fbf23785de1eeedcd0e4b5611429f8acaefa316a3aa80
|
| 3 |
+
size 4169791119
|
model-00055-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4f7b526126f09a15c29a5be4f497454831fc523c3385dfb46a393d54d19e10c
|
| 3 |
+
size 4169791163
|
model-00056-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7933769b12573b3b6895d41d3b14068934dc26b9c461fb695c29920972cb302
|
| 3 |
+
size 4169791125
|
model-00057-of-00057.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67b110ce8c83bc460b8af3803d475474ed79220c341109f79bc326b0c2961834
|
| 3 |
+
size 4800175181
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae73e31fefce04b005cb41c6781389426fae1a8553b6e58d29f133eaa31ebfb5
|
| 3 |
+
size 15524484
|