Upload docs/transformers_deploy_guide.hf_temp_rename.md with huggingface_hub
Browse files
docs/transformers_deploy_guide.hf_temp_rename.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MiniMax M2.1 Model Transformers Deployment Guide
|
| 2 |
+
|
| 3 |
+
[English Version](./transformers_deploy_guide.md) | [Chinese Version](./transformers_deploy_guide_cn.md)
|
| 4 |
+
|
| 5 |
+
## Applicable Models
|
| 6 |
+
|
| 7 |
+
This document applies to the following models. You only need to change the model name during deployment.
|
| 8 |
+
|
| 9 |
+
- [MiniMaxAI/MiniMax-M2.1](https://huggingface.co/MiniMaxAI/MiniMax-M2.1)
|
| 10 |
+
- [MiniMaxAI/MiniMax-M2](https://huggingface.co/MiniMaxAI/MiniMax-M2)
|
| 11 |
+
|
| 12 |
+
The deployment process is illustrated below using MiniMax-M2.1 as an example.
|
| 13 |
+
|
| 14 |
+
## System Requirements
|
| 15 |
+
|
| 16 |
+
- OS: Linux
|
| 17 |
+
|
| 18 |
+
- Python: 3.9 - 3.12
|
| 19 |
+
|
| 20 |
+
- Transformers: 4.57.1
|
| 21 |
+
|
| 22 |
+
- GPU:
|
| 23 |
+
|
| 24 |
+
- compute capability 7.0 or higher
|
| 25 |
+
|
| 26 |
+
- Memory requirements: 220 GB for weights.
|
| 27 |
+
|
| 28 |
+
## Deployment with Python
|
| 29 |
+
|
| 30 |
+
It is recommended to use a virtual environment (such as **venv**, **conda**, or **uv**) to avoid dependency conflicts.
|
| 31 |
+
|
| 32 |
+
We recommend installing Transformers in a fresh Python environment:
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
uv pip install transformers==4.57.1 torch accelerate --torch-backend=auto
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
Run the following Python script to run the model. Transformers will automatically download and cache the MiniMax-M2.1 model from Hugging Face.
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
| 42 |
+
import torch
|
| 43 |
+
|
| 44 |
+
MODEL_PATH = "MiniMaxAI/MiniMax-M2.1"
|
| 45 |
+
|
| 46 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 47 |
+
MODEL_PATH,
|
| 48 |
+
device_map="auto",
|
| 49 |
+
trust_remote_code=True,
|
| 50 |
+
)
|
| 51 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
| 52 |
+
|
| 53 |
+
messages = [
|
| 54 |
+
{"role": "user", "content": [{"type": "text", "text": "What is your favourite condiment?"}]},
|
| 55 |
+
{"role": "assistant", "content": [{"type": "text", "text": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"}]},
|
| 56 |
+
{"role": "user", "content": [{"type": "text", "text": "Do you have mayonnaise recipes?"}]}
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to("cuda")
|
| 60 |
+
|
| 61 |
+
generated_ids = model.generate(model_inputs, max_new_tokens=100, generation_config=model.generation_config)
|
| 62 |
+
|
| 63 |
+
response = tokenizer.batch_decode(generated_ids)[0]
|
| 64 |
+
|
| 65 |
+
print(response)
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Common Issues
|
| 69 |
+
|
| 70 |
+
### Hugging Face Network Issues
|
| 71 |
+
|
| 72 |
+
If you encounter network issues, you can set up a proxy before pulling the model.
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
export HF_ENDPOINT=https://hf-mirror.com
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### MiniMax-M2 model is not currently supported
|
| 79 |
+
|
| 80 |
+
Please check that trust_remote_code=True.
|
| 81 |
+
|
| 82 |
+
## Getting Support
|
| 83 |
+
|
| 84 |
+
If you encounter any issues while deploying the MiniMax model:
|
| 85 |
+
|
| 86 |
+
- Contact our technical support team through official channels such as email at [model@minimax.io](mailto:model@minimax.io)
|
| 87 |
+
|
| 88 |
+
- Submit an issue on our [GitHub](https://github.com/MiniMax-AI) repository
|
| 89 |
+
|
| 90 |
+
We continuously optimize the deployment experience for our models. Feedback is welcome!
|
| 91 |
+
|