> 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/jp/moderu/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 の必要量を削減します。このガイドでは、DeepSeek-V4.1 をローカルで実行する方法を [Unsloth Dynamic](/docs/jp/ji-chu/dynamic-3.0-ggufs.md) GGUF

Unsloth + llama.cpp により、約**3倍高速な** DeepSeek-V4.1 推論を、他の CPU/VRAM/ngram 系リポジトリよりも実現できます。私たちの **250.4 GB** 1ビット `UD-IQ1_M` 量子化は達成します **88.2% の top-1 一致率** 元の DeepSeek に対して、128GB+ 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/7ddff7964c918a6bb834c6963979e70a01021c2a#run-deepseek-v4.1-flash-1017-tutorials" class="button primary">DeepSeek-V4.1 のチュートリアルを実行</a><a href="/docs/jp/moderu/deepseek-v4.1-flash.md#quantization-analysis" class="button secondary">量子化分析</a>

### ⚙️ 使用ガイド

**DeepSeek-V4.1-Flash-1017** は MoE と **Engram の条件付きメモリを組み合わせたもので**: 最大 4 トークンまでの n-gram は、トークンごとに少数のテーブル行にアクセスするため、テーブルを GPU メモリに常駐させる必要はありません。推論には Unsloth の使用が最適です。最大で **3倍高速な** llama.cpp の上に最適化を重ねることで、他の CPU/VRAM/ngram 特化リポジトリよりも高速な DeepSeek-V4.1 推論を実現します。

1ビット `UD-IQ1_S` は、MacBook、DGX Spark、RTX Spark のような 128GB RAM 構成でも動作し、3ビット `UD-IQ3_XXS` は、Mac Studio のような 256GB RAM 構成でも動作します。

私たちの [Qwen3.8-Flash-Next](/docs/jp/moderu/qwen3.8-next.md) ガイドと同様に、Engram の 110.6–202.8 GB のテーブルは mmap により SSD 上に置いたままにできます。行は必要に応じて OS キャッシュに読み込まれ、ディスク要件全体は維持したまま RAM/VRAM を節約できます。

#### **DeepSeek-V4.1-Flash-1017 の要件:**

**表: ハードウェア要件** （RAM + VRAM、または統合メモリ；SSD 上の Engram）。

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

見積もりは、Engram 以外の重みよりおよそ 5〜10 GB 余裕を見ています。実行時とコンテキストにはさらに必要になる場合があります。

**n-gram ストレージ:** ルックアップ形式と重みサイズを以下に示します。残りの GB は、必要な RAM/VRAM の絶対最小量です。

| 量子化          | n-gram 形式 / GB  | 残り 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` トークン |

DeepSeek は **少なくとも 256K の出力トークン** を許可することを推奨しています。

### 📊 量子化分析

<figure><img src="https://735611837-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>

結果は、wiki1100 と long17k における DeepSeek の公式参照と比較しています。KL が低いほど次トークン確率が近く、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` （「高」）になっています。 **1 から 100**までの整数を設定できます。値を高くすると、モデルはより徹底的に推論するようになります。これはトークン上限ではありません。含まれているテンプレートは `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 のオフロード、ngram などのほぼ最適な構成を自動で選択し、セットアップが可能な限り近い最良速度になるようにします。

### 🦥 Unsloth ガイド

[Unsloth Desktop](https://unsloth.ai/docs/desktop) は、macOS、Windows、Linux 向けのローカル AI 用オープンソース UI です。GGUF の検索・ダウンロード、CPU/GPU オフロード設定、推論設定の調整、ツール接続を 1 つのアプリで行えます。

{% stepper %}
{% step %}

#### Unsloth をインストール

始める最も簡単な方法は、 [Unsloth Desktop アプリ](/docs/jp/desktop.md)をダウンロードすることです。対応環境は [macOS](/docs/jp/meru/install/mac.md), [Windows](/docs/jp/meru/install/windows-installation.md)、および [Linux](/docs/jp/meru/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)

または、手動でインストールしたい場合は:

{% tabs %}
{% tab title="ネイティブインストール" %}
**MacOS、Linux、WSL:**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

**Windows:**

```powershell
irm https://unsloth.ai/install.ps1 | iex
```

{% endtab %}

{% tab title="Docker" %}
その [UnslothのDockerイメージ](https://hub.docker.com/r/unsloth/unsloth) `unsloth/unsloth` Dockerで利用できます。 [ガイドを読む。](https://unsloth.ai/docs/get-started/install/docker)
{% endtab %}

{% tab title="Homebrew" %}
Unsloth Desktopをインストール:

{% code collapsedlinecount="10" %}

```bash
brew install --cask unsloth
```

{% endcode %}

Unsloth Desktopを更新:

```bash
brew upgrade --cask unsloth
```

{% endtab %}

{% tab title="WinGet" %}
Unsloth Desktopをインストール:

```powershell
winget install --id UnslothAI.Unsloth -e
```

Unsloth Desktopを更新:

```powershell
winget upgrade --id UnslothAI.Unsloth -e
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### DeepSeek-V4.1-Flash-1017 を検索してダウンロード

