The Problem, Then the Trick
Generating an image means choosing the colour of hundreds of thousands of dots so that the whole thing looks like something. Nobody knows how to write such a function directly. The trick behind diffusion models is to swap that impossible problem for an easy one, repeated.
The easy problem: hand the network an image slightly spoiled by noise and ask it to identify the noise that was added. This is ordinary supervised learning, because we know the answer, we are the ones who added the noise.
Once the network can do that, we run it backwards. We start from an image made entirely of noise (television static) and ask the network to take some of it away. Then a little more. After a few dozen passes there is no noise left, and what remains is an image. It matches no existing photograph: it was manufactured by the sequence of subtractions.
A language model writes one token after another: it produces a word, appends it to what it has already written, and starts again. What is written is final.
A diffusion model does nothing of the kind. No piece of the image is produced and then frozen: at every step the entire image is revised at once, slightly sharper than at the previous step. The number of steps has nothing to do with the size of the image, the same image can be generated in 1,000 steps or in 20.
So the left-to-right mental picture is simply wrong here. The right picture is a photograph developing in a tray: blurry everywhere, then slightly less blurry everywhere, then sharp.
This page assumes you already have the basic noising/denoising mechanism, laid out step by step in Diffusion Models: Fundamental Principles. Here we focus on the three building blocks you will meet by name in papers and in software: DDPM, DDIM and classifier-free guidance.
DDPM: The Founding Model
DDPM stands for Denoising Diffusion Probabilistic Models. This is the paper that made the method competitive.
Denoising Diffusion Probabilistic Models (Ho, Jain, Abbeel, 2020)One Direction: Spoiling the Image
The forward direction is the one that spoils the image. It involves no neural network at all: it is a fixed recipe, decided in advance.
Every symbol, in order:
- : the image as it stands at the previous step; : the image after the current step. is the original, untouched photograph.
- : the noising recipe. It is written as a probability distribution because the noise is drawn at random each time.
- : the normal distribution, the bell curve. "Drawing from " means: pick a number at random, usually close to the centre, rarely far from it. The two arguments after the semicolon are the centre and the spread.
- : how much noise is added at step . A small number fixed in advance, not a learned value.
- : the factor by which the image is shrunk before the noise is added.
- : the identity matrix. Its presence simply means the noise is drawn independently for each dot of the image, with the same spread everywhere.
The one-sentence reading: at each step, shrink the image a little and add a little noise in its place.
Why shrink? Otherwise the values would swell without bound. The pair and is chosen so that what shrinking removes is exactly what noise puts back: the total spread of the image stays constant throughout. That is where the square root comes from, spreads combine by adding squares, so to remove worth of spread you multiply by , not by .
Repeated long enough, this recipe erases everything. The paper fixes 1,000 steps and grows linearly from 0.0001 to 0.02, two values that appear verbatim in its experimental section. By the end nothing of the image survives: only noise.
The Other Direction: Repairing the Image
Here, and only here, does a neural network come in. We ask it to learn the reverse path.
- : the Greek letter theta, which by convention denotes the network's learned weights. A subscript therefore means "computed by the trained network", as opposed to the fixed recipe above.
- : the Greek letter mu, the centre of the bell. This is what the network produces: given the noisy image and the step number , it offers its best estimate of the image one notch less noisy.
- : the Greek letter sigma squared, the spread of the leftover noise at that step. In the paper this is not learned: it is fixed from the values.
- really is an input to the network. One single network serves all 1,000 steps; we tell it each time where it stands, because removing noise from an almost-clean image is not the same job as removing it from an almost-pure-noise image.
The one-sentence reading: the network takes a noisy image and a step number, and returns the same image one notch cleaner.
Training: A Single Line
- : the loss, the number training tries to make as small as possible.
- : the Greek letter epsilon, the noise that was actually added. We know it, since we drew it ourselves.
- : the noise the network thinks it recognises in image at step .
- : the sum of squared differences, dot by dot. A way of measuring "how far apart" two images are as a single number.
- : the expectation, that is, the average, over all training images and all randomly drawn step numbers.
The one-sentence reading: take a photograph, add a known amount of noise at a randomly chosen step, and score the network on how well it points out that noise. That is the whole of training.
Notice that we never asked the network to "draw a cat". We only taught it to recognise noise. The ability to generate is a side effect of that skill, and that is the whole elegance of the method.
The Awkward Consequence: Slowness
DDPM's generation recipe walks the 1,000 steps one at a time, and each step needs a full call to the network. There is nothing to parallelise: step 999 needs the result of step 1,000.
This is the central flaw of the original DDPM, and it cannot be quoted in seconds in any universal way, that depends entirely on the network and the hardware. What can be quoted is the number of network calls: 1,000, against 1 for a generative adversarial network of the same era.
DDIM: Cutting the Number of Steps
DDIM stands for Denoising Diffusion Implicit Models.
Denoising Diffusion Implicit Models (Song, Meng, Ermon, 2020)The Decisive Observation
In DDPM every reverse step carries a share of randomness: a fresh noise of spread is drawn. DDIM shows you can build a family of processes that lead to exactly the same training objective as DDPM, but whose reverse path can be made entirely deterministic, by setting .
Two consequences follow:
- Nothing to retrain. A model already trained the DDPM way can be sampled the DDIM way. This is why image-generation software offers the sampling method in a dropdown menu: it is decided after training.
- Steps can be skipped. Instead of walking 1,000, 999, 998…, you walk 1,000, 950, 900…, stopping at only a small fraction of the steps.
The paper measures, in wall-clock time, generation 10 to 50 times faster than DDPM at comparable quality. That figure comes from the paper's own abstract; "comparable quality" there is measured by FID, the Fréchet Inception Distance, an automatic similarity score between a batch of generated images and a batch of real ones, to be read with the caveats set out in How to Read a Benchmark Score.
What Determinism Buys on Top
- Reproducibility: same starting noise, same output image, every time. Without it, comparing two settings would be impossible, since the observed gap could come from chance alone.
- Inversion: because the path is deterministic and reversible, you can run it from a real photograph back to the noise that would have produced it, change the text prompt, then run forward again. This is the foundation of diffusion-based image editing.
The literature often describes DDPM and DDIM as two versions of the same continuous journey: a stochastic differential equation, abbreviated SDE, when the journey carries randomness at every instant, and an ordinary differential equation, abbreviated ODE, when it does not. "Differential" here means: we describe not the position, but the way it changes.
Seen that way, DDPM samples an SDE and DDIM samples the matching ODE, and the number of steps is merely how finely the journey is chopped up. The full framework, with score functions, is covered in Score-Based Models and Flow Matching.
The Noise Schedule
The noise schedule is the sequence of values, that is, the decision of how fast the image is destroyed in the forward direction. It is taken before training and is not learned.
- Linear: grows in a straight line from 0.0001 to 0.02. This is the original DDPM paper's choice.
- Cosine: follows a cosine curve, which destroys information more evenly. This variant comes from the Improved DDPM paper, where it is proposed precisely because the linear schedule destroys information too fast early on for small images.
- Scaled linear: the variant used in the Stable Diffusion code.
The schedule matters because it decides what the network spends its training time on. If it destroys everything in the first few steps, nearly every training step deals with an already unreadable image, and the network learns fine detail poorly.
Classifier-Free Guidance (CFG)
CFG stands for classifier-free guidance. It is the setting that image-generation interfaces call the guidance scale, and that everybody adjusts.
Classifier-Free Diffusion Guidance (Ho and Salimans, 2022)Where the Name Comes From
The earlier method, classifier guidance, required training a second network: a classifier able to say "this is a dog", whose gradient was used to push the image toward the right category. Two networks to train, one of them on noisy images.
Classifier-free guidance gets rid of that second network. Hence the name: you obtain the classifier's effect without a classifier.
The Mechanism
During training, the text prompt is erased in a fraction of the examples and replaced by an empty prompt. The same network therefore learns two jobs at once:
- with the text, it predicts a noise that leads toward the requested image, written ;
- without the text, it predicts a noise that leads toward any plausible image, written , for unconditional.
The paper tries erasing the prompt 10%, 20% and 50% of the time, and concludes that 50% consistently degrades results compared with 10% or 20%. The 10-to-20% figure in common use therefore comes straight from that measurement.
At generation time the network is called twice per step, once with the text and once without, and the two are combined:
- : the network's prediction ignoring the prompt.
- : its prediction taking the prompt into account.
- : the difference between the two, which is precisely the text's contribution. Everything the text changes, and nothing else.
- : the factor by which that difference is amplified.
- : the noise finally removed at that step.
The one-sentence reading: measure what the text changes, then exaggerate it.
The price is visible in the formula: two network calls per step instead of one, so twice the computation for the same image.

