> 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 是一个新的开源模型，面向代理式编码和聊天使用场景。该模型在 SWE-Pro（56.22%）和 Terminal Bench 2（57.0%）上实现了 SOTA 性能。

该 **2300亿参数** （100亿活跃）模型是以下模型的继任者 [MiniMax-M25](/docs/zh/mo-xing/tutorials/minimax-m25.md) 并且拥有一个 **20 万上下文** 窗口。未量化的 bf16 需要 **457GB**。Unsloth Dynamic **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/unsloth-dynamic-2.0-ggufs.md) 上运行，并获得 SOTA 量化性能——因此会将重要层上调到更高位宽（例如 8 位或 16 位）。感谢 MiniMax 在第一天就提供访问权限。

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

### :gear: 使用指南

4 位动态量化 `UD-IQ4_XS` 使用 **108GB** 的磁盘空间——这非常适合放在一个 **128GB 统一内存的 Mac** 上，可实现约 15+ tokens/s，并且在以下配置下也能更快运行： **1x16GB GPU 和 96GB RAM** ，可达 25+ tokens/s。 **2 位** 量化版本或最大的 2 位版本都可以装入 96GB 设备。

对于接近 **全精度**，使用 `Q8_0` （8 位）版本，它使用 243GB，可安装在 256GB RAM 设备 / Mac 上，并可实现 15+ tokens/s。

{% hint style="success" %}
为了获得最佳性能，请确保你的总可用内存（VRAM + 系统 RAM）大于你正在下载的量化模型文件大小。如果不够，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)。你现在可以在以下环境中运行 MiniMax-M2.7： [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-de/studio.md)中运行和训练 Gemma 4 QAT，我们新的本地 AI 开源网页 UI。Unsloth Studio 让你可以在本地运行模型，支持 **MacOS、Windows**、Linux，以及：

{% columns %}
{% column %}

* 搜索、下载， [运行 GGUF](/docs/zh/xin-de/studio.md#run-models-locally) 以及 safetensor 模型
* [**自修复** 工具调用](/docs/zh/xin-de/studio.md#execute-code--heal-tool-calling) + **网页搜索**
* [**代码执行**](/docs/zh/xin-de/studio.md#run-models-locally) （Python、Bash）
* [自动推理](/docs/zh/xin-de/studio.md#model-arena) 参数调优（temp、top-p 等）
* 使用 llama.cpp 进行快速 CPU + GPU 推理和 CPU 卸载
  {% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="/files/2dfd7fbf0b551d243091cd1054c69104594c25d5" 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` （动态 4bit 量化）或其他量化版本，例如 `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-de/studio/chat.md) 标签页并在搜索栏中搜索 MiniMax-M2.7，然后下载你想要的模型和量化版本。由于文件较大，下载需要一些时间，请耐心等待。为确保快速推理，请确保你有 [足够的 RAM/VRAM](#usage-guide)，否则推理仍可运行，但 Unsloth 会卸载到你的 CPU。

<div data-with-frame="true"><figure><img src="/files/e9e036f2445291b598f861bc299eb74ac42c3b46" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### 运行 MiniMax-M2.7

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

更多信息，你可以查看我们的 [Unsloth Studio 推理指南](/docs/zh/xin-de/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` 以保存到指定位置。请记住，该模型的最大上下文长度只有 20 万。

按此进行 **大多数默认** 用例：

```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` 。我们建议使用我们的 4bit 动态量化 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 的 completion 库

为了将 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="/files/f2a237398524807c82010f28f74d6245736885fb" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/fb33d5f655dfe59134b3cc15a5571f8854926e28" 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="/files/10d8b0685f9b9ebc9327dc53223901da5b345377" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
