> 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.md).

# DeepSeek-V4: ローカルでの実行方法

DeepSeek-V4は、DeepSeekの新しいオープンモデルで、以下を含みます **DeepSeek-V4-Pro** および **1.6T** パラメータ（49Bアクティブ）と **DeepSeek-V4-Flash** および **284B** パラメータ（13Bアクティブ）。これらのモデルは、コーディング、エージェント型ワークフロー、そして **100万トークンのコンテキスト** ウィンドウです。このガイドでは、DeepSeek-V4-Flashを ローカルで実行する方法を紹介します： [DeepSeek-V4-Flash GGUF](https://huggingface.co/unsloth/DeepSeek-V4-Flash-GGUF)

損失なしの **損失なしの** DeepSeekではQ8（`UD-Q8_K_XL`）、これはわずか **7GB大きいだけで** Q4（`UD-Q4_K_XL`）。 損失なしの8ビットGGUFは **162 GB** で、3ビットは **103GB** これは **110GBのRAM** 搭載デバイスで実行できま&#x3059;**.** DeepSeek-V4-FlashはMMLU-Proで86.2%、GPQA Diamondで88.1%、Terminal Bench 2.0で56.9%を記録しています。

{% hint style="success" %}
**7月7日：** DeepSeek-V4は、実行準備が整いました！また、 [DeepSeek-V4のチャット jinjaテンプレート](#deepseek-v4-chat-template-improvements)も改善し、4000件以上の会話で公式ベースラインと同等であることを検証しました。
{% endhint %}

<a href="/pages/7e26e08ac7ef8f627a7df931c96d2f819be44cd4#usage-guide" class="button primary">使用ガイド</a><a href="/pages/7e26e08ac7ef8f627a7df931c96d2f819be44cd4#run-deepseek-v4-flash-tutorials" class="button primary">実行チュートリアル</a>

### :llama: llama.cppのDeepSeek V4実装修正

llama.cppはDeepSeek V4のサポートを [24162](https://github.com/ggml-org/llama.cpp/pull/24162) - 私たちは、 **どの提供元のものでも**からのGGUFを使用すると、KVキャッシュ量子化を使った場合に、マルチターン会話がDS4のHugging Faceベースラインと比べてうまく機能しないことに気づきました `--cache-type/k/v q8_0` - その後、2026年7月7日以降、llama.cppに修正が入り、マージされました。 [25202](https://github.com/ggml-org/llama.cpp/pull/25202)

具体的には、修正前はDeepSeekの量子化モデルを呼び出すと `overlayotin kinetic academyléléléléulif` 、PR後には「フランスの首都はパリです。」となり、これは正しいです。

<table><thead><tr><th>エンジン</th><th width="91.54998779296875">スコア</th><th width="122.60003662109375">計算</th><th width="114.5">ツール選択</th><th width="97.4000244140625">並列ツール</th><th width="112.699951171875">マルチターンツール</th><th>ネストされたツール</th></tr></thead><tbody><tr><td>公式コード</td><td><strong>15/15</strong></td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td></tr><tr><td>任意の提供元</td><td><strong>4/15</strong></td><td>1</td><td>2</td><td>0</td><td>0</td><td>1</td></tr><tr><td><strong>後</strong> <a href="https://github.com/ggml-org/llama.cpp/pull/25202">25202</a></td><td><strong>15/15</strong></td><td>3</td><td>2</td><td>3</td><td>3</td><td>3</td></tr></tbody></table>

### :speech\_balloon: DeepSeek V4チャットテンプレートの改善

DeepSeek-V4のチャット jinjaテンプレートも改善し、4000件以上の会話でゴールデンベースライン（公式DS4）と同等であることを検証しました

追加しました `reasoning_effort` を追加し、 `max、high` を選べます。公式のDeepSeek-V4と同様です。DS4に従って正しいシステムプロンプトを先頭に付け、gpt-ossのスタイルに倣っています。

また、ツール呼び出しでは、 `reasoning_content` はDS4で保持されていましたが、jinjaチャットテンプレートでは除外されていました。それを復活させました。

**思考の無効化、推論強度の変更**

DeepSeek-V4はデフォルトで推論を使用します。また、推論強度をサポートしており、 `reasoning_effort` は「high」「max」、または無効にできます。

思考を無効にするには、以下を使用します： `--chat-template-kwargs '{"enable_thinking":false}'`。 **Windows** のPowerShellでは、次を使用してください： `--chat-template-kwargs "{\"enable_thinking\":false}"`

また、次も使用できます `--reasoning on` または `--reasoning off` をllama.cppでも使えるようになりました！

推論強度のカスタマイズや推論の無効化には、以下の例を使用してください：

```bash
--chat-template-kwargs '{"reasoning_effort":"max"}'
--chat-template-kwargs '{"reasoning_effort":"high"}'
--chat-template-kwargs '{"enable_thinking":false}'
```

### 📊 量子化分析

私たちの `UD-Q8_K_XL` 量子化は完全に損失なしです。DeepSeek-V4-Flashは [量子化を意識して学習されています](/docs/jp/burogu/quantization-aware-training-qat.md)：公式チェックポイントは、ルーティングされたエキスパート（モデルの96%）をネイティブにMXFP4で保存し、それ以外はすべてFP8またはBF16です。GGUFのMXFP4はまさにその形式なので、エキスパートをビット単位で再パックし、FP8は丸めなしでBF16にデ量子化されます。公式のDeepSeek重みとすべてのテンソルを照合したところ、1,328個すべてがビット一致し、推論時も損失なしのままです（KLダイバージェンスはほぼ0、トップトークン一致率100%）。

**非**-Unsloth DeepSeek-V4-FlashのGGUFはこれらのパスを使わずに変換されていたため、公式重みと異なっていました。 `UD-Q4_K_XL` 同一のビット一致エキスパートを保持し、非エキスパートのテンソル（モデルの4%）のみをQ8\_0に量子化するため、サイズと品質はQ8のすぐ隣に位置します。

<div align="left"><figure><img src="/files/a65ebc963dcb65162d58870d841e80434a7c5f1f" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="/files/b619ac65f3d479e2449322769fdf674a9da998ea" alt="" width="563"><figcaption></figcaption></figure></div>

公式重みと比較すると、両方のUnsloth量子化は品質/サイズの最前線にあります。UD-Q8\_K\_XLが唯一の損失なしのポイントです。UD-Q4\_K\_XLは他のコミュニティ製MXFP4形式と一致し、Q4\_K-experts変換より高精度で、それらはより大きいにもかかわらず0.029のKLDに達します。

<div align="left"><figure><img src="/files/9b36d1d24751ca985df67e9bc5e2930494856b98" alt="" width="563"><figcaption></figcaption></figure></div>

層ごとの誤差分布がその理由を示しています。ネイティブMXFP4エキスパートを維持すると、各層で重み誤差は0%です。エキスパートをQ4\_KやIQ2\_XXSに再量子化する変換では、ほぼすべての重みが丸められます：Q4\_Kでは5%、IQ2\_XXSでは30%以上です。

<div align="left"><figure><img src="/files/5ad9e679444ce07ff169ff366d996c66f80c3f20" alt="" width="563"><figcaption><p>私たちのMXFP4は8.4M個すべての重みで誤差がちょうど0ですが、別の4ビットグリッドであるQ4_Kは各重みを丸める必要があり（RMSE 5.2%）、</p></figcaption></figure></div>

一部のテンソルでQ8\_0とF16を使うのも損失なしではないことが分かりました。さらに、DeepSeekによってMXFP4 / FP8をうまく動かすためにQATが適用されているため、状況は悪化します。そのため、それらは直接BF16のままにしておく必要がありました。したがって、真の損失なし量子化にはUD-Q8\_K\_XLを使い、UD-Q4\_K\_XLではBF16項目の一部をQ8\_0へダウングレードします。

の完全なベンチマーク表は [GGUFベンチマークはこちら](#gguf-benchmarks).

#### ⚙️ 使用ガイド

DeepSeek-V4-FlashはDeepSeek-V4-Proより小さく高速で、 **284B** パラメータ（13Bアクティブ）と **100万トークンのコンテキストウィンドウ**があります。このモデルには3つのモードがあります、 **非思考**, **思考** **High** と **思考** **Max**.&#x20;

使用することを推奨します `UD-IQ3_XXS` は **103GB** が最良の結果です。ファイルサイズにはKVキャッシュやコンテキスト割り当ては含まれていないため、少なくとも **110GBのRAM** あればモデルを実行できます。

その `UD-Q8_K_XL` 量子化モデルは、DeepSeek-V4-Flashを完全な元精度のまま保持したものです。サイズは162GBで、少なくとも169GBの利用可能なRAM/VRAMを確保するのが理想です。

**表：推論ハードウェア要件** （単位 = 合計メモリ：RAM + VRAM、またはユニファイドメモリ）

<table><thead><tr><th width="129.8004150390625">1ビット</th><th width="130.85650634765625">2ビット</th><th width="140.26702880859375">3ビット</th><th>4ビット（ほぼ損失なし）</th><th>Q8_K_XL（損失なし）</th></tr></thead><tbody><tr><td>92 GB</td><td>102 GB</td><td>110-135 GB</td><td>162 GB</td><td>169 GB</td></tr></tbody></table>

{% hint style="success" %}
最高の性能を得るには、VRAMとシステムRAMを含む利用可能な総メモリが、量子化済みモデルファイルサイズを十分に上回るようにしてください。
{% endhint %}

#### 推奨設定

DeepSeekは、最良の性能のために以下のパラメータを推奨しています： `temperature=1.0`, `top-p=1.0`

**Think Highはデフォルトで有効です。** 無効になっている場合は、以下で有効にできます： `--chat-template-kwargs '{"enable_thinking":true}'` または、以下のUIドロップダウンで切り替えできます： [Unsloth Studio](#unsloth-studio-guide)。あわせてこちらも参照： [#deepseek-v4-chat-template-improvements](#deepseek-v4-chat-template-improvements "mention")

{% columns %}
{% column %}

| `temperature = 1.0` |
| ------------------- |
| `top-p = 1.0`       |
| {% endcolumn %}     |

{% column %}

* **最大コンテキストウィンドウ：** `1,048,576`
* Think Maxの場合は、コンテキストを少なくとも **384Kトークン**.
  {% endcolumn %}
  {% endcolumns %}

## DeepSeek-V4-Flash実行チュートリアル：

このチュートリアルでは、3ビット量子化を使用します `UD-IQ3_XXS`。これは128GB RAMのデバイスに収まるためです。以下に置き換えてください `UD-IQ3_XXS` および `UD-Q8_K_XL` （元品質）または、マシンに十分なメモリがあるなら別の量子化を使用してください。これで、DeepSeek-V4-Flashを [Unsloth Studio](#run-in-unsloth-studio).

<a href="/pages/7e26e08ac7ef8f627a7df931c96d2f819be44cd4#unsloth-studio-guide" class="button primary">🦥 Unsloth Studioガイド</a><a href="/pages/7e26e08ac7ef8f627a7df931c96d2f819be44cd4#llama.cpp-guide" class="button primary">🦙 Llama.cppガイド</a>

### 🦥 Unsloth Studioガイド

DeepSeek-V4-Flashは、現在以下で実行および学習できます [Unsloth Studio](/docs/jp/shii/studio.md)。これはローカルAI向けの新しいオープンソースWeb UIです。Unsloth Studioでは、モデルをローカルで **MacOS**, **Windows**、Linux、そして：

{% columns %}
{% column %}

* 検索、ダウンロード、 [GGUFの実行](/docs/jp/shii/studio.md#run-models-locally) およびsafetensorモデル
* [**自己修復** ツール呼び出し](/docs/jp/shii/studio.md#execute-code--heal-tool-calling) + **ウェブ検索**
* [**コード実行**](/docs/jp/shii/studio.md#run-models-locally) （Python、Bash）
* [自動推論](/docs/jp/shii/studio.md#model-arena) パラメータ調整（temp、top-pなど）
* llama.cppによる高速なCPU + GPU推論
* [LLMの学習](/docs/jp/shii/studio.md#no-code-training) VRAMを70%削減しつつ2倍高速
  {% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="/files/0c669daca85ca010593ac3f42e8184ceed3a362c" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}

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

最新バージョンを使用していることを確認してください。ターミナルで実行：

**MacOS、Linux、WSL：**

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

**Windows PowerShell：**

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

{% endstep %}

{% step %}

#### Unslothを起動

**MacOS、Linux、WSL、Windows：**

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

その後、 `http://127.0.0.1:8888` （または指定のURL）をブラウザで開いてください。
{% endstep %}

{% step %}

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

初回起動時には、アカウントを保護するためのパスワードを作成し、再度サインインする必要があります。その後、 [Unsloth Chat](/docs/jp/shii/studio/chat.md) タブを開き、検索バーでDeepSeek-V4-Flashを検索して、希望のモデルと量子化をダウンロードしてください。

<figure><img src="/files/45da0e53ec6c6dffc6866ebc4f12bdc4e1255bd4" alt="" width="563"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### DeepSeek-V4-Flashを実行

Unsloth Studioを使うと推論パラメータは自動設定されますが、手動でも変更できます。 **Think Highはデフォルトで有効**なので、右側のドロップダウンからNon-thinkまたはThink Maxに切り替えられます。コンテキスト長、チャットテンプレート、その他の設定も編集できます。

詳細は、以下をご覧ください： [Unsloth Studio推論ガイド](/docs/jp/shii/studio/chat.md).

<figure><img src="/files/668875d75498112271cc5626c709a3674caaefe2" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### 🦙 Llama.cppガイド

{% 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サポートはデフォルトで有効です。

```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
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 %}
これで以下を使用できます `llama.cpp` を直接使ってモデルを読み込み・ダウンロードできます。ちょうど `ollama run`のように。まず、希望する量子化タイプを `IQ3_XXS`。また、以下を使用して `export LLAMA_CACHE="folder"` 保存先を `llama.cpp` 特定の場所に固定できます。なお、このダウンロード प्रक्रियाは非常に遅い場合があるため、次のセクションの手動ダウンロード手順を使うのがおそらく最適です。

```bash
export LLAMA_CACHE="unsloth/DeepSeek-V4-Flash-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/DeepSeek-V4-Flash-GGUF:UD-IQ3_XXS \\
    --temp 1.0 \\
    --top-p 1.0 \\
    --min-p 0.0
```

{% endstep %}

{% step %}
モデルを手動でダウンロードしたい場合は、以下のコードでダウンロードできます（ `pip install huggingface_hub`をインストールした後）。ダウンロードが止まる場合は、以下を参照： [Hugging Face Hub、XETのデバッグ](/docs/jp/ji-ben/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/DeepSeek-V4-Flash-GGUF \\
    --local-dir unsloth/DeepSeek-V4-Flash-GGUF \\
    --include "*UD-IQ3_XXS*" # 4ビットには "*UD-IQ4_XS*" を使用
```

{% endstep %}

{% step %}
以下を編集できます `--threads 32` CPUスレッド数として、 `--ctx-size 32768` コンテキスト長として、 `--n-gpu-layers 2` GPUオフロードする層数として指定します。GPUのメモリ不足が起きる場合は調整してみてください。CPUのみで推論する場合は削除してください。

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/DeepSeek-V4-Flash-GGUF/blob/main/UD-IQ3_XXS/DeepSeek-V4-Flash-UD-IQ3_XXS-00001-of-00004.gguf \\
    --temp 1.0 \\
    --top-p 1.0 \\
    --min-p 0.0
```

{% endcode %}
{% endstep %}
{% endstepper %}

## 📊 ベンチマーク

### GGUFベンチマーク

Unslothおよび他の提供元の量子化のベンチマーク比較表は以下をご覧ください。参照値 = 公式重み。wikitext-2上で、ctx 512、4x B200におけるパープレキシティとKLダイバージェンス。

<figure><img src="/files/a65ebc963dcb65162d58870d841e80434a7c5f1f" alt="" width="563"><figcaption></figcaption></figure>

| 量子化                               | サイズ（GB） | PPL    | 平均KLD        | RMS delta-p | 同一トップトークン | ビット一致の重み     |
| --------------------------------- | ------- | ------ | ------------ | ----------- | --------- | ------------ |
| 公式（参照）                            | 156.4   | 4.5319 | 0            | 0%          | 100%      | 100%         |
| **Unsloth UD-Q8\_K\_XL**          | 161.9   | 4.5319 | **約0（損失なし）** | 0.000%      | 100.000%  | **100.000%** |
| **Unsloth UD-Q4\_K\_XL**          | 155.1   | 4.5335 | 0.0102       | 3.40%       | 96.28%    | 97.46%       |
| bartowski MXFP4                   | 156.0   | 4.5351 | 0.0105       | 3.42%       | 96.18%    | 97.57%       |
| antirez Q4KExperts-F16（imatrix）   | 164.6   | 4.5743 | 0.0291       | 5.87%       | 93.95%    | 0.51%        |
| antirez Q4KExperts-F16            | 164.6   | 4.5726 | 0.0290       | 5.89%       | 93.94%    | 0.93%        |
| antirez mixed L37-42-Q4K（imatrix） | 97.6    | 5.8169 | 0.3605       | 21.15%      | 79.74%    | 0.41%        |
| antirez IQ2XXS（imatrix）           | 86.7    | 6.0808 | 0.4079       | 22.23%      | 78.15%    | 0.39%        |
| antirez IQ2XXS                    | 86.7    | 6.1518 | 0.4207       | 22.74%      | 77.92%    | 0.47%        |

### 公式ベンチマーク

表形式のベンチマークはさらに下にあります：

<figure><img src="/files/612ee251571abd8da32cc091bad36fff16b99dc3" alt="" width="563"><figcaption></figcaption></figure>

| ベンチマーク（指標）                 | V4-Flash 非思考 | V4-Flash High | V4-Flash Max | V4-Pro 非思考 | V4-Pro High | V4-Pro Max |
| -------------------------- | :----------: | :-----------: | :----------: | :--------: | :---------: | :--------: |
| **知識と推論**                  |              |               |              |            |             |            |
| MMLU-Pro（EM）               |     83.0     |      86.4     |     86.2     |    82.9    |     87.1    |  **87.5**  |
| SimpleQA-Verified（Pass\@1） |     23.1     |      28.9     |     34.1     |    45.0    |     46.2    |  **57.9**  |
| Chinese-SimpleQA（Pass\@1）  |     71.5     |      73.2     |     78.9     |    75.8    |     77.7    |  **84.4**  |
| GPQA Diamond（Pass\@1）      |     71.2     |      87.4     |     88.1     |    72.9    |     89.1    |  **90.1**  |
| HLE（Pass\@1）               |      8.1     |      29.4     |     34.8     |     7.7    |     34.5    |  **37.7**  |
| LiveCodeBench（Pass\@1）     |     55.2     |      88.4     |     91.6     |    56.8    |     89.8    |  **93.5**  |
| Codeforces（レーティング）         |       -      |      2816     |     3052     |      -     |     2919    |  **3206**  |
| HMMT 2026 Feb（Pass\@1）     |     40.8     |      91.9     |     94.8     |    31.7    |     94.0    |  **95.2**  |
| IMOAnswerBench（Pass\@1）    |     41.9     |      85.1     |     88.4     |    35.3    |     88.0    |  **89.8**  |
| Apex（Pass\@1）              |      1.0     |      19.1     |     33.0     |     0.4    |     27.4    |  **38.3**  |
| Apex Shortlist（Pass\@1）    |      9.3     |      72.1     |     85.7     |     9.2    |     85.5    |  **90.2**  |
| **長文コンテキスト**               |              |               |              |            |             |            |
| MRCR 1M（MMR）               |     37.5     |      76.9     |     78.7     |    44.7    |     83.3    |  **83.5**  |
| CorpusQA 1M（ACC）           |     15.5     |      59.3     |     60.5     |    35.6    |     56.5    |  **62.0**  |
| **エージェント型**                |              |               |              |            |             |            |
| Terminal Bench 2.0（Acc）    |     49.1     |      56.6     |     56.9     |    59.1    |     63.3    |  **67.9**  |
| SWE Verified（解決済み）         |     73.7     |      78.6     |     79.0     |    73.6    |     79.4    |  **80.6**  |
| SWE Pro（解決済み）              |     49.1     |      52.3     |     52.6     |    52.1    |     54.4    |  **55.4**  |
| SWE Multilingual（解決済み）     |     69.7     |      70.2     |     73.3     |    69.8    |     74.1    |  **76.2**  |
| BrowseComp（Pass\@1）        |       -      |      53.5     |     73.2     |      -     |     80.4    |  **83.4**  |
| ツール付きHLE（Pass\@1）          |       -      |      40.3     |     45.1     |      -     |     44.7    |  **48.2**  |
| MCPAtlas（Pass\@1）          |     64.0     |      67.4     |     69.0     |    69.4    |   **74.2**  |    73.6    |
| GDPval-AA（Elo）             |       -      |       -       |     1395     |      -     |      -      |  **1554**  |
| Toolathlon（Pass\@1）        |     40.7     |      43.5     |     47.8     |    46.3    |     49.0    |  **51.8**  |


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://unsloth.ai/docs/jp/moderu/deepseek-v4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
