ineso22 commited on
Commit
dfd1e81
·
verified ·
1 Parent(s): ce2e1bd

Upload docs/transformers_deploy_guide_cn.hf_temp_rename.md with huggingface_hub

Browse files
docs/transformers_deploy_guide_cn.hf_temp_rename.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MiniMax M2.1 模型 Transformers 部署指南
2
+
3
+ [英文版](./transformers_deploy_guide.md) | [中文版](./transformers_deploy_guide_cn.md)
4
+
5
+ ## 本文档适用模型
6
+
7
+ 本文档适用以下模型,只需在部署时修改模型名称即可。
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
+ 以下以 MiniMax-M2.1 为例说明部署流程。
13
+
14
+ ## 环境要求
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
+ - 显存需求:权重需要 220 GB
27
+
28
+ ## 使用 Python 部署
29
+
30
+ 建议使用虚拟环境(如 **venv**、**conda**、**uv**)以避免依赖冲突。
31
+
32
+ 建议在全新的 Python 环境中安装 Transformers:
33
+
34
+ ```bash
35
+ uv pip install transformers==4.57.1 torch accelerate --torch-backend=auto
36
+ ```
37
+
38
+ 运行如下 Python 命令运行模型,Transformers 会自动从 Huggingface 下载并缓存 MiniMax-M2.1 模型。
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
+ ## 常见问题
69
+
70
+ ### Huggingface 网络问题
71
+
72
+ 如果遇到网络问题,可以设置代理后再进行拉取。
73
+
74
+ ```bash
75
+ export HF_ENDPOINT=https://hf-mirror.com
76
+ ```
77
+
78
+ ### MiniMax-M2 model is not currently supported
79
+
80
+ 请确认开启 trust_remote_code=True。
81
+
82
+ ## 获取支持
83
+
84
+ 如果在部署 MiniMax 模型过程中遇到任何问题:
85
+
86
+ - 通过邮箱 [model@minimax.io](mailto:model@minimax.io) 等官方渠道联系我们的技术支持团队
87
+
88
+ - 在我们的 [GitHub](https://github.com/MiniMax-AI) 仓库提交 Issue
89
+
90
+ - 通过我们的 [官方企业微信交流群](https://github.com/MiniMax-AI/MiniMax-AI.github.io/blob/main/images/wechat-qrcode.jpeg) 反馈
91
+
92
+ 我们会持续优化模型的部署体验,欢迎反馈!