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

# DiffusionGemma - ローカルでの実行方法

DiffusionGemma **26B-A4B** Google DeepMind の新しいオープン **マルチモーダル** モデルで、〜上に構築された [Gemma 4](/docs/jp/moderu/gemma-4.md) MoEアーキテクチャ。〜に対応し **256Kコンテキスト**, **140以上の言語**、DiffusionGemma は〜向けに設計されています **高速テキスト生成** テキスト、動画、画像入力全体にわたって。DiffusionGemma はローカルで実行できます **18GB RAM**、そして [ファインチューニング](#fine-tune-diffusiongemma) は現在、〜経由でサポートされています [Unsloth](https://github.com/unslothai/unsloth).

標準的なトークンごとのデコードの代わりに、DiffusionGemma は **拡散生成** を使用して出力を並列に生成し、徐々に最終回答へ洗練していきます。これは拡散画像モデルに似ていますが、テキスト向けです。モデルは以下で実行できます: [Unsloth Studio](/docs/jp/shii/studio.md) または llama.cpp。RTX 6000 では、DiffusionGemma は次に達することができます **2000トークン/秒以上**. **GGUF：** [diffusiongemma-26B-A4B-it-GGUF](https://huggingface.co/unsloth/diffusiongemma-26B-A4B-it-GGUF)

<a href="/pages/67dde10a83f289f1c4d84bf59deafcd898794129#run-diffusiongemma-tutorials" class="button primary">DiffusionGemma を実行</a><a href="/pages/67dde10a83f289f1c4d84bf59deafcd898794129#fine-tune-diffusiongemma" class="button secondary">DiffusionGemma をファインチューニング</a>

{% hint style="success" %}
**6月12日:** 現在、DiffusionGemma を以下経由で実行できます [Unsloth Studio](#unsloth-studio-guide) ✨ 推論が1.8倍高速に！
{% endhint %}

### 使用ガイド

DiffusionGemma は、標準モデルより高速な生成を必要とするユーザー向けに設計されています。高速なローカル推論、長文脈文書分析、画像/動画理解、OCRと文書解析、コード生成、ツール利用、エージェント的ワークフロー、低遅延の小バッチ推論に適しています。

標準の Gemma 4 モデルとは異なり、DiffusionGemma には拡散対応の推論ランタイムが必要です。次のような自己回帰設定だけでは `temperature`, `top_p`、そして `top_k` 必要な拡散サンプラーなしに推奨動作を再現するには不十分です。

<div data-with-frame="true"><figure><img src="/files/c3cb18ff1e86ab57357a3712b0511e41752c66b4" alt="" width="563"><figcaption></figcaption></figure></div>

### ハードウェア要件

モデルを4ビット精度で動かすには、少なくとも18GBのRAMがあるのが一般的に望ましいです。 **GGUF：** [diffusiongemma-26B-A4B-it-GGUF](https://huggingface.co/unsloth/diffusiongemma-26B-A4B-it-GGUF)

**表: DiffusionGemma Inference GGUF の推奨ハードウェア要件** （単位 = 総メモリ: RAM + VRAM、またはユニファイドメモリ）

| 4ビット  | 5-bit | 6ビット  | 8ビット  | BF16 / FP16 |
| ----- | ----- | ----- | ----- | ----------- |
| 18 GB | 20 GB | 24 GB | 28 GB | 52 GB       |

{% hint style="info" %}
目安として、利用可能な総メモリは、ダウンロードする量子化モデルのサイズを少なくとも上回る必要があります。そうでなくても、RAM/ディスクへの部分オフロードを使って実行できますが、生成は遅くなります。また、使用するコンテキストウィンドウに応じて、より多くの計算リソースも必要になります。
{% endhint %}

## DiffusionGemma の実行チュートリアル

少なくとも4ビット精度を使うのが最適なので、4ビットの `Q4_K_M` 量子化版を使用します。これには18GBのRAMが必要です。 **GGUF：** [diffusiongemma-26B-A4B-it-GGUF](https://huggingface.co/unsloth/diffusiongemma-26B-A4B-it-GGUF)

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

### 🦥 Unsloth Studioガイド

{% hint style="success" %}
現在、DiffusionGemma を以下経由で実行できます [Unsloth Studio](#unsloth-studio-guide) ✨。 [`v0.1.463-beta`](https://github.com/unslothai/unsloth/tree/v0.1.462-beta) または `2026.6.6`.
{% endhint %}

DiffusionGemma は現在、実行および学習を [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/c3cb18ff1e86ab57357a3712b0511e41752c66b4" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}

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

最新のものを使用するようにしてください [`v0.1.463-beta`](https://github.com/unslothai/unsloth/tree/v0.1.462-beta) または `2026.6.6`。ターミナルで実行してください：

**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 %}

#### DiffusionGemma を検索してダウンロード

初回起動時には、アカウントを保護するためのパスワードを作成し、再度サインインする必要があります。

その後、 [Unsloth Chat](/docs/jp/shii/studio/chat.md) タブで検索バーに DiffusionGemma を入力し、希望するモデルと量子化版をダウンロードします。
{% endstep %}

{% step %}

#### DiffusionGemma を実行

Unsloth Studioを使用すると推論パラメータは自動設定されますが、手動で変更することもできます。コンテキスト長、チャットテンプレート、その他の設定も編集できます。

詳細については、 [Unsloth Studio 推論ガイド](/docs/jp/shii/studio/chat.md).

<div data-with-frame="true"><figure><img src="/files/c3cb18ff1e86ab57357a3712b0511e41752c66b4" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}

### 🦙 Llama.cppガイド

このチュートリアルでは、Dynamic 4ビットの `Q4_K_M` 量子化版を使用し、18GBのRAMが必要です。 [llama.cpp](llama.cpphttps://github.com/ggml-org/llama.cpp) 特に CPU を使っている場合に、ローカルで高速推論するために使用します。

{% stepper %}
{% step %}
特定の `llama.cpp` のPRを取得 [**GitHub はこちら**](https://github.com/ggml-org/llama.cpp/pull/24423)。以下のビルド手順に従うこともできます。 `-DGGML_CUDA=ON` を `-DGGML_CUDA=OFF` に変更してください。GPU がない場合や CPU 推論だけを使いたい場合です。 **Apple Mac / Metal デバイスの場合**、 `-DGGML_CUDA=OFF` に設定し、そのまま続行してください。Metal サポートはデフォルトで有効です。

```bash
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
gh pr checkout 24423
# CUDAでビルド（CPUのみビルドにするには -DGGML_CUDA=ON を外す）
cmake -B build -DGGML_CUDA=ON
cmake --build build -j --config Release --target llama-diffusion-cli
cd ..
```

{% endstep %}

{% step %}
（をインストールした後に）モデルをダウンロードしてください `pip install huggingface_hub`）。次のいずれかを選択できます `Q4_K_M` または次のような他の量子化版を選択できます `Q8_0` 。ダウンロードが止まる場合は、以下を参照してください: [Hugging Face Hub、XETのデバッグ](/docs/jp/ji-ben/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
pip install -U "huggingface_hub[cli]"
hf download unsloth/diffusiongemma-26B-A4B-it-GGUF \\
    --local-dir unsloth/diffusiongemma-26B-A4B-it-GGUF \\
    --include "*Q8_0*" # より小さい16GBのダウンロードには "*Q4_K_M*" を使用
```

{% endstep %}
{% endstepper %}

### DiffusionGemma とチャット

その後、以下を実行します:

{% code overflow="wrap" %}

```bash
./build/bin/llama-diffusion-cli \\
  -m unsloth/diffusiongemma-26B-A4B-it-GGUF/diffusiongemma-26B-A4B-it-Q8_0.gguf \\
  -ngl 99 -cnv -n 2048
```

{% endcode %}

次のように表示されます:

<figure><img src="/files/fa3ee102c7fe1f0619d2572e8f72b7dfa0f64001" alt=""><figcaption></figcaption></figure>

そして「Flappy Bird ゲームを作成して」のような質問を入力すると、ステップが表示されます:

<figure><img src="/files/72fe86bf54063a42a8d5348cd07715fb096d6569" alt=""><figcaption></figcaption></figure>

その後、出力が表示されます:

<figure><img src="/files/6daa207428749871a1d361985f850ee8f9d8c27b" alt="" width="375"><figcaption></figcaption></figure>

会話を続けることもできます！

変更してください `-n 2048` 予測したいトークン数を指定します。大きいほど、より長い回答になります。

### 拡散のライブ可視化

拡散を実際にライブで見るには、以下を使用します。特に有効にするのは `--diffusion-visual`:

```bash
./build/bin/llama-diffusion-cli \\
  -m unsloth/diffusiongemma-26B-A4B-it-GGUF/diffusiongemma-26B-A4B-it-Q8_0.gguf \\
  -ngl 99 -cnv -n 2048 --diffusion-visual
```

再び次が表示されます:

<figure><img src="/files/711f4cdbf0da0c6cf0c7ebfb0b6623b709f797ee" alt=""><figcaption></figcaption></figure>

そして得られるのは:

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

次のブランチを使用した llama.cpp の全パラメータ:

* `-n, --n-predict N` - 目標トークン; そこから導出 `--diffusion-blocks` そして増加 `-ub` / `-b` / `-c`.
* `-ngl 99` - すべての層をGPUへオフロード（`-ngl 0` CPUのみの場合）。
* `-cnv` - マルチターン会話モード。
* `--diffusion-visual` - ライブキャンバスのノイズ除去表示。
* Entropy-Bound サンプラーはデフォルトで有効（`--diffusion-eb auto`）。以下で調整します: `--diffusion-eb-max-steps` （デフォルト48）、 `--diffusion-eb-t-max` / `--diffusion-eb-t-min` (0.8 -> 0.4), `--diffusion-eb-entropy-bound` （0.1）、および `--diffusion-eb-confidence` (0.005).
* `--diffusion-kv-cache {auto,on,off}` - プロンプトプレフィックスのKVキャッシュ（auto = 単一GPUではオン）。

## DiffusionGemma をファインチューニング

現在、DiffusionGemma を直接 [**Unsloth**](#unsloth-studio-guide)。この例では、ドメイン固有学習の影響を示すために、スドクーでモデルをファインチューニングします。ベースモデルは当初スドクーのタスクで性能が低いですが、対象を絞ったデータセットで学習した後は、実際にスドクーを解く方法を学び、すべての例を正しく解けるようになります。

Colab ノートブック（A100）を使って、以下で DiffusionGemma をファインチューニングできます:

{% embed url="<https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/DiffusionGemma_(26B-A4B)-Sudoku.ipynb>" %}

<div data-with-frame="true"><figure><img src="/files/f272586b00e3025fb709accaf4270c773c3e6ca8" alt="" width="563"><figcaption></figcaption></figure></div>

## 推奨設定

[Unsloth Studio](#unsloth-studio-guide) モデルに最適な推論設定を自動で設定します。必要なら以下を使用してください:

| カテゴリ   | 設定           | 値                           |
| ------ | ------------ | --------------------------- |
| サンプリング | 手法           | `diffusion_sampling`        |
| サンプリング | サンプラー        | `entropy_bounded_denoising` |
| サンプリング | 最大ノイズ除去ステップ数 | `48`                        |
| 温度     | 温度スケジュール     | `linear_decay`              |
| 温度     | 温度開始         | `0.8`                       |
| 温度     | 温度終了         | `0.4`                       |
| エントロピー | エントロピー境界     | `0.1`                       |
| 適応停止   | 適応停止が有効      | `true`                      |
| 適応停止   | エントロピー閾値     | `0.005`                     |
| キャンバス  | キャンバス長       | `256`                       |

**適応停止のトリガー条件**

適応停止がトリガーされるのは、 **両方の** 条件が満たされたときのみです:

| 条件                        | 必要な値      |
| ------------------------- | --------- |
| キャンバスの平均エントロピー            | `< 0.005` |
| 最も高確率のトークンが2ステップ連続で安定している | `true`    |

各ノイズ除去ステップで、サンプラーは相互情報量境界が次の値のままである、最も低エントロピーなトークンを選択すべきです: `entropy_bound = 0.1`。選択されなかったトークンは、次のノイズ除去ステップの前に完全に再ノイズ化されるべきです。

### 思考モード

DiffusionGemma は Gemma 4 形式の思考モードをサポートします。思考を有効にするには、システムプロンプトの先頭に思考トークンを追加します:

```
<|think|>
```

思考が有効な場合、モデルは内部推論チャネルの後に最終回答を出力することがあります:

```
<|channel>thought
[内部推論]
<channel|>
[最終回答]
```

思考を無効にするには、 `<|think|>` トークンをシステムプロンプトから削除します。思考が無効でも、モデルは空の thought チャネルを出力することがあります:

```
<|channel>thought
<channel|>
[最終回答]
```

マルチターン会話では、 **はいけません** 以前の隠れた思考を会話履歴に含めないでください。次のユーザーターンの前には、最終的なアシスタント応答のみを含めてください。

## DiffusionGemma のベストプラクティス

### マルチモーダルプロンプト

DiffusionGemma は、テキストや画像を含むインターリーブされたマルチモーダル入力をサポートします。動画は画像フレームのシーケンスとして処理できます。

マルチモーダルプロンプトで最良の結果を得るには、画像またはフレームの内容をテキスト指示より前に配置します。例:

```
[画像]
グラフを説明し、主要な傾向を要約してください。
```

文書解析、OCR、グラフ理解、UI理解、または短いテキスト抽出には、より大きいビジュアルトークン予算を使用してください。

対応するビジュアルトークン予算:

| ビジュアルトークン予算 | 最適用途                |
| ----------- | ------------------- |
| 70          | 高速分類、簡単なキャプション生成    |
| 140         | 軽量な視覚QA             |
| 280         | 一般的な画像理解            |
| 560         | OCR、グラフ、UIスクリーンショット |
| 1120        | 密な文書、細かい文字、詳細抽出     |

動画形式の入力では、DiffusionGemma は最大で処理できます **60秒** 〜のサンプリング時 **1秒あたり1フレーム**.

### サンプリングに関する注意

DiffusionGemma は通常の次トークンのみのモデルではありません。これは **キャンバス**、ノイズのあるトークン予測を繰り返し洗練することで。生成プロセスは概ね次のとおりです:

1. エンコーダーがプロンプトを処理し、コンテキストキャッシュを構築します。
2. デコーダーが256トークンの生成キャンバスを受け取ります。
3. 拡散サンプラーがキャンバスのノイズを反復的に除去します。
4. 確信度の高いトークンが選択され、保持されます。
5. 不確かなトークンは再びノイズ付けされ、再度洗練されます。
6. キャンバスが完成すると、コンテキストに追加されます。
7. モデルは次のキャンバスへ進みます。

このブロック自己回帰的アプローチにより、DiffusionGemma は標準的な自己回帰モデルより少ない順伝播回数で多数のトークンを生成できます。

## ベンチマーク

DiffusionGemma は速度とマルチモーダル推論に最適化されていますが、標準の Gemma 4 は従来の推論ベンチマークでより強力です。

| ベンチマーク              | DiffusionGemma 26B-A4B | Gemma 4 26B-A4B |
| ------------------- | ---------------------: | --------------: |
| MMLU Pro            |                  77.6% |           82.6% |
| AIME 2026 ツールなし     |                  69.1% |           88.3% |
| LiveCodeBench v6    |                  69.1% |           77.1% |
| Codeforces ELO      |                   1429 |            1718 |
| GPQA Diamond        |                  73.2% |           82.3% |
| Tau2 平均             |                  56.2% |           68.2% |
| HLE ツールなし           |                  11.0% |            8.7% |
| HLE 検索あり            |                  11.9% |           17.2% |
| BigBench Extra Hard |                  47.6% |           64.8% |
| MMMLU               |                  81.5% |           86.3% |

| 長文脈ベンチマーク                | DiffusionGemma 26B-A4B | Gemma 4 26B-A4B |
| ------------------------ | ---------------------: | --------------: |
| MRCR v2 8 needle 128K 平均 |                  32.0% |           44.1% |

**視覚ベンチマーク:**

| 視覚ベンチマーク                | DiffusionGemma 26B-A4B | Gemma 4 26B-A4B |
| ----------------------- | ---------------------: | --------------: |
| MMMU Pro                |                  54.3% |           73.8% |
| OmniDocBench 1.5、低いほど良い |                  0.319 |           0.149 |
| MATH-Vision             |                  70.5% |           82.4% |
| MedXPertQA MM           |                  49.0% |           58.1% |


---

# 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/diffusiongemma.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.