Careful: Two Rival Numbering Conventions
This is a permanent source of confusion when reading papers and documentation.
- With the formula above, the one used by image-generation software, means "no amplification": the difference term is taken as is and you land back on . And deletes the prompt entirely.
- The original paper writes the same thing with the factor shifted by 1, so that in its notation means "no amplification". Its experimental sweep runs from 0 to 4, which corresponds to 1 to 5 in the software convention.
So "guidance 7" in one source and "guidance 7" in another do not necessarily denote the same thing. Always check which value corresponds to no guidance at all.
Setting the Factor in Practice
Be clear about the status of these values: they are conventions of use, not measured results. No paper establishes that a guidance of 7.5 is optimal.
The only solid landmarks are the qualitative behaviour, visible in the image below, and the default written into the tooling: Hugging Face's Diffusers library ships its Stable Diffusion pipeline with a factor of 7.5, and it is that default which became the conventional starting point, not because it won a comparison, but because it is in the code.
- Too low, and the image largely ignores the prompt and turns generic.
- Too high, and the prompt is followed but colours saturate and repetitive textures appear.

Start from your tool's default. If the image is generic and follows the prompt poorly, go up. If it has garish colours or repeating patterns, go down. It is the setting whose visual effect is most immediate, hence the first one to touch, but there is no universally good value, and the scale differs from one model to the next.
Latent Diffusion: The Optimisation That Made This Accessible
The Problem: Diffusing on Pixels Costs Too Much
Let us count. A 512-by-512 image, with three colour channels, red, green, blue:
Every denoising step has to process those 786,432 values. And there are dozens of steps.
The Solution: Compress First
High-Resolution Image Synthesis with Latent Diffusion Models (Rombach et al., 2021)Instead of diffusing on pixels, we diffuse in a latent space, a compressed representation space produced by an autoencoder. "Latent" simply means: not directly visible.
- The encoder of a VAE (variational autoencoder, detailed in Variational Autoencoders) shrinks the image from 512×512×3 down to 64×64×4, that is 16,384 values.
- Diffusion, with everything described above, operates on those 16,384 values.
- The VAE's decoder rebuilds the visible image from the result.
The reduction factor derives itself in front of you:
48 times fewer values to process at each step. Be careful about what that number says exactly: it counts values, not operations. The real per-step cost does not fall by exactly 48, since it also depends on the network's structure, and you must add the cost (paid only once) of the encoder and decoder. But the order of magnitude of the gain is right, and it is what moved image generation from the datacentre to the consumer graphics card.
Where the Text Comes In
This architecture is also where the text prompt is injected, by cross-attention at every stage of the denoising network. That mechanism is covered in Text-to-Image.

