Diffusion Models are the class of generative models that learn to reverse a gradual noising process — training a neural network to iteratively denoise random Gaussian noise back into realistic data samples, achieving state-of-the-art image generation quality that has surpassed GANs in fidelity, diversity, and training stability.
Forward Diffusion Process:
- Noise Schedule: progressively add Gaussian noise to data over $T$ timesteps (typically $T=1000$) — $x_t = \sqrt{\bar\alpha_t}x_0 + \sqrt{1-\bar\alpha_t}\epsilon $ where $\bar\alpha_t$ decreases from 1 to $\sim 0$; by $t=T, x_T \approx N(0,I)$ pure noise
- Variance Schedule: $\beta_t$ controls noise added at each step — linear schedule (β₁=10⁻⁴ to $\beta_T=0.02$), cosine schedule (smoother transition, better for high-resolution), or learned schedule
- Markov Chain: each step depends only on the previous step — $q(x_t|x_{t-1}) = N(x_t; \sqrt{1-\beta_t}x_{t-1}, \beta_{tI})$; forward process has no learnable parameters
- Closed-Form Sampling: $x_t$ can be computed directly from $x_0$ at any $t$ without sequential simulation — key efficiency trick for training: sample random $t$, compute $x_t$, predict noise
Reverse Denoising Process:
- Noise Prediction Network: U-Net (or Transformer) $\epsilon _\theta (x_t, t)$ trained to predict the noise $\epsilon $ added to $x_0$ to produce $x_t$ — loss $= \lVert{\epsilon - \epsilon _\theta (x_t, t)}\rVert^2$ averaged over random $t$ and random noise $\epsilon $
- Score Matching Equivalence: predicting noise is equivalent to estimating the score $\nabla_x \log p(x_t)$ — score function points toward higher data density; denoising follows the gradient of log-probability
- Sampling: starting from $x_T \sim N(0,I)$, iteratively denoise: $x_{t-1} = (1/\sqrt{\alpha }_t)(x_t - (\beta _t/\sqrt{1-\bar\alpha_t})\epsilon _\theta (x_{t,t})) + \sigma_t z$ — each step removes predicted noise and adds small random noise for stochasticity
- Accelerated Sampling: DDIM (deterministic implicit sampling) reduces 1000 steps to 50-100 — DPM-Solver and consistency models further reduce to 1-4 steps while maintaining quality
Guidance and Conditioning:
- Classifier Guidance: use a pre-trained classifier's gradient to steer generation toward a target class — ε̃ = ε_θ(x_t,t) - s∇_x log p(y|x_t); guidance scale $s$ controls class adherence vs. diversity
- Classifier-Free Guidance (CFG): train unconditional and conditional models together (randomly dropping conditioning) — guided prediction $= (1+w)\epsilon _\theta (x_{t,t,c}) - w\epsilon _\theta (x_{t,t})$ where $w$ controls guidance strength; eliminates need for separate classifier
- Text-to-Image (Stable Diffusion): diffusion in learned latent space of a VAE — CLIP text encoder provides conditioning; $4\times $ compressed latent space enables high-resolution (512-1024px) generation at reasonable compute cost
- ControlNet: adds spatial conditioning (edges, depth, pose) to pre-trained diffusion models — trainable copy of encoder with zero-convolution connections; preserves original model quality while adding precise spatial control
Diffusion models represent the current frontier of generative AI — powering Stable Diffusion, DALL-E, Midjourney, and Sora with unprecedented image and video generation quality, fundamentally changing creative workflows and establishing new benchmarks in generative modeling that GANs and VAEs could not achieve.