> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec-2b9c2cf.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemma 4 ComfyUI ワークフロー例

> ComfyUI で Google の軽量オープン LLM「Gemma 4」を実行し、テキスト生成、画像理解、動画分析、音声文字起こしを最大 256K コンテキストでサポートします。

<Tip>
  <Tabs>
    <Tab title="ローカルユーザー">
      ComfyUI が最新版に更新されていることを確認してください。

      * [ComfyUI のダウンロード](https://www.comfy.org/download)
      * [更新手順](/ja/installation/update_comfyui)

      このガイドで紹介するワークフローは、[ワークフローテンプレート](/ja/interface/features/template)から入手できます。
      テンプレート内に該当のワークフローが見つからない場合、ComfyUI のバージョンが古くなっている可能性があります。

      ワークフローを読み込んだ際にノードが欠落している場合の考えられる原因：

      1. 最新の ComfyUI（Nightly 版）を使用していない
      2. 起動時に一部のノードのインポートに失敗している
    </Tab>

    <Tab title="クラウドユーザー">
      * [Cloud](https://cloud.comfy.org) は、ComfyUI の安定版リリース後に更新されます。

      したがって、このドキュメントでコアノードが見つからない場合、それは新しいコアノードがまだ最新の安定版にリリースされていない可能性があります。次回の安定版リリースをお待ちください。
    </Tab>
  </Tabs>
</Tip>

**Gemma 4** は Google DeepMind による次世代の軽量オープン LLM ファミリーで、テキスト生成、画像理解、動画分析、音声文字起こし、構造化ツール使用のために設計されています。ComfyUI ではネイティブの **Text Generation** モデルとして統合されています。

**モデルのハイライト**：

* **マルチモーダル設計** — テキスト、画像、動画、音声入力を同時に受け付け可能
* **3 サイズから選択**：
  * **E2B（2B）** — 高速・軽量、コンシューマー GPU に最適
  * **E4B（4B）** — バランスの取れた性能、推奨デフォルト
  * **31B** — 最高品質、より多くの VRAM が必要
* **思考モード** — 回答生成前の段階的推論を内蔵
* **長いコンテキスト** — 最大 128K トークン（E2B/E4B）、256K トークン（31B）
* **多言語対応** — 35+ 言語を即座にサポート、140+ 言語で事前学習
* **関数呼び出し** — 構造化ツール使用とエージェント型ワークフローをネイティブサポート
* **ComfyUI ネイティブ** — 組み込みの `TextGenerate` ノードと `CLIPLoader` ノードで読み込み・実行

**関連リンク**：

* [Hugging Face (Comfy-Org/gemma-4)](https://huggingface.co/Comfy-Org/gemma-4)
* [Google AI for Developers](https://ai.google.dev/gemma)
* [ComfyUI ソースコード (nodes\_textgen.py)](https://github.com/Comfy-Org/ComfyUI/blob/master/comfy_extras/nodes_textgen.py)

## 利用可能なワークフロー

<h3 id="llm_gemma4_text_gen">
  Gemma 4：テキスト生成
</h3>

テキストプロンプトと、オプションで画像、オーディオ、またはビデオを入力します。設定可能な推論、コーディング、多言語サポートを備えたテキスト出力を生成します。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/llm_gemma4_text_gen-1.webp" alt="Gemma 4 テキスト生成ワークフローのプレビュー" />

<CardGroup cols={2}>
  <Card title="Comfy Cloud で実行" icon="cloud" href="https://cloud.comfy.org/?template=llm_gemma4_text_gen&utm_source=docs&utm_medium=referral&utm_campaign=gemma4">
    Comfy Cloud で開く
  </Card>

  <Card title="ワークフローをダウンロード" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/llm_gemma4_text_gen.json">
    JSON をダウンロード、またはテンプレートライブラリで "Gemma4: Text Generation" を検索
  </Card>
</CardGroup>

**入力素材**

これらの任意のファイルを対応するノードにアップロードします：

<CardGroup cols={2}>
  <Card title="the_lily_veil.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/the_lily_veil.png">
    `LoadImage` ノード 2 · `the_lily_veil.png`
  </Card>

  <Card title="voice_demo.mp3" icon="download" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/voice_demo.mp3">
    `LoadAudio` ノード 5 · `voice_demo.mp3`
  </Card>

  <Card title="video_wan_vace_inpainting_input_video.mp4" icon="download" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/video_wan_vace_inpainting_input_video.mp4">
    `LoadVideo` ノード 6 · `video_wan_vace_inpainting_input_video.mp4`
  </Card>
</CardGroup>

このワークフローは Gemma 4 のコアとなる**テキスト生成**機能を示しています。テキストプロンプトに加えて、オプションで画像、オーディオファイル、またはビデオを追加コンテキストとして受け付け、推論、コーディング、多言語プロンプトに対応した自然言語出力を生成します。

**入力**：

* **テキストプロンプト**：質問または指示
* **画像**（オプション）：視覚理解タスク用（OCR、物体検出、チャート読み取りなど）
* **オーディオ**（オプション）：音声認識または文字起こし用
* **ビデオ**（オプション）：フレームをまたいだビデオ理解用（内部で 1 FPS にサブサンプリング）

**主要な制御パラメータ**：

* **Max length**：生成する最大トークン数（デフォルト 256）
* **Sampling mode**：サンプリングのオン/オフを切り替え、temperature、top-k、top-p、繰り返しペナルティ、シードを調整
* **Thinking mode**：最終回答の前に段階的推論を有効化
* **Use default template**：モデル用の内蔵システムプロンプトを適用

**出力**：

* **Generated text**：モデルの応答をプレーンテキスト文字列として返します

<Card title="Subgraph について" icon="book-open" href="/ja/interface/features/subgraph">
  このワークフローは Subgraph ノードを使用してモジュール処理を実現しています。Subgraph ドキュメントでカスタマイズと拡張の方法を確認してください。
</Card>

## モデルのダウンロード

Gemma 4 モデルは ComfyUI ではテキストエンコーダー（text encoder）として読み込まれます。該当するモデルファイルをダウンロードし、正しいディレクトリに配置してください：

<Card title="Gemma 4 2B (E2B IT FP8)" icon="download" href="https://huggingface.co/Comfy-Org/gemma-4/resolve/main/text_encoders/gemma4_e2b_it_fp8_scaled.safetensors">
  高速・軽量、コンシューマー GPU に最適。
</Card>

<Card title="Gemma 4 4B (E4B IT FP8)" icon="download" href="https://huggingface.co/Comfy-Org/gemma-4/resolve/main/text_encoders/gemma4_e4b_it_fp8_scaled.safetensors">
  バランスの取れた性能。ワークフローのデフォルトモデル。
</Card>

<Card title="全バリアントを表示" icon="external-link" href="https://huggingface.co/Comfy-Org/gemma-4/tree/main/text_encoders">
  すべての Gemma 4 モデルウェイトを閲覧。
</Card>

ダウンロードした `.safetensors` ファイルを以下のディレクトリに配置してください：

```
📂 ComfyUI/
├── 📂 models/
│   └── 📂 text_encoders/
│       └── gemma4_e4b_it_fp8_scaled.safetensors
```