Flow Matching: The Formulation That Replaced DDPM
Flow matching reframes the problem. Rather than defining a noising recipe and then learning to walk it back, you pick a path directly between the noise distribution and the image distribution (most often a straight line) and train the network to predict, at every point, the velocity at which to move along that path.
Flow Matching for Generative Modeling (Lipman et al., 2022)The advantage is easy to see: if the path is a straight line, a large stride stays on the path. With a winding path, a large stride runs off the road. This is why models trained this way tolerate very-few-step generation far better.
Stable Diffusion 3 is built on this formulation, and its paper compares it against several classic diffusion variants:
Scaling Rectified Flow Transformers for High-Resolution Image Synthesis (Esser et al., 2024)Where the Field Stands
The current lines of work, without figures we could not source:
- Step count: distillation aims to bring generation down to a handful of steps, or even a single one.
- Control: ControlNet imposes a structure, a character's pose, the outlines of a drawing; IP-Adapter imposes resemblance to a reference image.
- Architecture: diffusion transformers (DiT) are gradually replacing U-Nets.
- Training: flow matching is gradually replacing DDPM.
"I type a sentence, I get an image" hides everything above. For a user, that does not matter. For anyone who has to read a paper or compare two systems, the distinction between what is fixed in advance (the noise schedule, the number of steps, the guidance factor), what is learned (the denoising network's weights, the VAE's) and what is computed on the fly (the noise predictions at each step) is exactly what lets you see what a system actually adds.
1. How does a diffusion model build its image, compared with a language model?
2. What is the network of a diffusion model actually trained to do?
3. A team trained a model the DDPM way and wants faster generation with DDIM. What must they do?
4. A documentation page states that a guidance factor of 7.5 is « optimal ». What is the real status of that value?
5. In the full Stable Diffusion pipeline, which of these elements is learned during training?