📖

拡散モデル とは?

Stable Diffusion、Imagen、DALL·E 3による画像生成の基盤となる生成AI技術である拡散モデルについて、わかりやすく解説するガイドです。

拡散モデル(diffusion model)とは、段階的なノイズ付与プロセスを逆向きに実行することを学習することで、新しいデータ(通常は画像、音声、動画)を生成するタイプの生成AIです。訓練時には、実例の画像に多数の小さなステップで段階的にガウスノイズを付加していき、その各ステップで付加されたノイズをニューラルネットワークに予測させます。訓練が完了したモデルは、純粋なランダムノイズから出発し、それを反復的に「デノイズ(ノイズ除去)」することで、テキストプロンプトによって導かれた写実的な画像のような、首尾一貫した新しいサンプルを生成できます。

拡散モデルの仕組み

訓練は互いに結びついた2つのフェーズで行われます。フォワードプロセス(forward process)では、 clean な訓練画像に対し、固定数のタイムステップ(多くは1,000回)にわたって少しずつランダムノイズを加え、静止画と区別がつかなくなるまで劣化させます。リバースプロセス(reverse process)では、ニューラルネットワーク(通常はU-Net)が各タイムステップで付加されたノイズを推定し、それを減算してクリーンな画像へ逆方向に進む方法を学習します。

推論時には、純粋なガウスノイズのサンプルから生成が開始されます。モデルはそれを段階的にノイズ除去し、クリーンな画像が現れるまで繰り返します。プロンプト「a corgi on a skateboard」を画像にするなど、生成を条件付きにするために、テキストエンコーダ(CLIPやT5モデルなど)がプロンプトを埋め込みベクトルに変換し、拡散ネットワークはその埋め込みに注意を向けながらデノイズするように学習します。2022年に導入されたClassifier-free Guidance(分類器なし誘導)は、同じモデルに無条件でのデノイズも学習させ、その2つの予測を外挿することで、出力がプロンプトにどれだけ忠実であるかを強めます。

なぜ重要なのか

拡散モデルは、Stable Diffusion、DALL·E 3、Midjourney、GoogleのImagenといった今日の主要なテキスト→画像システムのバックボーンです。GANなど従来の生成手法と比べて、より高精細で多様なサンプルを生成する傾向があり、反復的なサンプリングによりテキスト・深度マップ・スケッチなどの信号で条件を付けることが容易です。画像以外にも、音声(DiffSingerなど)、動画、タンパク質構造(RoseTTAFold All-Atomなど)、3D形状生成など幅広いモデルに同じ手法が適用されており、拡散は現代のAIにおいて最も汎用性の高い生成フレームワークの一つとなっています。

拡散モデルの主な種類

  • Denoising Diffusion Probabilistic Models(DDPM) — Hoら(2020)による基礎的な定式化で、生成をガウスノイズの反復的なノイズ除去として捉えます。
  • Denoising Diffusion Implicit Models(DDIM) — 非マルコフ的なステップを用いることで、再学習なしに推論時間を短縮する高速なサンプラーです。
  • Latent Diffusion Models(LDM) — Stable Diffusionで広く普及した方式で、ピクセル空間ではなく圧縮された潜在空間で拡散プロセスを実行し、計算量を大幅に削減します。
  • スコアベースモデル(SDE) — 拡散とスコアマッチングおよび確率微分方程式を結びつける連続時間の視点で、柔軟なサンプラーを可能にします。
  • Rectified Flow / Flow Matching — ノイズからデータへのより直線的な経路を学習し、はるかに少ないステップで生成できる新しい派生手法です。

より深く技術的に学びたい方は、Ho、Jain、AbbeelによるDDPMの原著論文と、RombachらによるLatent Diffusionの論文が標準的な出発点です。要するに、拡散モデルは生成を「多くの小さく学習可能なノイズ除去ステップ」に分解する、シンプルな発想でありながらクリエイティブAIを再定義した手法です。

よくある質問

How is a diffusion model different from a GAN?
GANs train a generator and discriminator in opposition and produce a sample in a single forward pass, which can be fast but often unstable. Diffusion models instead train a single network to iteratively denoise, which tends to yield more diverse and higher-quality samples at the cost of slower generation. Most modern image generators have moved from GANs to diffusion for this reason.
Why do diffusion models need so many steps to generate an image?
Each step only removes a small amount of noise, so the network can stay accurate across all noise levels. Modern samplers like DDIM, DPM-Solver, and rectified-flow variants can produce good images in 4 to 20 steps, but very few-step sampling can reduce fine detail. Step count is a trade-off between speed, quality, and prompt fidelity.
What does "guidance scale" mean in diffusion models?
Guidance scale controls how strongly the output is pushed toward the text prompt. The model runs both a conditional prediction (with the prompt) and an unconditional one, then extrapolates between them; a higher scale means the prompt has more influence, producing sharper but sometimes less natural images, while a lower scale gives more creative but looser results.
Are diffusion models only used for images?
No. The same denoising framework has been applied to audio and music generation, video synthesis, 3D shape and texture generation, molecular and protein design, and even planning in reinforcement learning. Anywhere data can be progressively noised and learned, diffusion tends to be a viable generative approach.