> 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/mistral-3.5.md).

# Mistral 3.5 - 如何在本地运行

Mistral 3.5 模型指南，可在你的设备上本地运行或微调

Mistral 发布了 Mistral-Medium-3.5-128B，这是他们新的稠密型 128B 参数、多模态、混合推理模型。它支持文本和图像输入、文本输出、256K 上下文窗口，并且在推理、编码、长上下文、工具使用、代理式工作流以及多模态文档/图像理解方面表现出色。

Mistral Medium 3.5 以仅为其 5 倍大小的模型提供极具竞争力的性能。可在约 64GB RAM 上本地运行。GGUF： [Mistral-Medium-3.5-128B-GGUF](https://huggingface.co/unsloth/Mistral-Medium-3.5-128B-GGUF)

{% hint style="success" %}
**2026 年 5 月 1 日更新：** 我们与 Mistral 合作修复了影响某些实现的 Mistral Medium 3.5 推理问题，并发布了包含该修复的更新版 GGUF（**与 Unsloth 无关** 或我们的量化版本）。该问题由 YaRN 解析中的一个怪癖导致，影响了多个实现，包括 `transformers` 和 `llama.cpp`。将 `mscale_all_dim` 从 `1` 改为 `0` 即可解决。我们还修复了 `mmproj` 文件未正确生成的问题。

<mark style="background-color:$success;">**Mistral 现已将我们的修复推送到他们的官方仓库！**</mark>
{% endhint %}

### 使用指南

{% hint style="info" %}
GGUF 的视觉功能目前已支持。后续会提供支持。
{% endhint %}

表：Mistral Medium 3.5 推荐硬件要求。单位为总内存：RAM + VRAM，或统一内存。

| Mistral 3.5     | 3 位   | 4 位   | 8 位        |
| --------------- | ----- | ----- | ---------- |
| Medium 3.5 128B | 64 GB | 80 GB | 128-170 GB |

{% hint style="info" %}
你的总可用内存应至少超过你下载的量化模型大小。如果不足，llama.cpp 仍可通过部分 RAM / 磁盘卸载运行，但生成会更慢。长上下文、更大的批次、重工具调用的代理运行以及图像提示词也需要更多内存。
{% endhint %}

#### 推荐设置

使用 Mistral 推荐的推理设置：

* `reasoning_effort="none"` → 快速即时回复、聊天、信息提取和简单指令。
* `reasoning_effort="high"` → 推理模式，推荐用于复杂提示、编码、研究、数学和代理式使用。

推荐的采样默认值：

* 使用 `temperature = 0.7` 用于 `reasoning_effort="high"`.
* 使用 `temperature = 0.0` 改为 `0.7` 用于 `reasoning_effort="none"`，具体取决于任务。
* 保持重复惩罚和存在惩罚关闭，或设为 `1.0` ，除非你看到循环输出。
* 最大上下文长度为 `262,144`

#### **推理模式**

Mistral Medium 3.5 支持即时指令模式和带有 'high' 选项的推理模式。

要在 llama.cpp / llama-server 中启用高推理：

```bash
--chat-template-kwargs '{"reasoning_effort":"high"}'
```

要禁用推理：

```bash
--chat-template-kwargs '{"reasoning_effort":"none"}'
```

如果你使用的是 Windows PowerShell，请使用：

```powershell
--chat-template-kwargs "{\"reasoning_effort\":\"none\"}"
```

## 运行 Mistral 3.5 教程

由于 Mistral Medium 3.5 是一个稠密型 128B 模型，本地推理的推荐起点是动态 4 位 GGUF。GGUF： `unsloth/Mistral-Medium-3.5-128B-GGUF`

<a href="/docs/zh/mo-xing/mistral-3.5.md#unsloth-studio-guide" class="button primary">在 Unsloth Studio 中运行</a><a href="/pages/5902f65155c9213c17d6735294471de2eb587dd1#llama.cpp-guide" class="button secondary">在 llama.cpp 中运行</a>

{% hint style="warning" %}
目前没有多模态/视觉 GGUF 可在 **Ollama** 运行，因为需要单独的 `mmproj` 视觉文件。请使用兼容 llama.cpp 的后端。

不要使用 **CUDA 13.2** ，否则你可能会得到乱码输出。NVIDIA 正在修复。
{% endhint %}

### 🦥 Unsloth Studio 指南

在本教程中，我们将使用 [Unsloth Studio](/docs/zh/xin/studio.md)，这是我们用于运行和训练 LLM 的全新网页界面。使用 Unsloth Studio，你可以运行模型并输入 **音频**图像和文本，并可在本地处理，运行于 **Mac、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 等）
* [训练 LLM](/docs/zh/xin/studio.md#no-code-training) 速度快 2 倍，VRAM 占用减少 70%
  {% 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%2FFeQ0UUlnjXkDdqhcWglh%2Fskinny%20studio%20chat.png?alt=media&amp;token=c2ee045f-c243-4024-a8e4-bb4dbe7bae79" 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 Studio（一次性）

该设置会自动安装 Node.js（通过 nvm）、构建前端、安装所有 Python 依赖，并构建带有 CUDA 支持的 llama.cpp。

{% hint style="info" %}
**WSL 用户：** 系统会提示你输入你的 `sudo` 密码，以安装构建依赖项（`cmake`, `git`, `libcurl4-openssl-dev`).
{% endhint %}
{% endstep %}

{% step %}

#### 启动 Unsloth

**MacOS、Linux、WSL：**

```bash
source unsloth_studio/bin/activate
unsloth studio -H 0.0.0.0 -p 8888
```

**Windows PowerShell：**

```bash
& .\unsloth_studio\Scripts\unsloth.exe studio -H 0.0.0.0 -p 8888
```

<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%2Fd1yMMNa65Ccz50Ke0E7r%2FScreenshot%202026-03-17%20at%2012.32.38%E2%80%AFAM.png?alt=media&amp;token=9369cfe7-35b1-4955-b8cb-42f7ecb43780" alt="" width="375"><figcaption></figcaption></figure></div>

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

{% step %}

#### 搜索并下载 Mistral Medium 3.5

首次启动时，你需要创建一个密码来保护你的账户，并在稍后重新登录。然后前往 [Unsloth Chat](/docs/zh/xin/studio/chat.md) 标签页，在搜索栏中搜索 Mistral 3.5，并下载你想要的模型和量化版本。
{% endstep %}

{% step %}

#### 运行 Mistral 3.5

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

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

### 🦙 Llama.cpp 指南

本指南中，我们将为 Mistral Medium 3.5 使用 Unsloth Dynamic 4 位版本。请参见： `unsloth/Mistral-Medium-3.5-128B-GGUF`.

在这些教程中，我们将使用 llama.cpp 进行快速本地推理，尤其适合你拥有 CPU 或高内存统一内存机器的情况。

**1. 构建 llama.cpp**

获取最新的 `llama.cpp` 在 GitHub 上。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只想进行 CPU 推理。对于 Apple Mac / Metal 设备，请设置 `-DGGML_CUDA=OFF`；Metal 支持默认开启。

```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
```

**2. 直接从 Hugging Face 运行**

```bash
export LLAMA_CACHE="unsloth/Mistral-Medium-3.5-128B-GGUF"

./llama.cpp/llama-cli \\
    -hf unsloth/Mistral-Medium-3.5-128B-GGUF:UD-Q4_K_XL \\
    --temp 0.7 \\
    --chat-template-kwargs '{"reasoning_effort":"none"}'
```

对于高推理模式：

```bash
./llama.cpp/llama-cli \\
    -hf unsloth/Mistral-Medium-3.5-128B-GGUF:UD-Q4_K_XL \\
    --temp 0.7 \\
    --chat-template-kwargs '{"reasoning_effort":"high"}'
```

**3. 手动下载模型**

安装后 `huggingface_hub` 和 `hf_transfer`:

```bash
pip install huggingface_hub hf_transfer

hf download unsloth/Mistral-Medium-3.5-128B-GGUF \\
    --local-dir unsloth/Mistral-Medium-3.5-128B-GGUF \\
    --include "*UD-Q4_K_XL*" \\
    --include "*mmproj*"
```

如果下载卡住，请设置：

```bash
export HF_HUB_ENABLE_HF_TRANSFER=1
```

**4. 运行本地 GGUF**

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Mistral-Medium-3.5-128B-GGUF/Mistral-Medium-3.5-128B-UD-Q4_K_XL.gguf \\
    --temp 0.7 \\
    --chat-template-kwargs '{"reasoning_effort":"none"}'
```

如果包含多模态投影器 GGUF，请使用：

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Mistral-Medium-3.5-128B-GGUF/Mistral-Medium-3.5-128B-UD-Q4_K_XL.gguf \\
    --mmproj unsloth/Mistral-Medium-3.5-128B-GGUF/mmproj-BF16.gguf \\
    --temp 0.7 \\
    --chat-template-kwargs '{"reasoning_effort":"none"}'
```

#### Llama-server 部署

要在 llama-server 上部署 Mistral Medium 3.5，请使用：

```bash
./llama.cpp/llama-server \\
    -hf unsloth/Mistral-Medium-3.5-128B-GGUF:UD-Q4_K_XL \\
    --alias "mistral-medium-3.5" \\
    --host 0.0.0.0 \\
    --port 8001 \\
    --temp 0.7 \\
    --chat-template-kwargs '{"reasoning_effort":"none"}'
```

对于推理模式：

```bash
--chat-template-kwargs '{"reasoning_effort":"high"}'
```

如果你使用的是 Windows PowerShell，请使用：

```powershell
--chat-template-kwargs "{\"reasoning_effort\":\"high\"}"
```

你可以使用兼容 OpenAI 的请求来访问 llama-server：

```bash
curl http://localhost:8001/v1/chat/completions \\
  -H "Content-Type: application/json" \\
  -d '{
    "model": "mistral-medium-3.5",
    "messages": [
      {"role": "user", "content": "解释即时模式和推理模式之间的主要区别。"}
    ],
    "temperature": 0.7
  }'
```

### Mistral 3.5 最佳实践

#### 提示示例

**简单推理提示**

```
系统：
你是一个精确的推理助手。请谨慎求解，并只给出最终答案和简短说明。

用户：
一列火车在上午 8:15 出发，并在上午 11:47 到达。旅程持续了多长时间？
```

使用 `reasoning_effort="high"` 适用于这种风格的提示。

**OCR / 文档提示**

对于 OCR 和文档提取，请先放图像，并要求结构化输出。

```
[先图像]
从这张收据中提取所有文本。以 JSON 形式返回商家、日期、商品条目和总额。
```

**多模态比较提示**

```
[图像 1]
[图像 2]
比较这两张截图，并告诉我哪一张更可能让新用户感到困惑。给出 3 个具体原因。
```

**编码代理提示**

```
你是一个在代码仓库中工作的编码代理。
先检查相关文件，然后提出最小化补丁。
返回最终答案，并包含：摘要、已更改文件、运行的测试和风险。
```

使用 `reasoning_effort="high"` 并使用工具调用进行代码库探索。

**JSON / 函数调用提示**

```
在需要计算或查询时，始终使用所提供的工具。
只返回有效 JSON。不要在 JSON 对象之外包含任何说明文字。
```

### 基准测试

<div><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Ffzh7zfLQYF1Tn6YAriUx%2Frfffrrf.png?alt=media&amp;token=0247ce56-5b61-4ffb-a3dc-44ac6e4477d0" alt=""><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fj7W8gGzonNSM3aEY2qQr%2Ffrfrfref.png?alt=media&amp;token=cebcb72b-6813-47ed-ba31-a80e6d4b43d8" alt=""><figcaption></figcaption></figure></div>


---

# 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/mistral-3.5.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.
