Diffusion models

From Noise to Pictures

16 September 2026 · 9 min read

Tools like Stable Diffusion and DALL·E can turn a sentence into a detailed picture in seconds. Under the hood, most of them rely on the same surprisingly simple idea: learn how to remove noise, then start from pure noise and keep removing it.

This post walks through how that works, using pictures first and maths only where it helps.

The big idea: learn to clean up noise

Take any photo, say of a cat, and sprinkle a little random static over it. Do that again, and again. After enough rounds the photo is gone and all that is left is noise, like an old TV with no signal.

Going that way is easy and needs no intelligence at all. Going the other way, from static back to a picture, is the hard part, and that is exactly what a diffusion model learns to do. It never learns to make a picture in one go. It only learns to make a noisy picture slightly less noisy.

Five copies of a small cat picture, going from clean to completely noisy. Adding noise goes left to right; the model learns to go right to left.Forward: add a little noise each step (simple, no learning)step 02505007501,000Reverse: remove a little noise each step (what the model learns)
Training data is destroyed on purpose: a little noise is added at every step until nothing is left (violet). The model learns to undo one small step at a time (blue). To create a new image, it starts from pure noise and runs the blue arrow.

Once a model can take one small step from noisier to cleaner, you can chain hundreds of those steps together. Start from pure static, step, step, step, and an image appears. Because the starting static is random, you get a different image every time.

Step one: destroying images on purpose

During training, we take real images and add noise to them according to a fixed recipe, called a noise schedule. Early steps add only a whisper of noise; by the last step (often step 1,000) the image is indistinguishable from pure static.

A handy shortcut: we never need to add noise a thousand times in a row. There is a formula that jumps straight to any step tt by mixing the clean image x0x_0 with fresh noise ϵ\epsilon:

xt=αˉt x0+1−αˉt ϵx_t = \sqrt{\bar{\alpha}_t}\, x_0 + \sqrt{1 - \bar{\alpha}_t}\, \epsilon

You can read it as a slider. The number αˉt\bar{\alpha}_t says how much of the original image survives at step tt: close to 1 at the start, so it is mostly image; close to 0 at the end, so it is mostly noise.

Step two: learning to guess the noise

Here is the clever part. Instead of asking the network “what should the clean image look like?”, we ask an easier question: “which noise was added to this image?” If it can answer that, we can subtract the noise and get a cleaner image.

A clean image plus random noise makes a noisy image. The denoising network looks at the noisy image and guesses the noise. Its guess is compared with the real noise, and the difference trains the network.clean image+random noise=noisy imageDenoisingnetworkguesses the noiseits guesscomparethe difference (error)is what trains the network
One training step. Take a real image, mix in random noise, and ask the network to guess exactly which noise was added. The gap between its guess and the real noise is the error it learns from. Repeat millions of times, at every noise level.

The network is usually a U-Net or a transformer. It is also told how noisy the image is (the step number), and optionally a description of what the image shows, such as a text prompt. Training simply measures how far its guess is from the real noise, and nudges it to do better:

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

In words: average, over many images, noise samples and steps, the squared gap between the true noise ϵ\epsilon and the network’s guess ϵθ\epsilon_\theta. The cc is the optional description, such as text, a class label, a pose or another image.

Step three: making a brand new image

To generate, we start from pure random noise, xT∼N(0,I)x_T \sim \mathcal{N}(0, \mathbf{I}), and repeat: ask the network for its noise guess, remove a bit of it, move to the next step. The early steps decide the big picture (where the cat sits, roughly what colours); the late steps add edges, texture and fine detail.

The original method (DDPM) needs many steps, so it is slow. A later method (DDIM) showed the same trained network can take far fewer, larger steps. Modern samplers keep playing with the same trade-off: fewer steps are faster, more careful steps can look better.

Steering it with a prompt

Text-to-image tools turn your prompt into numbers and feed them to the network at every step, so its noise guesses lean toward images that fit the description.

A trick called classifier-free guidance makes the steering stronger. The network makes two guesses, one with your prompt and one without, and the tool pushes further in the direction where they differ. Turn that knob up and images follow the prompt more literally; turn it too far and they become flat, over-saturated and all alike.

A chart with guidance strength on the horizontal axis. How well the image matches the prompt rises and then levels off. Variety and natural look fall as guidance increases. A shaded sweet spot sits in the middle.matches the promptvariety & natural looksweet spotlowhighGuidance strength
Illustrative, not measured. Turning guidance up makes images follow the prompt more closely, but too much makes them look samey and over-processed. Most tools default to somewhere in the middle.

Why most models work in a smaller space

Running hundreds of denoising steps on every pixel of a large image is expensive. Latent diffusion first compresses the image into a much smaller grid of numbers using an encoder, does all the denoising there, and only at the end turns the result back into pixels with a decoder.

A 512 by 512 image, 786,432 numbers, is encoded into a 64 by 64 latent of 16,384 numbers. Diffusion runs on the latent, then a decoder produces the full image again.image, 512×512786,432 numbersencoderdenoising runs herelatent, 64×6416,384 numbersdecodernew imagefull size again48× fewer numbers to process at every step
Latent diffusion, the approach behind Stable Diffusion. An encoder squeezes the image into a much smaller grid of numbers, all the denoising happens there, and a decoder turns the result back into a full-size image.

The compression throws away detail you would barely notice while keeping the layout and meaning of the image, which makes training and generation far cheaper. The catch: anything the compression threw away can never come back, so the decoder sets a ceiling on how sharp the final image can be.

What can go wrong

  1. It is slow by design. Each step depends on the one before, so generating an image takes many passes through the network, not one.
  2. A prompt is a nudge, not a contract. Guidance steers toward likely images; it does not guarantee the right number of fingers, exact text or correct facts.
  3. The data shows through. Biases, gaps and duplicated images in the training set can reappear in what the model makes, sometimes as near-copies.
  4. Good scores are not the whole story. Common metrics check that images look realistic overall, not that they are accurate, original or safe.

The mental model

A diffusion model is a very good noise remover. Training teaches it to clean up a slightly noisy image at every level of noise. Generation chains those small clean-ups together, turning random static into a picture one step at a time.

Everything else, from samplers and guidance to latent spaces and prompts, is about where that journey happens and how firmly we steer it.

References

  1. Ho, Jain, and Abbeel. Denoising Diffusion Probabilistic Models (2020). Paper
  2. Song, Meng, and Ermon. Denoising Diffusion Implicit Models (2020). Paper
  3. Ho and Salimans. Classifier-Free Diffusion Guidance (2022). Paper
  4. Rombach et al. High-Resolution Image Synthesis with Latent Diffusion Models (2022). Paper