Skip to content

Diffusion Model

Learns to remove noise from images step by step. To generate, it starts from pure static and denoises it into a brand new image.

Also denoising diffusion · DDPM · latent diffusion · score-based model

Fig. / How it works
REMOVE A LITTLE NOISE, STEP BY STEP
Domain 06
Generative AI
Role · kind
Models and algorithmsModel
Level
Advanced

Sohl-Dickstein et al., 2015; Ho et al. (DDPM), 2020

Imagine a sculptor who starts with a rough block of marble and chips away a little at a time until a statue appears. A diffusion model does that with static: it chips away noise, step by step, until a picture appears.

Where it fits

Not shown: 1 more that build on it. See the full list below.

+All relationships as a list

See it on the full map

Try it

From noise to data: diffusion, exactly
Loading interactive widget…
TakeawayDestroying data with noise is easy and needs no learning. A diffusion model learns to undo it one small step at a time, and guidance pushes each step harder toward what you asked for.

How it works

Destroying an image is easy: add a bit of random noise, then a bit more, and after enough steps you have pure static. That is the forward process, and it needs no learning.

A diffusion model learns to run the film backward. Training is simple:

  1. Take a real image and a random step number tt.
  2. Add the amount of noise that belongs to step tt.
  3. Ask the network: what noise was added? Compare with the truth and update.

After training on millions of images, the network is an expert denoiser at every noise level. To generate, start from pure random noise and repeatedly subtract the predicted noise, a little at a time. Each step makes the image slightly cleaner, and after dozens of steps a new image emerges that never existed in the training set.

Text conditioning: feed a text description into the denoiser (through attention layers), and it learns to denoise toward images that match the text. Classifier-free guidance exaggerates the difference between “denoise with the prompt” and “denoise without it”, trading variety for prompt-faithfulness.

Latent diffusion: running hundreds of steps on full-size images is expensive, so models like Stable Diffusion first compress the image with an autoencoder (see VAE) and do the diffusion in that small latent space.

The math

The forward process has a closed form, with noise schedule αˉt\bar\alpha_t:

xt=αˉt x0+1−αˉt ϵ,ϵ∼N(0,I)x_t = \sqrt{\bar\alpha_t}\, x_0 + \sqrt{1 - \bar\alpha_t}\, \epsilon, \qquad \epsilon \sim \mathcal{N}(0, I)

The network ϵθ\epsilon_\theta is trained with the simple loss

L=Ex0,t,ϵ[∥ϵ−ϵθ(xt,t)∥2]\mathcal{L} = \mathbb{E}_{x_0, t, \epsilon}\big[\lVert \epsilon - \epsilon_\theta(x_t, t) \rVert^2\big]

Everyday use cases

  • Case 01

    Text-to-image

    Turn "an astronaut riding a horse" into a picture.

  • Case 02

    Photo editing

    Fill in removed objects, extend a photo beyond its borders, change the style.

  • Case 03

    Video and audio

    The same idea, extended through time, generates video clips and sound.

Famous examples

Strengths, weaknesses and when to use it

Strengths

  • High-quality, diverse samples.
  • Stable training compared with GANs.
  • Easy to condition on text, images or sketches.

Weaknesses

  • Slow sampling: many denoising steps per image (though distillation and better samplers cut this a lot).
  • Expensive to train.

When to use itThe default choice for high-quality image, video and audio generation.

Compare with

Check yourself

  1. Q01

    What does the network in a diffusion model learn to predict during training?

    Show answer

    B: The noise that was added to the image

  2. Q02

    Where does generation start?

    Show answer

    B: From pure random noise

  3. Q03

    What does latent diffusion change?

    Show answer

    A: It runs the diffusion in a compressed latent space instead of on full-size pixels

Go deeper