> 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 性能。

该 **230B 参数** （10B 活跃）模型是……的后继 [MiniMax-M25](/docs/zh/mo-xing/tutorials/minimax-m25.md) 并且具有一个 **200K 上下文** 窗口。未量化的 bf16 需要 **457GB**。Unsloth 动态 **4-bit** 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 在首发日提供访问权限。

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

### :gear: 使用指南

4 位动态量化 `UD-IQ4_XS` 使用 **108GB** 的磁盘空间——这可以很好地放在一台 **128GB 统一内存的 Mac** 上，实现约 15+ token/秒，而且在配备一台 **1x16GB GPU 和 96GB RAM** 时也可达到 25+ token/秒。 **2 位** 量化版本，或者最大的 2 位版本，可装入 96GB 设备。

对于接近 **全精度**，使用 `Q8_0` （8 位），其占用 243GB，可在 256GB RAM 的设备 / Mac 上运行，速度达 15+ token/秒。

{% 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)。你现在可以在 [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)中运行和训练 Gemma 4 QAT，这是我们为本地 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) 参数调优（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` （动态 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="/files/e9e036f2445291b598f861bc299eb74ac42c3b46" 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="/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.
