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

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

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

所有上传都使用 Unsloth [Dynamic 2.0](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/unsloth-dynamic-2.0-ggufs) 以获得 SOTA 量化性能——因此重要层会被提升到更高比特位（例如 8 位或 16 位）。感谢 MiniMax 在首日开放访问。

{% hint style="success" %}
新的 MiniMax-M2.7 GGUF 基准测试现已 उपलब्ध！ [在此查看](#gguf-benchmarks)
{% endhint %}

### :gear: 使用指南

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

对于接近 **全精度**，请使用 `Q8_0` （8-bit），它占用 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-bit [`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](https://unsloth.ai/docs/zh/xin-zeng/studio)中运行，这是我们面向本地 AI 的新开源 Web UI。Unsloth Studio 让你可以在本地运行模型于 **MacOS、Windows**、Linux 以及：

{% columns %}
{% column %}

* 搜索、下载， [运行 GGUF](https://unsloth.ai/docs/zh/xin-zeng/studio#run-models-locally) 和 safetensor 模型
* [**自我修复** 工具调用](https://unsloth.ai/docs/zh/xin-zeng/studio#execute-code--heal-tool-calling) + **网页搜索**
* [**代码执行**](https://unsloth.ai/docs/zh/xin-zeng/studio#run-models-locally) （Python、Bash）
* [自动推理](https://unsloth.ai/docs/zh/xin-zeng/studio#model-arena) 参数调优（temp、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&#x26;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` （动态 4bit 量化）或其他量化版本，如 `UD-Q4_K_XL` 。如果下载卡住，请参阅 [hugging-face-hub-xet-debugging](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/troubleshooting-and-faqs/hugging-face-hub-xet-debugging "mention")

然后前往 [Studio Chat](https://unsloth.ai/docs/zh/xin-zeng/studio/chat) 标签页，在搜索栏中搜索 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&#x26;token=e2568c00-86eb-452f-a4eb-10bcc0194ddf" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### 运行 MiniMax-M2.7

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

如需更多信息，你可以查看我们的 [Unsloth Studio 推理指南](https://unsloth.ai/docs/zh/xin-zeng/studio/chat).
{% 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-bit 量化）或其他量化版本，如 `UD-Q6_K_XL` 。我们建议使用 4bit 动态量化 UD-IQ4\_XS 来平衡体积和精度。如果下载卡住，请参阅 [hugging-face-hub-xet-debugging](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/troubleshooting-and-faqs/hugging-face-hub-xet-debugging "mention")

```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": "Create a Snake game."},],
)
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&#x26;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&#x26;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&#x26;token=04f4b3fd-9d04-4e80-9f06-09afd8ce884d" alt=""><figcaption></figcaption></figure>
