> 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/ministral-3.md).

# Ministral 3 - 运行指南

Mistral 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="/docs/zh/mo-xing/tutorials/ministral-3.md#fine-tuning" class="button primary">微调 Ministral 3</a>

我们还上传了 Mistral Large 3 [这里的 GGUFs](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) |

### ⚙️ 使用指南

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

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

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

**足够的输出长度**：对大多数查询，思考版使用输出长度 `32,768` 个 token 适用于推理变体的大多数查询，且 `16,384` 适用于指令变体。如有必要，你可以增加推理模型的最大输出大小。

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

当我们使用以下内容时，可得到聊天模板格式：

{% code overflow="wrap" %}

```python
tokenizer.apply_chat_template([
    {"role" : "user", "content" : "1+1 等于多少？"},
    {"role" : "assistant", "content" : "2"},
    {"role" : "user", "content" : "1+1 等于多少？"}
    ], add_generation_prompt = True
)
```

{% endcode %}

#### Ministral *推理* 聊天模板：

{% 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 *指令* 聊天模板：

{% 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-ministral-3-reasoning-2512) 和 [指令](#instruct-ministral-3-instruct-2512) 模型的变体。

### Instruct: Ministral-3-Instruct-2512

为了在 **指令**上获得最佳性能，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

为了在 **推理**，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 视觉微调笔记本

{% 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="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F2qDbhHfpuhNAHOtIernm%2Fimage.png?alt=media&amp;token=9a3d4bb2-3994-4ec8-aeb8-16bc2bcb77c4" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FLZlHHeAjoVAeO6juQDiC%2Fimage.png?alt=media&amp;token=45abbb30-b705-4eec-81fc-fb99dd0c2621" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

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

{% columns %}
{% column %}
![](https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FqpfPNKkSF2O1T0flshEi%2Funknown.png?alt=media\&token=a2f14139-bcab-40bf-a054-f189de5d23df)

![](https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fe8TBzOVVn5iYhlJ6nh63%2Funknown.png?alt=media\&token=520699f9-ffd0-43a5-a0ef-263fa678b4bd)
{% endcolumn %}

{% column %}
![](https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FudSxKSBuSOIXONrtarmp%2Funknown.png?alt=media\&token=beefcbce-67df-4ce2-92b8-3e0adc240df6)

![](https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FgwwlcVjMt9nqyqVC6xqD%2Funknown.png?alt=media\&token=b5b390b6-c9e6-4926-9a70-d4aa365caa86)
{% endcolumn %}
{% endcolumns %}


---

# 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/tutorials/ministral-3.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.
