> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/zh/mo-xing/tutorials/minimax-m27.md).

# MiniMax-M2.7：如何本地运行

在你自己的设备上本地运行 MiniMax-M2.7 LLM！

MiniMax-M2.7 是一个面向 agentic 编码和聊天使用场景的新开源模型。该模型在 SWE-Pro（56.22%）和 Terminal Bench 2（57.0%）上实现了 SOTA 性能。

“ **230B 参数** （10B 激活）模型是……的继任者 [MiniMax-M25](/docs/zh/mo-xing/tutorials/minimax-m25.md) 并且有一个 **200K 上下文** 窗口。未量化的 bf16 需要 **457GB**. Unsloth 动态 **4 位** GGUF 将大小缩减至 **108GB** **(-60%)** 因此它可以在一台 **128GB RAM** 设备上运&#x884C;**:** [**MiniMax-M2.7 GGUF**](https://huggingface.co/unsloth/MiniMax-M2.7-GGUF)

所有上传都使用 Unsloth [Dynamic 2.0](/docs/zh/ji-chu-zhi-shi/dynamic-3.0-ggufs.md) 以获得 SOTA 量化性能——因此重要层会被上转为更高位宽（例如 8 位或 16 位）。感谢 MiniMax 提供的 day zero 访问权限。

{% hint style="success" %}
新的 MiniMax-M2.7 GGUF 基准测试现已提供！ [请看这里](#gguf-benchmarks)
{% endhint %}

### :gear: 使用指南

4 位动态量化 `UD-IQ4_XS` 使用 **108GB** 的磁盘空间——这非常适合放在一台 **128GB 统一内存的 Mac** 可达到约 15+ token/s，而且配合一个 **1×16GB GPU 和 96GB RAM** 可达到 25+ tokens/s。 **2 位** 量化版本，或者最大的 2-bit 版本，可以放在 96GB 设备上。

对于接近 **满精度**，请使用 `Q8_0` （8 位）时还会更快，使用 243GB 内存，并可在 256GB RAM 设备 / Mac 上以 15+ token/s 运行。

{% hint style="success" %}
为了获得最佳性能，请确保你的可用总内存（VRAM + 系统内存）大于你正在下载的量化模型文件大小。如果不足，llama.cpp 仍可通过 SSD/HDD 卸载运行，但推理会更慢。
{% endhint %}

### 推荐设置

MiniMax 建议使用以下参数以获得最佳性能： `temperature=1.0`, `top_p = 0.95`, `top_k = 40`.

{% columns %}
{% column %}

| 默认设置（大多数任务）         |
| ------------------- |
| `temperature = 1.0` |
| `top_p = 0.95`      |
| `top_k = 40`        |
| {% endcolumn %}     |

{% column %}

* **最大上下文窗口：** `196,608`
* 默认系统提示：

{% code overflow="wrap" %}

```
你是一个有帮助的助手。你的名字是 MiniMax-M2.7，由 MiniMax 构建。
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## 运行 MiniMax-M2.7 教程：

为了让 MiniMax-M2.7 在 128GB RAM 设备上运行，我们将使用 4 位 [`UD-IQ4_XS` 量化](https://huggingface.co/unsloth/MiniMax-M2.7-GGUF?show_file_info=UD-IQ4_XS%2FMiniMax-M2.7-UD-IQ4_XS-00001-of-00004.gguf)。你现在可以在 [llama.cpp](#run-in-llama.cpp) 和 [Unsloth Studio](#run-in-unsloth-studio).

{% hint style="warning" %}
请不要使用 CUDA 13.2 运行任何模型，因为这可能会导致输出乱码或质量很差。NVIDIA 正在修复该问题。
{% endhint %}

### 🦥 在 Unsloth Studio 中运行

MiniMax-M2.7 现在可以在 [Unsloth Studio](/docs/zh/xin/studio.md)，我们的全新本地 AI 开源网页 UI 中运行和训练。Unsloth Studio 让你能够在本地运行模型于 **MacOS、Windows**、Linux 以及：

{% columns %}
{% column %}

* 搜索、下载、 [运行 GGUF](/docs/zh/xin/studio.md#run-models-locally) 和 safetensor 模型
* [**自修复** 工具调用](/docs/zh/xin/studio.md#execute-code--heal-tool-calling) + **网页搜索**
* [**代码执行**](/docs/zh/xin/studio.md#run-models-locally) （Python、Bash）
* [自动推理](https://unsloth.ai/docs/desktop#feature-deep-dive) 参数调优（温度、top-p 等）
* 使用 llama.cpp 实现快速 CPU + GPU 推理和 CPU 卸载
  {% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FstfdTMsoBMmsbQsgQ1Ma%2Flandscape%20clip%20gemma.gif?alt=media&amp;token=eec5f2f7-b97a-4c1c-ad01-5a041c3e4013" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}

#### 安装 Unsloth

在你的终端中运行：

**MacOS、Linux、WSL：**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

**Windows PowerShell：**

```bash
irm https://unsloth.ai/install.ps1 | iex
```

{% endstep %}

{% step %}

#### 启动 Unsloth

**MacOS、Linux、WSL 和 Windows：**

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

**然后打开 `http://localhost:8888` 在你的浏览器中。**
{% endstep %}

{% step %}

#### 搜索并下载 MiniMax-M2.7

首次启动时，你需要创建一个密码来保护你的账户，并在之后重新登录。然后你会看到一个简短的引导向导，用于选择模型、数据集和基本设置。你可以随时跳过。

你可以选择 `UD-IQ4_XS` （动态 4 位量化）或其他量化版本，例如 `UD-Q4_K_XL` 。如果下载卡住，请查看 [Hugging Face Hub、XET 调试](/docs/zh/ji-chu-zhi-shi/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

然后前往 [Unsloth Chat](/docs/zh/xin/studio/chat.md) 标签页，并在搜索栏中搜索 MiniMax-M2.7，下载你想要的模型和量化版本。由于文件较大，下载会花一些时间，请耐心等待。为确保快速推理，请确保你有 [足够的 RAM/VRAM](#usage-guide)，否则推理仍然可以工作，但 Unsloth 会卸载到你的 CPU。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fh6qv7Mh2VqtdhZaixrnO%2FScreenshot%202026-04-11%20at%206.46.55%E2%80%AFPM.png?alt=media&amp;token=e2568c00-86eb-452f-a4eb-10bcc0194ddf" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### 运行 MiniMax-M2.7

在使用 Unsloth Studio 时，推理参数应自动设置，不过你仍然可以手动更改。你也可以编辑上下文长度、聊天模板和其他设置。

更多信息请查看我们的 [Unsloth Studio 推理指南](/docs/zh/xin/studio/chat.md).
{% endstep %}
{% endstepper %}

### ✨ 在 llama.cpp 中运行

{% hint style="warning" %}
请不要使用 CUDA 13.2 运行任何模型，因为这可能会导致输出乱码或质量很差。NVIDIA 正在修复该问题。
{% endhint %}

{% stepper %}
{% step %}
获取最新的 `llama.cpp` 在 [GitHub 上获取](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明进行操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只想使用 CPU 推理。 **对于 Apple Mac / Metal 设备**，设置 `-DGGML_CUDA=OFF` 然后按常规继续——Metal 支持默认开启。

{% code overflow="wrap" %}

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endcode %}
{% endstep %}

{% step %}
如果你想使用 `llama.cpp` 直接加载模型，你可以执行以下操作：(:IQ4\_XS) 是量化类型。你也可以通过 Hugging Face 下载（第 3 点）。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 保存到指定位置。请记住，该模型的最大上下文长度只有 200K。

按照以下内容进行 **大多数默认** 场景：

```bash
export LLAMA_CACHE="unsloth/MiniMax-M2.7-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/MiniMax-M2.7-GGUF:UD-IQ4_XS \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 40
```

{% endstep %}

{% step %}
下载模型（在安装 `pip install huggingface_hub hf_transfer`之后）。你可以选择 UD-IQ4\_XS（动态 4 位量化）或其他量化版本，例如 `UD-Q6_K_XL` 。我们建议使用我们的 4 位动态量化 UD-IQ4\_XS，以平衡体积和准确率。如果下载卡住，请参见 [Hugging Face Hub、XET 调试](/docs/zh/ji-chu-zhi-shi/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/MiniMax-M2.7-GGUF \\
    --local-dir unsloth/MiniMax-M2.7-GGUF \\
    --include "*UD-IQ4_XS*" # 8 位请使用 "*Q8_0*"
```

{% endstep %}

{% step %}
你可以修改 `--threads 32` CPU 线程数， `--ctx-size 16384` 用于上下文长度， `--n-gpu-layers 2` 用于 GPU 卸载的层数。如果你的 GPU 显存不足，请尝试调整它。如果你只使用 CPU 推理，也请将其移除。

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/MiniMax-M2.7-GGUF/UD-IQ4_XS/MiniMax-M2.7-UD-IQ4_XS-00001-of-00004.gguf \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 40
```

{% endcode %}
{% endstep %}
{% endstepper %}

#### 🦙 Llama-server 与 OpenAI 的补全库

为了将 MiniMax-M2.7 部署到生产环境中，我们使用 `llama-server` 或 OpenAI API。在新的终端中，例如通过 tmux，使用以下方式部署模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-server \\
    --model unsloth/MiniMax-M2.7-GGUF/UD-IQ4_XS/MiniMax-M2.7-UD-IQ4_XS-00001-of-00004.gguf \\
    --alias "unsloth/MiniMax-M2.7" \\
    --prio 3 \
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.01 \
    --top-k 40 \
    --port 8001
```

{% endcode %}

然后在新的终端中，在完成以下操作后 `pip install openai`，执行：

{% code overflow="wrap" %}

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
    model = "unsloth/MiniMax-M2.7",
    messages = [{"role": "user", "content": "创建一个贪吃蛇游戏。"},],
)
print(completion.choices[0].message.content)
```

{% endcode %}

## 📊 基准测试

### GGUF 基准测试

以下是 MiniMax-M2.7 的 KLD 99% 基准测试。左下角越好：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FOkxq866NI68lXd0LBcsV%2FCode_Generated_Image(18)(1).png?alt=media&amp;token=ce73524f-1db2-410a-ac2f-a26cba04d270" alt=""><figcaption></figcaption></figure>

由于 MiniMax-M2.7 使用与 MiniMax-M2.5 相同的架构，M2.7 的 GGUF 量化基准测试应该与 M2.5 非常相似。因此，我们也会参考之前针对 M2.5 进行的量化基准测试：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FhfO2gsbz2lWrZXg3ojyE%2FHCGBTzgboAASv_A.png?alt=media&amp;token=7d6334ca-4f3c-4946-aacd-d55527375fce" alt=""><figcaption></figcaption></figure>

[Benjamin Marie（第三方）对](https://x.com/bnjmn_marie/status/2027043753484021810/photo/1) **MiniMax-M2.5** 使用 **Unsloth GGUF 量化版本** 在一个 **750 提示混合套件** （LiveCodeBench v6、MMLU Pro、GPQA、Math500）进行了基准测试，并报告了 **整体准确率** 和 **相对错误增长** （量化模型与原始模型相比，出错频率增加了多少）。

无论精度如何，Unsloth 量化版本在准确率和相对误差方面都远胜于非 Unsloth 对应版本（尽管它们小 8GB）。

**关键结果：**

* **这里最佳的质量/大小权衡： `unsloth UD-Q4_K_XL`.**\
  它最接近原版：仅 **6.0 分** 下降，而且“仅仅” **+22.8%** 比基线多出更多错误。
* **其他 Unsloth Q4 量化版本表现非常接近（准确率约 64.5–64.9）。**\
  `IQ4_NL`, `MXFP4_MOE`，以及 `UD-IQ2_XXS` 在这个基准上质量基本相同，其中 **约 33–35%** 比原版多出更多错误。
* Unsloth GGUF 的表现明显优于其他非 Unsloth GGUF，例如参见 `lmstudio-community - Q4_K_M` （尽管小 8GB），以及 `AesSedai - IQ3_S`.

### 官方基准

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fn5Xz2P6kzHRH2sQGPsHH%2Fminimaxm2.7%20model.jpg?alt=media&amp;token=04f4b3fd-9d04-4e80-9f06-09afd8ce884d" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/zh/mo-xing/tutorials/minimax-m27.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
