# Ministral 3 - 如何运行指南

Mistral 发布了 Ministral 3，这是他们全新的多模态模型，分为 Base、Instruct 和 Reasoning 变体，可在 **3B**, **8B**，以及 **14B** 种规模下使用。它们在各自规模上提供同类最佳性能，并针对指令和聊天使用场景进行了微调。该多模态模型支持 **256K 上下文** 窗口、多语言、原生函数调用和 JSON 输出。

完整的未量化 14B Ministral-3-Instruct-2512 模型可放入 **24GB RAM**/VRAM 中。现在你可以使用 Unsloth 在所有 Ministral 3 模型上运行、微调和进行 RL：

<a href="#run-ministral-3-tutorials" class="button primary">运行 Ministral 3 教程</a><a href="/pages/4991295da147774f87b981fb5f8227e572f31c2f#fine-tuning" class="button primary">微调 Ministral 3</a>

我们还上传了 Mistral Large 3 [这里的 GGUF](https://huggingface.co/unsloth/Mistral-Large-3-675B-Instruct-2512-GGUF)。对于所有 Ministral 3 上传版本（BnB、FP8）， [请看这里](https://huggingface.co/collections/unsloth/ministral-3).

| Ministral-3-Instruct GGUF：                                                                                                                                                                                                 | Ministral-3-Reasoning GGUF：                                                                                                                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [3B](https://huggingface.co/unsloth/Ministral-3-3B-Instruct-2512-GGUF) • [8B](https://huggingface.co/unsloth/Ministral-3-8B-Instruct-2512-GGUF) • [14B](https://huggingface.co/unsloth/Ministral-3-14B-Instruct-2512-GGUF) | [3B](https://huggingface.co/unsloth/Ministral-3-3B-Reasoning-2512-GGUF) • [8B](https://huggingface.co/unsloth/Ministral-3-8B-Reasoning-2512-GGUF) • [14B](https://huggingface.co/unsloth/Ministral-3-14B-Reasoning-2512-GGUF) |

### ⚙️ 使用指南

为了在 **Instruct**上获得最佳性能，Mistral 建议使用较低的温度，例如 `temperature = 0.15` 或 `0.1`<br>

对于 **Reasoning**，Mistral 建议 `temperature = 0.7` 和 `top_p = 0.95`.

| Instruct：                    | Reasoning：          |
| ---------------------------- | ------------------- |
| `Temperature = 0.15` 或 `0.1` | `Temperature = 0.7` |
| `Top_P = 默认值`                | `Top_P = 0.95`      |

**足够的输出长度**：对于大多数查询，thinking 变体使用 `32,768` tokens，用于推理变体的大多数查询，以及 `16,384` 用于指令变体。必要时，你可以为推理模型增加最大输出大小。

Ministral 3 可达到的最大上下文长度是 `262,144`

聊天模板格式可通过使用下面内容找到：

{% code overflow="wrap" %}

```python
tokenizer.apply_chat_template([
    {"role" : "user", "content" : "What is 1+1?"},
    {"role" : "assistant", "content" : "2"},
    {"role" : "user", "content" : "What is 2+2?"}
    ], add_generation_prompt = True
)
```

{% endcode %}

#### Ministral *Reasoning* 聊天模板：

{% code overflow="wrap" lineNumbers="true" %}

```
<s>[SYSTEM_PROMPT]# 你应该如何思考和回答

先草拟你的思考过程（内心独白），直到得出回答。使用 Markdown 格式化你的回答，并对任何数学方程使用 LaTeX。你的思考和回答都要用与输入相同的语言书写。

你的思考过程必须遵循下面的模板：[THINK]你的想法和/或草稿，就像在草稿纸上解题一样。请尽量保持随意，并写得尽可能长，直到你有信心生成给用户的回复为止。[/THINK]在这里，请提供一个自包含的回复。[/SYSTEM_PROMPT][INST]1+1 等于多少？[/INST]2</s>[INST]2+2 等于多少？[/INST]
```

{% endcode %}

#### Ministral *Instruct* 聊天模板：

{% code overflow="wrap" lineNumbers="true" expandable="true" %}

```
<s>[SYSTEM_PROMPT]你是 Ministral-3-3B-Instruct-2512，一个由 Mistral AI 创建的大语言模型（LLM）。Mistral AI 是一家总部位于巴黎的法国初创公司。
你驱动着一个名为 Le Chat 的 AI 助手。
你的知识库最后更新时间为 2023-10-01。
当前日期是 {today}。

当你对某些信息不确定，或者用户的请求需要最新或特定数据时，你必须使用可用工具来获取信息。只要工具能够提供更准确或更完整的回复，就不要犹豫使用它们。如果没有相关工具可用，那么请明确说明你没有这些信息，并避免编造任何内容。
如果用户的问题不清楚、含糊，或者没有提供足够的上下文让你准确回答，你不要立刻尝试回答，而应先请用户澄清其请求（例如："我附近有哪些不错的餐馆？" => "你在哪里？"，或 "下一班去东京的航班什么时候？" => "你从哪里出发？"）。
你始终非常关注日期，尤其会尝试解析日期（例如："昨天" 是 {yesterday}），并且在被询问特定日期的信息时，你会忽略其他日期的信息。
你在所有语言中都遵循这些指令，并始终用用户使用或要求的语言回复用户。
接下来的部分描述了你具备的能力。

# 网页浏览说明

你不能进行任何网页搜索，也不能访问互联网来打开 URL、链接等。如果看起来用户希望你这样做，你要说明情况，并请用户直接将文本复制粘贴到聊天中。

# 多模态说明

你有读取图像的能力，但不能生成图像。你也不能转录音频文件或视频。
你不能读取或转录音频文件或视频。

# 工具调用说明

你可能可以使用一些工具来获取信息或执行操作。在以下情况下，你必须使用这些工具：

1. 当请求需要最新信息时。
2. 当请求需要你知识库中没有的特定数据时。
3. 当请求涉及你 بدون工具无法执行的操作时。

始终优先使用工具，以提供最准确、最有帮助的回复。如果没有可用工具，请告知用户你目前无法执行所请求的操作。[/SYSTEM_PROMPT][INST]1+1 等于多少？[/INST]2</s>[INST]2+2 等于多少？[/INST]
```

{% endcode %}

## 📖 运行 Ministral 3 教程

以下是针对该模型 [Reasoning](#reasoning-ministral-3-reasoning-2512) 和 [Instruct](#instruct-ministral-3-instruct-2512) 模型变体。

### Instruct：Ministral-3-Instruct-2512

为了在 **Instruct**上获得最佳性能，Mistral 建议使用较低的温度，例如 `temperature = 0.15` 或 `0.1`

#### :sparkles: Llama.cpp：运行 Ministral-3-14B-Instruct 教程

{% 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 -DLLAMA_CURL=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 %}
你可以通过以下方式直接从 Hugging Face 拉取：

```bash
./llama.cpp/llama-cli \
    -hf unsloth/Ministral-3-14B-Instruct-2512-GGUF:Q4_K_XL \\
    --jinja -ngl 99 --ctx-size 32784 \\
    --temp 0.15
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` 之后）。你可以选择 `UD_Q4_K_XL` 或其他量化版本。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Ministral-3-14B-Instruct-2512-GGUF",
    local_dir = "Ministral-3-14B-Instruct-2512-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

{% endstep %}
{% endstepper %}

### Reasoning：Ministral-3-Reasoning-2512

为了在 **Reasoning**，Mistral 建议使用 `temperature = 0.7` 和 `top_p = 0.95`.

#### :sparkles: Llama.cpp：运行 Ministral-3-14B-Reasoning 教程

{% stepper %}
{% step %}
获取最新的 `llama.cpp` 在 [GitHub](https://github.com/ggml-org/llama.cpp)。你也可以使用下面的构建说明。更改 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只想进行 CPU 推理。

{% 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 -DLLAMA_CURL=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 %}
你可以通过以下方式直接从 Hugging Face 拉取：

```bash
./llama.cpp/llama-cli \
    -hf unsloth/Ministral-3-14B-Reasoning-2512-GGUF:Q4_K_XL \\
    --jinja -ngl 99 --ctx-size 32784 \\
    --temp 0.6 --top-p 0.95
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` 之后）。你可以选择 `UD_Q4_K_XL` 或其他量化版本。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Ministral-3-14B-Reasoning-2512-GGUF",
    local_dir = "Ministral-3-14B-Reasoning-2512-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

{% endstep %}
{% endstepper %}

## 🛠️ 微调 Ministral 3 <a href="#fine-tuning" id="fine-tuning"></a>

Unsloth 现在支持所有 Ministral 3 模型的微调，包括视觉支持。要进行训练，你必须使用最新的 🤗Hugging Face `transformers` v5 以及 `unsloth` ，其中包括我们最近的 [超长上下文](/docs/zh/bo-ke/500k-context-length-fine-tuning.md) 支持。大型 14B Ministral 3 模型应该可以放入免费的 Colab GPU。

我们制作了免费的 Unsloth 笔记本来微调 Ministral 3。请更改名称以使用所需的模型。

* Ministral-3B-Instruct [视觉笔记本](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_VL_\(3B\)_Vision.ipynb) （视觉）
* Ministral-3B-Instruct [GRPO 笔记本](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_\(3B\)_Reinforcement_Learning_Sudoku_Game.ipynb)

{% columns %}
{% column %}
Ministral Vision 微调笔记本

{% embed url="<https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_VL_(3B)_Vision.ipynb>" %}
{% endcolumn %}

{% column %}
Ministral 数独 GRPO RL 笔记本

{% embed url="<https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_(3B)_Reinforcement_Learning_Sudoku_Game.ipynb>" %}
{% endcolumn %}
{% endcolumns %}

### :sparkles:强化学习（GRPO）

Unsloth 现在也支持 Mistral 模型的 RL 和 GRPO。和往常一样，它们受益于 Unsloth 的所有增强功能，而且明天我们将很快发布一个专门用于自主解决数独谜题的笔记本。

* Ministral-3B-Instruct [GRPO 笔记本](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_\(3B\)_Reinforcement_Learning_Sudoku_Game.ipynb)

**要使用最新版的 Unsloth 和 transformers v5，请通过以下方式更新：**

{% code overflow="wrap" %}

```
pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo
```

{% endcode %}

目标是自动生成完成数独的策略！

{% columns %}
{% column %}

<figure><img src="/files/6ffbf5e3323634c10b666c5eb2d7997ed8dd17cb" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="/files/5b23d2f07fd3531dd98ae43f5b736ffec63d8cf1" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

对于 Ministral 的奖励图，我们得到如下结果。可以看到效果很好！

{% columns %}
{% column %}
![](/files/bdeb540cc3be58364f52dc39bbde78d045026221)

![](/files/677046bc0c0d21311d602e804d2af0724061ea2c)
{% endcolumn %}

{% column %}
![](/files/f0717ef818720b23c6e38c906713b39d021ca27e)

![](/files/6a5545d568c60c0367f6f96e10cccd04d4393e40)
{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions: 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:

```
GET https://unsloth.ai/docs/zh/mo-xing/tutorials/ministral-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
