> 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/deepseek-v4.1-flash.md).

# DeepSeek-V4.1-Flash：本地运行指南

使用 Unsloth GGUF 和 Engram n-gram 卸载，在本地运行 DeepSeek-V4.1-Flash-1017。

**DeepSeek-V4.1-Flash-1017** 是 V4.1-Flash 的新更新，使其成为 **最强的** 截至目前在代码、智能体任务等方面最强的开源模型。拥有 1M 上下文，其 **552B** 骨干 + **196B Engram** 参数支持 SSD 卸载，以降低 RAM/VRAM 需求。本指南展示如何使用 Unsloth 在本地运行 DeepSeek-V4.1 [Dynamic V3.1](#dynamic-v3.1-update-october-30th-2026) GGUF。

[Unsloth Desktop](/docs/zh/desktop.md) + llama.cpp 可实现约**快 3 倍** 比其他专注于 CPU/VRAM/n-gram 的仓库更快的 DeepSeek-V4.1 推理。DeepSeek 可在 128GB+ RAM 配置上本地运行，或在 64GB RAM 上运行（更慢）。 `UD-Q8_K_XL` （无损）为 **508.4 GB**，而 `UD-Q4_K_XL` （近无损）为 **500.7 GB**。GGUF： [**DeepSeek-V4.1-Flash-1017-GGUF**](https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF)

<a href="/pages/186a58039c49acb85318ef9708c070fd5a5e2a45#run-deepseek-v4.1-flash-1017-tutorials" class="button primary">运行 DeepSeek-V4.1 教程</a>

### Dynamic V3.1 更新（2026 年 10 月 30 日）

我们正在发布新的 DeepSeek-V4.1-Flash-1017 GGUF，它们使用我们新的 [**Unsloth Dynamic**](/docs/zh/ji-chu-zhi-shi/dynamic-3.0-ggufs.md) **V3.1（预览）算法** 该算法改进了 Unsloth 量化在几乎所有基准上的表现，并且相较其他提供方属于同类最佳。

我们在 UDv3 和 UD3.1 的所有量化上跑了 AIME25、Aider Polyglot、LiveCodeBench v6、HMMT 2026、GPQA Diamond、MMLU-Pro、IFEval 等，并与声称在 AIME25 上所有量化都能恢复到 100% 的 GSQ-RCO 变体进行了对比，但我们无法复现这些数字。

我们提供 6 个基准的完整平均值（不包括 Aider Polyglot——如果把 Aider 算进去，差异会更明显），并展示 UD3.1 在几乎所有任务上都表现出色。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FOuLKE4mwn1xkCJchptDN%2Ftotal_ista.png?alt=media&amp;token=cdc15dba-6b30-4ca3-8318-94138acf6d27" alt=""><figcaption></figcaption></figure>

#### 我们无法复现 GSQ-RCO 的结果

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FgEHmQB9WBKLJ1vMssB6N%2Fclaims_ista.png?alt=media&amp;token=838ee657-1085-4c00-bcdb-66abbe2862c1" alt=""><figcaption></figcaption></figure>

由 ISTA-DASLab 制作的 GSQ-RCO DeepSeek-V4.1-Flash-1017 量化声称在所有量化上 AIME25 得分为 100%——我们无法复现这一点，并在 AIME25 上通过多次运行并取平均展示， **GSQ-RCO 保留了基线的 94.64%（不是 100%）**。我们还在第二张图中对所有基线数值进行了缩放，以考虑方法差异。

<div><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FMFdsiPUHkPAXMYPblKDx%2Fgsq_rco_claims_vs_true_bars(1).png?alt=media&amp;token=99b6f559-52fe-481f-911a-92b559cfd01f" alt=""><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FDHa3imd8XoDXehkvATcC%2Fgsq_rco_claims_vs_true_bars_recovery.png?alt=media&amp;token=244b229c-1b23-47e3-bfa5-d0b9631f426b" alt=""><figcaption></figcaption></figure></div>

就 AIME25 而言，ISTA 报告称 3 种量化均为 100% 准确率；然而当我们对每个量化在 AIME25 上按每题测试 16 次：30 道题 \* 16 个样本 = 每个量化 480 个答案，温度 1.0、推理努力 50 时，我们看到量化表现明显下降，而且在所有比特宽度上都不是 100% 准确率。&#x20;

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FtcF0k9ss042lXLgvDyIt%2Faime25.png?alt=media&amp;token=8025e417-e669-43cb-bf8f-ce69a9254aca" alt="" width="375"><figcaption></figcaption></figure>

GSQ-RCO 基准同样使用推理努力 50，并且按照 README.md

#### KLD 是一个合理的指标

最近有一些说法认为 KLD 不是一个好的指标。KL 散度（KLD）衡量量化模型在同一文本上对下一个 token 的预测，与参考模型的预测相比偏离了多远。

$$
\text{min  } D\_{KL} \large( \theta, \hat{\theta}\large)
$$

**量化的主要目标是将 KLD 降到 0，同时还要减小量化模型的磁盘占用** （你也可以纳入其他优化项，例如生成速度）。

如果 KLD 为 0，那么模型就完美重建了输出 logits，因此量化模型会与原始模型生成 100% 相同的输出。

你可以清楚地看到 GSQ-RCO 的 KLD 更高、top-1% 一致性更低，甚至比我们旧的 Unsloth v3 量化还差——v3.1 进一步改进了这一点。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F0YkDIvosvnP6nRVlhNy5%2FKLD%20ISTA.png?alt=media&amp;token=a4601232-2858-4b8d-a618-8991a48eeb6d" alt=""><figcaption></figcaption></figure>

有人说 KLD 可以通过作弊“刷分”或“benchmaxed”，比如在测试集上计算 KLD，或者只用一个数据集来跑 KLD。为验证这一理论，我们在多个留出测试上进行了实验，并展示 UDv3.1 在所有方面都优于 GSQ-RCO。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FBBJeFPqCiW0Al9IvGNsC%2Fsize_vs_kld_per_axis(2).png?alt=media&amp;token=08452280-2005-4fa9-bdc7-a37f162b49e7" alt=""><figcaption></figcaption></figure>

我们也提供了所有留出测试的 top-1% 一致性：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FcCroCNVfybzFZ7lAMHVy%2Fsize_vs_top1_per_axis(2).png?alt=media&amp;token=a7f50164-e15c-45ef-911b-e73882436845" alt=""><figcaption></figcaption></figure>

#### 量化会增加推理长度

我们还测试了较低比特的量化是否会思考更久——我们把所有测试的上下文长度设为 32K，如果量化思考过久就判定失败。我们也在最高 128K token 上运行了 Livecodebench，结果类似。我们提供了所有 6 个基准中被截断的答案数量，并表明 Unsloth 量化的截断明显少于 GSQ 的量化（因此我们认为它们思考得更少）。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FEKPO459yFA9vQwKohCR0%2Ftruncation.png?alt=media&amp;token=e8ddafad-7f4e-4891-a329-511ffd177365" alt=""><figcaption></figcaption></figure>

不过这确实表明量化会增加思考/推理长度，因此对于较小比特的量化，请准备更高的推理预算。

#### 用于基准测试的 Engram 移除

我们还移除了用于绘图的 engram，但这不会改变任何结果，因为所有低比特量化都使用 IQ4\_NL 作为 engram——Q2\_K\_XL 和 IQ2\_XXS 使用 Q5\_K。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fzggh3ij4y2HInPA0LU80%2Fremove%20engram.png?alt=media&amp;token=5900687a-ad79-4d69-8650-318fa3a17d61" alt=""><figcaption></figcaption></figure>

#### 完整基准结果

| 量化                 | 大小 GB | AIME25 | HMMT 2026 年 2 月 | GPQA-D | MMLU-Pro | IFEval | LCB v6（32K） | 6 项平均 | Aider pass\@1 | 截断 %（6） |
| ------------------ | ----: | -----: | --------------: | -----: | -------: | -----: | ----------: | ----: | ------------: | ------: |
| UD-Q8\_K\_XL（参考）   | 508.4 |  97.08 |           68.94 |  90.47 |    88.61 |  95.10 |       85.90 | 87.68 |             - |    1.48 |
| UD-Q2\_K\_XL（v3.1） | 334.8 |  97.50 |           69.89 |  89.58 |    88.28 |  94.92 |       84.76 | 87.49 |             - |    2.10 |
| UD-IQ2\_XXS（v3.1）  | 300.5 |  96.88 |           67.61 |  88.95 |    87.53 |  95.19 |       83.62 | 86.63 |         44.38 |    2.71 |
| UD-IQ1\_M（v3.1）    | 250.4 |  95.00 |           62.88 |  88.38 |    87.53 |  95.10 |       84.38 | 85.55 |         42.13 |    2.91 |
| UD-IQ1\_S（v3.1）    | 233.0 |  92.92 |           57.01 |  87.63 |    86.62 |  94.92 |       82.10 | 83.53 |         36.52 |    4.15 |
| GSQ-RCO IQ2\_XS    | 265.8 |  95.00 |           64.39 |  88.64 |    86.62 |  94.27 |       84.95 | 85.64 |         41.57 |    2.83 |
| GSQ-RCO IQ2\_XXS   | 248.8 |  95.21 |           57.95 |  85.80 |    86.53 |  93.72 |       82.86 | 83.68 |         36.52 |    4.00 |
| GSQ-RCO IQ1\_M     | 231.3 |  91.88 |           53.60 |  85.10 |    85.49 |  91.77 |       82.86 | 81.78 |         29.78 |    4.69 |

#### 完整基准测试方法

| 基准              | 来源（修订版）                                    |    条目 |           样本 / 条目 |    最大 token | 种子基准                | 提示词                               | 评分器                                               |
| --------------- | ------------------------------------------ | ----: | ----------------: | ----------: | ------------------- | --------------------------------- | ------------------------------------------------- |
| AIME25          | MathArena/aime\_2025（c94da77e）             |    30 |                16 |      32,768 | 20261029            | 题目 + "请逐步推理，并将最终答案写在 \boxed{} 中。" | 对最后一个 \boxed{} 进行 math\_verify，回退为精确整数            |
| HMMT 2026 年 2 月 | MathArena/hmmt\_feb\_2026                  |    33 |                16 |      32,768 | 20261029            | 与 AIME25 相同                       | math\_verify                                      |
| GPQA-D          | Idavidrein/gpqa diamond（633f5ee8）          |   198 | 8（4 + 4；较早的上传为 4） |      32,768 | 20261026 + 20261029 | OpenAI simple-evals 选择题模板         | 最后的“Answer: X”，回退为 \boxed{X}、“answer is (X)”、单独字母 |
| MMLU-Pro        | 1,203 条分层子集                                | 1,203 |                 2 |      32,768 | 20261029            | simple-evals 风格，最多 10 个选项         | 最后的“Answer: X”                                    |
| IFEval          | google/IFEval                              |   541 |                 2 |      32,768 | 20261029            | 原始提示词                             | 官方 instruction\_following\_eval，严格，提示词级别          |
| LCB v6（32K）     | livecodebench/code\_generation\_lite test6 |   175 |                 3 |      32,768 | 20261026            | 官方 LCB 系统 + 用户提示词                 | 官方 extract\_code + run\_test，每个测试 6 秒，沙盒化子进程      |
| 6 项平均           | 以上所有基准                                     |       |                   |             |                     |                                   | 9 个 pass\@1 值的平均值                                 |
| Aider pass\@1   | Aider Polyglot                             |   225 |             1 次试验 | 每次回复 32,768 | 不适用                 | Docker 中的官方 aider 基准              | 练习的单元测试                                           |
| 截断 %（6）         | 这 6 个基准                                    |       |                   |      32,768 |                     |                                   | 在 token 上限处结束的答案占比                                |

### ⚙️ 使用指南

**DeepSeek-V4.1-Flash-1017** 将 MoE 与 **Engram 条件记忆**相结合：最多四个 token 的 n-gram 每个 token 只访问表中的少数几行，因此表无需一直驻留在 GPU 内存中。推理时最好使用 Unsloth，因为它最多可实现 **快 3 倍** 通过在 llama.cpp 之上进行优化，使 DeepSeek-V4.1 的推理速度比其他专注于 CPU/VRAM/n-gram 的仓库更快。

1 位 `UD-IQ1_S` 可在 128GB RAM 的设备上运行，如 Macbook、DGX Spark 或 RTX Spark；而 3 位 `UD-IQ3_XXS` 可在 256GB RAM 的设备上运行，如 Mac Studio。

就像我们 [Qwen3.8-Flash-Next](/docs/zh/mo-xing/qwen3.8-next.md) 指南中的 PLE / n-gram 层一样，Engram 的 110.6–202.8 GB 表可以通过 mmap 保持在 SSD 上。各行按需加载到操作系统缓存中，在保留完整磁盘需求的同时节省 RAM/VRAM。

#### **DeepSeek-V4.1-Flash-1017 需求：**

**表：硬件需求** （RAM + VRAM，或统一内存；Engram 在 SSD 上）。

| 1 位        | 2 位        | 3 位        | 4 位    | 8 位    |
| ---------- | ---------- | ---------- | ------ | ------ |
| 128–145 GB | 176–205 GB | 256–290 GB | 305 GB | 315 GB |

估算值大致比非 Engram 权重多 5–10 GB。运行时和上下文可能需要更多。

**n-gram 存储：** 下面显示查找格式和权重大小。Rest GB 是所需 RAM/VRAM 的绝对最小值。

| 量化           | N-gram 格式 / GB  | Rest GB |
| ------------ | --------------- | ------- |
| UD-IQ1\_S    | IQ4\_NL / 110.6 | 122.4   |
| UD-IQ1\_M    | IQ4\_NL / 110.6 | 139.8   |
| UD-IQ2\_XXS  | Q5\_K / 135.2   | 165.3   |
| UD-Q2\_K\_XL | Q5\_K / 135.2   | 199.6   |
| UD-IQ3\_XXS  | Q6\_K / 161.3   | 233.5   |
| UD-IQ3\_S    | Q6\_K / 161.3   | 262.3   |
| UD-Q3\_K\_XL | MXFP8 / 202.8   | 282.3   |
| UD-Q4\_K\_XL | MXFP8 / 202.8   | 297.9   |
| UD-Q8\_K\_XL | MXFP8 / 202.8   | 305.6   |

### 推荐设置

DeepSeek 推荐 temperature = 1.0、top-p = 1.0，并禁用 top-k 和 min-p：

| 参数            | 设置                |
| ------------- | ----------------- |
| `temperature` | `1.0`             |
| `top_p`       | `1.0`             |
| 最大上下文窗口       | `1,048,576` token |

DeepSeek 建议允许 **至少 256K 输出 token** 用于其长生成设置。

### 📊 量化分析

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FZbUjhpI7wJTjf3pM1uwu%2Fsize_vs_top1(1).png?alt=media&amp;token=4e133008-8026-4e93-baa7-d7f2e2b81ecc" alt=""><figcaption></figcaption></figure>

结果与 DeepSeek 在 wiki1100 和 long17k 上的官方参考进行比较。更低的 KL 表示更接近的下一个 token 概率；更高的 top-1 表示更多匹配的预测。

DeepSeek 混合使用 **MXFP4**、FP8 和 BF16。Q4 和 Q8 保留 **MXFP4** 专家和同一张 Engram 表；它们的标签并不描述每个张量的精度。Q4 将许多非专家权重存储为 Q8\_0；Q8 使用 BF16。

我们还展示了当我们将 engram 精度从 IQ4\_NL 更改为 Q5\_K、Q6\_K 和 MXFP8 时会发生什么，并提供 **独立的 engram，允许你自由混搭。**

| 量化           | 总大小      | wiki1100 KL / top-1 | long17k KL / top-1 |
| ------------ | -------- | ------------------- | ------------------ |
| UD-IQ1\_S    | 233.0 GB | 0.457 / 82.8%       | 0.364 / 85.1%      |
| UD-IQ1\_M    | 250.4 GB | 0.314 / 87.1%       | 0.241 / 88.2%      |
| UD-IQ2\_XXS  | 300.5 GB | 0.203 / 90.5%       | 0.142 / 91.2%      |
| UD-Q2\_K\_XL | 334.8 GB | 0.138 / 91.5%       | 0.0879 / 93.3%     |
| UD-IQ3\_XXS  | 394.7 GB | 0.0625 / 94.6%      | 0.043 / 95.1%      |
| UD-IQ3\_S    | 423.6 GB | 0.0316 / 96.0%      | 0.0195 / 96.8%     |
| UD-Q3\_K\_XL | 485.1 GB | 0.0204 / 96.5%      | 0.0114 / 97.4%     |
| UD-Q4\_K\_XL | 500.7 GB | 9.00e-03 / 98.2%    | 4.46e-03 / 98.5%   |
| UD-Q8\_K\_XL | 508.4 GB | 4.76e-03 / 98.5%    | 2.81e-03 / 98.7%   |

**选择一个量化：** IQ1\_S 相比 Q8 约可节省 54% 的磁盘空间。IQ1\_M 额外增加 17.4 GB，并将 wiki1100 上的 top-1 一致性提高 4.3 个百分点，在 long17k 上提高 3.1 个百分点。IQ3 变体达到 94.6–96.8% 的一致性。

#### **思考努力**

默认已启用思考， `reasoning_effort=75` （“high”）。你可以设置一个整数，范围为 **1 到 100**。数值越高，模型会被要求更彻底地推理；它们不是 token 限制。随附模板还接受 `low` = 50, `medium` = 62, `high` = 75 和 `max` = 100.

例如，将以下选项之一添加到启动命令中：

```bash
# 默认思考努力
--chat-template-kwargs '{"reasoning_effort":75}'

# 最大思考努力
--chat-template-kwargs '{"reasoning_effort":100}'

# 禁用思考
--chat-template-kwargs '{"enable_thinking":false}'
```

## 运行 **DeepSeek-V4.1-Flash-1017** 教程：

在本教程中，我们使用 `UD-Q2_K_XL`。Unsloth 会自动选择近乎最优的 DeepSeek-V4.1 卸载、n-gram 等配置，确保你的设置获得尽可能接近最佳的速度。

### 🦥 Unsloth 指南

[Unsloth Desktop](https://unsloth.ai/docs/desktop) 是我们面向 macOS、Windows 和 Linux 的本地 AI 开源界面。你可以从一个应用中搜索并下载 GGUF，配置 CPU 和 GPU 卸载，调整推理设置并连接工具。

{% stepper %}
{% step %}

#### 安装 Unsloth

最简单的入门方式是下载 [Unsloth 桌面应用](/docs/zh/desktop.md)。可运行于 [macOS](/docs/zh/kuai-su-kai-shi/install/mac.md), [Windows](/docs/zh/kuai-su-kai-shi/install/windows-installation.md)，以及 [Linux](/docs/zh/kuai-su-kai-shi/install/linux.md).

<a href="https://unsloth.ai/download" class="button primary" data-icon="down-to-bracket">下载 Unsloth</a>

* <i class="fa-apple">:apple:</i> [下载适用于 macOS](https://unsloth.ai/download/mac)
* <i class="fa-windows">:windows:</i> [下载适用于 Windows](https://unsloth.ai/download/windows)
* <i class="fa-linux">:linux:</i> [下载适用于 Linux](https://unsloth.ai/download/linux)

或者，如果你更喜欢手动安装：
{% endstep %}

{% step %}

#### 搜索并下载 DeepSeek-V4.1-Flash-1017

前往 [Unsloth Chat](/docs/zh/xin/studio/chat.md) 或 Model hub，搜索 **DeepSeek-V4.1-Flash-1017** 并选择 [unsloth/DeepSeek-V4.1-Flash-1017-GGUF](https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF)。使用上方列出的大小和内存要求下载你想要的量化版本。
{% endstep %}

{% step %}

#### 运行 DeepSeek-V4.1-Flash-1017

默认启用思考模式，使用 `75`，你可以在我们的切换开关中更改它。Unsloth 会自动选择接近最优的 DeepSeek-V4.1 卸载、ngram 等配置，确保你的设置获得尽可能接近最佳的速度。

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

使用 UD-IQ1\_S 时，233.0 GB 的下载包含一个 110.6 GB 的 Engram n-gram 表和 122.4 GB 的其他权重。使用 Engram 按需加载可将查找表保留在 SSD 上，并为缓存行、上下文和运行时缓冲区提供额外的 RAM/VRAM。有关内存要求，请参阅上方的使用指南。
{% endstep %}

{% step %}

#### 通过 Unsloth API 提供 DeepSeek-V4.1-Flash-1017 服务

你可以使用 `unsloth run` 命令，并通过以下方式使用 API 提供 DeepSeek-V4.1-Flash-1017 服务 `llama-server` 运行时标志，包括上下文大小、GPU 层、线程、采样、网络和工具配置。更多信息请查看我们的 [API 文档](/docs/zh/ji-chu-zhi-shi/api.md) 或 [unsloth start](/docs/zh/ji-cheng/unsloth-start.md).

{% code overflow="wrap" %}

```bash
unsloth run --model unsloth/DeepSeek-V4.1-Flash-1017-GGUF:UD-Q2_K_XL \\
    --temp 1.0 \\
    --top-p 1.0 \\
    --min-p 0.0 \\
    --chat-template-kwargs '{"reasoning_effort":75}'
```

{% endcode %}

使用支持 DeepSeek-V4.1-1017 和 Engram 按需加载的运行时。将 n-gram 表保留在磁盘上时，请应用《使用指南》中的 SSD 卸载和内存设置。
{% endstep %}

{% step %}

#### Unsloth 现在已准备就绪

你可以通过 Unsloth Desktop 将 DeepSeek-V4.1-Flash-1017 连接到你的工具。Unsloth 还支持以下工作流：

* **连接工具：** [Claude Code](/docs/zh/ji-chu-zhi-shi/claude-code.md), [Codex](/docs/zh/ji-chu-zhi-shi/codex.md), [网页搜索](/docs/zh/xin/studio/chat.md#advanced-web-search), [MCP](/docs/zh/ji-chu-zhi-shi/mcp.md) 等等
* **训练模型：** 微调其他受支持的文本、扩散、 [嵌入](/docs/zh/ji-chu-zhi-shi/embedding-finetuning.md)，等等
* **生成媒体：** 创建并训练 [图像](/docs/zh/ji-chu-zhi-shi/diffusion-image.md)、视频、 [TTS](/docs/zh/ji-chu-zhi-shi/text-to-speech-tts-fine-tuning.md) 在本地

<div align="center"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FYShiiub5gs5pCQLX6d4U%2FScreenshot%202026-08-15%20at%2012.18.24%E2%80%AFAM.png?alt=media&amp;token=d6996797-a144-4113-b4c3-155cca6c39a0" alt="Unsloth Desktop Agents settings interface example" width="563"><figcaption><p>Unsloth Desktop 的 Agents 设置（界面示例）。连接工具时，选择 DeepSeek-V4.1-Flash-1017 和你下载的量化版本。</p></figcaption></figure></div>
{% endstep %}
{% endstepper %}

### 🦙 在 llama.cpp 中运行 DeepSeek-V4.1-Flash

{% stepper %}
{% step %}
我们需要使用我们特定的 llama.cpp PR [这里](https://github.com/ggml-org/llama.cpp/pull/30817)。你也可以按照下面的构建说明进行操作。将 `-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 git -y
git clone https://github.com/ggml-org/llama.cpp
git -C llama.cpp fetch origin pull/30817/head:deepseek41
git -C llama.cpp checkout deepseek41
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
```

{% endstep %}

{% step %}
要运行模型，你可以这样做：

```bash
pip install -U "huggingface_hub[cli]"
hf download unsloth/DeepSeek-V4.1-Flash-1017-GGUF \\
    --local-dir unsloth/DeepSeek-V4.1-Flash-1017-GGUF \\
    --include "*UD-Q2_K_XL*"
```

将全部 7 个分片保存在同一文件夹中，并将 `--model` 指向第一个分片。llama.cpp 会自动加载其余分片。
{% endstep %}

{% step %}
然后运行它：

```bash
./llama.cpp/llama-cli \\
    --model unsloth/DeepSeek-V4.1-Flash-1017-GGUF/UD-Q2_K_XL/DeepSeek-V4.1-Flash-1017-UD-Q2_K_XL-00001-of-00007.gguf \\
    --temp 1.0 \\
    --top-p 1.0 \\
    --top-k 0 \\
    --min-p 0.0 \\
    --chat-template-kwargs '{"reasoning_effort":75}' \\
    --load-mode mmap \\
    --lazy-mode on \\
    --override-tensor "per_layer_token_embd.weight=CPU"
```

此示例按需从 SSD 加载 Engram n-gram 表。保持 `--load-mode mmap` 和 `--lazy-mode on` 启用，以便进行 SSD 卸载。
{% endstep %}
{% endstepper %}

### ⚡**DSpark** - 推测解码

DeepSeek-V4.1 包含 **DSpark**，这是一种在主模型验证之前先提出多个 token 的推测解码架构。它与 Engram n-gram 查找表是分开的： **Engram 提供学习到的记忆；DSpark 加速解码**。同样名字的 n-gram 推测解码选项也是另一个不同的特性。

对于 DSpark，请将主模型与匹配的 **V4.1-1017 drafter** 以及带有 DSpark 支持的运行时配对使用。保持 drafter 和主检查点版本一致，并为 drafter 预留额外内存。本指南中的 CLI 和服务器示例使用的是普通解码。

**DSpark 使 DeepSeek-V4.1-Flash-GGUF 的推理解码速度大约提升 1.3 到 1.5 倍！**

我们提供一个 8GB 的 Q8\_0 DSpark 模块，以及一个 8.5GB 的完整 BF16 版本。

### :checkered\_flag:混合搭配 engram

你也可以将 DeepSeek-V4.1 的 engram 精度更改为你想要的任何值。

| Engram 精度 | 大小（GB）   |
| --------- | -------- |
| MXFP8（原始） | 202.8 GB |
| Q6\_K     | 161.3 GB |
| Q5\_K     | 135.2 GB |
| IQ4\_NL   | 110.6 GB |

例如，在下载默认使用 IQ4\_NL engram 的动态 1 位量化 IQ1\_S 后，你可以只下载位于以下位置的 MXFP8 engram，将其替换为 MXFP8 版本 <https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF/tree/main/engram> 称为 `DeepSeek-V4.1-Flash-1017-engram-MXFP8.gguf_file` 要执行此操作，请按以下脚本进行：

```bash
# 1. 获取表 + 脚本
hf download unsloth/DeepSeek-V4.1-Flash-1017-GGUF \\
  --include "engram/*MXFP8*" "engram/set_split.py" --local-dir .

# 2. 将其标记为 5 个分片中的第 5 个（UD-IQ1_S 的表槽）
python engram/set_split.py engram/DeepSeek-V4.1-Flash-1017-engram-MXFP8.gguf_file 5 5

# 3. 先保留旧表，然后将新表重命名为该表分片的名称
mv UD-IQ1_S/DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00005-of-00005.gguf UD-IQ1_S/engram-IQ4_NL.bak
mv engram/DeepSeek-V4.1-Flash-1017-engram-MXFP8.gguf_file \\
   UD-IQ1_S/DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00005-of-00005.gguf

# 4. 像平常一样运行
llama-server -m UD-IQ1_S/DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00001-of-00005.gguf
```

## 📊 基准测试

### **GGUF KLD 和 Top-1% 基准测试**

我们的量化在 wiki1100 上相较官方 F32 参考的 top-1 一致性为 82.8–98.5%，在 long17k 上为 85.1–98.7%。与 UD-Q8\_K\_XL 相比，UD-Q4\_K\_XL 可节省 7.7 GB，在 wiki1100 上一致性差距为 0.3 个百分点，在 long17k 上为 0.2 个百分点。Q8 在这两个集合上的 KL 散度也更低。

**我们还将 engram 表精度从 IQ4\_NL 改为 Q5\_K、Q6\_K 和 MXFP8，并展示 KLD 如何受到影响**

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FdIFvyiUQafZ2upn6VdhJ%2Fsize_vs_kld(1).png?alt=media&amp;token=e5d14eab-9143-4d0a-b1a6-f5427d995808" alt=""><figcaption></figcaption></figure>

### **官方基准**

DeepSeek 报告了以下 **V4.1-Flash-1017** 与之前的 V4.1-Flash 版本相比的结果。这些是官方模型结果，不是本指南中 GGUF 的测量值。来源： [DeepSeek 的 1017 模型卡](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017).

| 基准                   | V4.1-Flash-1017 | V4.1-Flash  |
| -------------------- | --------------- | ----------- |
| 不使用工具的 HLE           | 42.6（44.0†）     | 36.8（39.1†） |
| Terminal-Bench 4.0   | 42.3            | 31.2        |
| DeepSWE v1.1         | 77.0            | 74.2        |
| 程序基准                 | 29.1            | 20.3        |
| 自然语言到仓库基准            | 68.2            | 65.4        |
| 自动化基准 v1.0.6         | 60.5            | 54.8        |
| 智能体的最后考试             | 35.4            | 31.8        |
| Apex 基准 v1.1         | 72.1            | 64.6        |
| Chartography（使用工具）   | 83.0            | 78.9        |
| BabyVision（使用工具）     | 92.5            | 89.6        |
| ZeroBench-main（使用工具） | 51.0            | 49.0        |

† HLE 的纯文本子集。DeepSeek 在 Terminal-Bench 4.0 中使用 Claude Code harness，在 DeepSWE v1.1 中使用 Mini-SWE-V2。分数取决于评估设置、推理投入和上下文预算。


---

# 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/deepseek-v4.1-flash.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.
