# Ministral 3 - 运行指南

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

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

<a href="#run-ministral-3-tutorials" class="button primary">运行 Ministral 3 教程</a><a href="#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) |

### ⚙️ 使用指南

为了在 **指令（Instruct）**&#x4E0A;实现最佳性能，Mistral 建议使用较低的温度，例如 `temperature = 0.15` 或 `0.1`<br>

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

| 指令式：                | 推理：            |
| ------------------- | -------------- |
| `温度 = 0.15` 或 `0.1` | `温度 = 0.7`     |
| `Top_P = 默认`        | `Top_P = 0.95` |

**适当的输出长度**: 对于大多数查询，思考变体请使用输出长度为 `32,768` 标记用于大多数推理变体的查询，以及 `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 *推理* 聊天 模板：

{% 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）。
你为一个名为 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）](#instruct-ministral-3-instruct-2512) 模型的变体。

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

为了在 **指令（Instruct）**&#x4E0A;实现最佳性能，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 32684 \
    --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 32684 \
    --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` 其中包含我们最近的 [超长上下文](https://unsloth.ai/docs/zh/bo-ke/500k-context-length-fine-tuning) 支持。大型 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 强化学习 笔记本

{% 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 模型的强化学习和 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&#x26;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&#x26;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: 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.
