TL;DR
A diffusion model generates data by learning to undo a corruption process. Training starts from real data and adds a little Gaussian noise at each of many steps until the result is pure noise. A neural network is then trained to look at a noisy input and predict the noise that was added, so that the process can be run backwards, from noise to a clean sample.
The forward process is fixed and needs no learning. All the learning is in the one denoising network, trained with a simple mean squared error, which is why diffusion models are stable to train compared with adversarial models.
Where you'll see it: in image generators such as Stable Diffusion and in video and audio synthesis, where a model starts from random noise and refines it into a picture or clip over a number of denoising steps.
Intuition
Learning to clean up a photograph
Imagine a photograph that has been slowly covered in static, a little at a time, until nothing of the picture is left. Each step of the static is small and easy to describe. Now imagine a model that has seen many such photographs at every stage of the damage. Given a slightly noisy image, it can say which part is noise and which part is picture. Subtract the noise it predicts, and the image becomes a little clearer.
Repeat that many times from pure static and an image appears. That is the whole idea. The model never has to draw a face in one go. It only has to make one small, reliable decision: how much of what it sees is noise.
Why does this work when a single jump from noise to image does not? Because the small steps stay close to a Gaussian shape, so the model's job at each step is simple and well posed. A sudden jump would require the model to invent a whole image from nothing, which is a far harder and more ambiguous question.
flowchart LR
X0[clean image x0] -->|add noise step 1| X1[x1]
X1 -->|add noise| X2[x2]
X2 -->|...| XT[pure noise xT]
XT -->|denoise with network| Y2[y2]
Y2 -->|denoise| Y1[y1]
Y1 -->|denoise| Y0[new sample]
The top row is fixed and known. The bottom row is what the trained network runs, from noise back to a sample.
- signal, sqrt of alpha-bar
- noise, sqrt of 1 - alpha-bar
The math
Setup
Let be a data point, such as an image flattened into a vector. The forward process adds noise over steps. A schedule with each says how much noise each step adds. Define and the running product .
Each step is a Gaussian draw from , where is the identity matrix:
The scaling shrinks the old signal slightly, so the total variance stays bounded and the process settles to a standard Gaussian.
The closed form for any step
Each step is linear and Gaussian, so composing of them gives a single Gaussian. The result is that we can jump straight to any step :
Equivalently, with noise ,
This is the key to training. We never run the chain step by step during learning. We pick a random , draw , and form in one line. The reparameterised form above is the same trick described in Reparameterization Trick.
The reverse process
The reverse chain is also modelled as Gaussian:
The true reverse step is hard to write down, but conditioning on it has a closed form. Its mean is a function of and the noise that produced it. This suggests parameterising the network to predict , so the mean becomes
Here is the denoising network, and is a fixed variance chosen from the schedule.
The training objective
Training comes from the evidence lower bound on the data log likelihood. Once the terms are rewritten using the closed forms above, the bound becomes a sum over steps of squared errors between the true noise and the predicted noise. Ho and colleagues found that dropping the per-step weights gives a simpler objective that trains better:
This is a Mean Squared Error loss. Each training step samples a data point, a time , and a noise draw, then takes a gradient step on the squared error.
Connection to score matching
The predicted noise is closely tied to the gradient of the log density of the noisy data, the score. For Gaussian noise, . A diffusion model is therefore a noise-level-indexed family of score models, which is why the same picture appears in the score-based formulation of Song and colleagues.
Worked examples
Take a single number as the data, , with schedule . Draw noise .
- Then and .
- Signal coefficient: , so the signal is .
- Noise coefficient: , so the noise is .
- Sum: .
- Interpretation: after one step the value moved only slightly toward the noise. Most of the signal survives, which is why the earliest steps are easy to undo.
Continue the same toy schedule to a second step with , so and . Take and noise . The forward draw is
- .
- .
- So .
- Suppose the network, given and , predicts . The loss term is .
- Interpretation: the gradient step nudges the network to predict more negative noise for inputs like this one. Averaged over many , and , these small corrections shape the whole denoising behaviour.
Tradeoffs and failure modes
Diffusion models give high sample quality and stable training. Their costs are in sampling speed and in the schedule and parameterisation choices.
| Situation | Problem | Better choice |
|---|---|---|
| Interactive generation | Hundreds of network calls per sample | Fewer-step samplers, or distillation into a faster model |
| Very high resolution images | Compute grows fast with pixel count | Work in a compressed space, as in [[latent-diffusion-model |
| Need exact likelihoods | Diffusion gives only a bound on the likelihood | Normalising flows, or accept the bound |
| Schedule too aggressive | Signal disappears too early and the model learns little at the end | Tune the schedule, for example a cosine schedule |
| Need a fast single-pass generator | Iterative sampling is the bottleneck | A GAN or a one-step student model |
Two failure modes are common. Sampling with too few steps or a poor variance choice gives blurry or washed-out outputs. Training on a small dataset can lead the network to memorise examples, which shows up as near-copies of the training set.
History
Sohl-Dickstein and colleagues proposed the idea in 2015, drawing on nonequilibrium thermodynamics and the way systems diffuse toward equilibrium. Their model was not competitive with the GANs of the time. In 2020 Ho, Jain and Abbeel showed that a simple reweighting of the bound, together with a U-Net denoiser, produced image quality that rivalled the best generative models, and the objective above became the standard recipe. Song and colleagues later unified the approach with score-based models and stochastic differential equations, which opened faster samplers. Latent diffusion moved the process into a compressed space and made large image generators practical on modest hardware.
Check yourself
QuestionRecall: what does the network predict?Show answer
The noise that was added to the clean data to produce the noisy input at step . The network receives and the time , and its output is compared with the true in the mean squared error loss.
QuestionCompute: with , and , what is ?Show answer
. Signal and noise have equal weight at this step, because gives equal coefficients on the two terms.
QuestionWhy: why can training pick a random instead of running the whole chain?Show answer
The closed form lets us sample any noise level directly from clean data. Each training example then costs one forward pass of the network, and random gives an unbiased estimate of the full objective summed over all steps.
QuestionApplied: you want the model to denoise faster at sampling time while keeping the same network. What can you change, and what does it cost?Show answer
Use a sampler that takes fewer, larger steps, such as a strided or ODE-based sampler, instead of all steps of the ancestral sampler. The network stays the same, and the cost is some loss of sample quality, because the larger steps approximate the reverse chain less accurately. Sampling quality should be checked against the full-step result on held-out prompts or inputs.