Instructions to use MiniMaxAI/MiniMax-M2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MiniMaxAI/MiniMax-M2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MiniMaxAI/MiniMax-M2", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MiniMaxAI/MiniMax-M2", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("MiniMaxAI/MiniMax-M2", trust_remote_code=True) 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use MiniMaxAI/MiniMax-M2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MiniMaxAI/MiniMax-M2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MiniMaxAI/MiniMax-M2
- SGLang
How to use MiniMaxAI/MiniMax-M2 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 "MiniMaxAI/MiniMax-M2" \ --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": "MiniMaxAI/MiniMax-M2", "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 "MiniMaxAI/MiniMax-M2" \ --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": "MiniMaxAI/MiniMax-M2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MiniMaxAI/MiniMax-M2 with Docker Model Runner:
docker model run hf.co/MiniMaxAI/MiniMax-M2
xuebi commited on
Commit ·
6d30eb0
1
Parent(s): c2b7e11
update: prepare for transformers
Browse filesSigned-off-by: xuebi <xuebi@minimaxi.com>
- config.json +6 -1
- generation_config.json +2 -0
config.json
CHANGED
|
@@ -79,7 +79,7 @@
|
|
| 79 |
"layernorm_mlp_beta": 1.0,
|
| 80 |
"max_position_embeddings": 196608,
|
| 81 |
"mlp_intermediate_size": 8192,
|
| 82 |
-
"model_type": "
|
| 83 |
"mtp_transformer_layers": 1,
|
| 84 |
"num_attention_heads": 48,
|
| 85 |
"num_experts_per_tok": 8,
|
|
@@ -96,6 +96,11 @@
|
|
| 96 |
"weight_block_size": [
|
| 97 |
128,
|
| 98 |
128
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
]
|
| 100 |
},
|
| 101 |
"rms_norm_eps": 1e-06,
|
|
|
|
| 79 |
"layernorm_mlp_beta": 1.0,
|
| 80 |
"max_position_embeddings": 196608,
|
| 81 |
"mlp_intermediate_size": 8192,
|
| 82 |
+
"model_type": "minimax_m2",
|
| 83 |
"mtp_transformer_layers": 1,
|
| 84 |
"num_attention_heads": 48,
|
| 85 |
"num_experts_per_tok": 8,
|
|
|
|
| 96 |
"weight_block_size": [
|
| 97 |
128,
|
| 98 |
128
|
| 99 |
+
],
|
| 100 |
+
"modules_to_not_convert": [
|
| 101 |
+
"gate",
|
| 102 |
+
"e_score_correction_bias",
|
| 103 |
+
"lm_head"
|
| 104 |
]
|
| 105 |
},
|
| 106 |
"rms_norm_eps": 1e-06,
|
generation_config.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
{
|
|
|
|
| 2 |
"do_sample": true,
|
|
|
|
| 3 |
"temperature": 1.0,
|
| 4 |
"top_p": 0.95,
|
| 5 |
"top_k": 40,
|
|
|
|
| 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,
|