へ移動 [Unsloth Chat](/docs/jp/shii/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/jp/shii/studio/chat.md).

を参照してください。UD-IQ1\_S では、233.0 GB のダウンロードに 110.6 GB の Engram n-gram テーブルと 122.4 GB のその他の重みが含まれます。ルックアップテーブルを SSD に保持するために Engram のオンデマンド読み込みを使用し、キャッシュされた行、コンテキスト、実行時バッファ用に追加の RAM/VRAM を確保してください。メモリ要件については上記の使用ガイドに従ってください。
{% endstep %}

{% step %}

#### Unsloth API で DeepSeek-V4.1-Flash-1017 を提供する

を使用できます `unsloth run` コマンドを使って、 `llama-server` のランタイムフラグを使用して API 経由で DeepSeek-V4.1-Flash-1017 を提供できます。これには、コンテキストサイズ、GPU レイヤー、スレッド、サンプリング、ネットワーク、ツール設定が含まれます。詳細は [API ドキュメント](/docs/jp/ji-chu/api.md) または [unsloth start](/docs/jp/tong-he/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/jp/ji-chu/claude-code.md), [Codex](/docs/jp/ji-chu/codex.md), [ウェブ検索](/docs/jp/shii/studio/chat.md#advanced-web-search), [MCP](/docs/jp/ji-chu/mcp.md) など
* **モデルを学習:** 対応する他のテキスト、拡散、 [埋め込み](/docs/jp/ji-chu/embedding-finetuning.md)などをファインチューニング
* **メディアを生成:** 作成・学習 [画像](/docs/jp/ji-chu/diffusion-image.md)、動画、 [TTS](/docs/jp/ji-chu/text-to-speech-tts-fine-tuning.md) をローカルで

<div align="center"><figure><img src="https://735611837-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 つの shard を同じフォルダに入れ、 `--model` を最初の shard に向けてください。llama.cpp は残りの shard を自動で読み込みます。
{% 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"
```

この例では、Engram の n-gram テーブルを SSD から必要に応じて読み込みます。SSD オフロード用に `--load-mode mmap` と `--lazy-mode on` を有効にしてください。
{% endstep %}
{% endstepper %}

### ⚡**DSpark** - 推測デコーディング

DeepSeek-V4.1 には **DSpark**、メインモデルが検証する前に複数のトークンを提案する推測デコーディングアーキテクチャが含まれています。これは Engram の n-gram ルックアップテーブルとは別です: **Engram は学習済みメモリを提供し、DSpark はデコードを高速化します**。同様の名前の n-gram 推測デコーディングオプションも別機能です。

DSpark を使う場合は、メインモデルを対応する **V4.1-1017 ドラフター** と組み合わせ、DSpark 対応ランタイムを使用してください。ドラフターとメインのチェックポイントのバージョンを一致させ、ドラフター用に追加メモリを確保してください。このガイドの 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 だけを <https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF/tree/main/engram> という `DeepSeek-V4.1-Flash-1017-engram-MXFP8.gguf_file` にあるものをダウンロードするだけで、MXFP8 のものに切り替えられます。

```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. 古いテーブルを退避し、新しいものをテーブル shard の名前に変更する
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 参照に対して 82.8〜98.5% の top-1 一致率、long17k では 85.1〜98.7% の一致率を示します。UD-Q4\_K\_XL は UD-Q8\_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://735611837-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         |
| ProgramBench            | 29.1            | 20.3         |
| NL2Repo-Bench           | 68.2            | 65.4         |
| Automation-Bench v1.0.6 | 60.5            | 54.8         |
| Agents’ Last Exam       | 35.4            | 31.8         |
| Apex Bench 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/jp/moderu/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.
