Skip to content
ExamSpine

How diffusion models work

A diffusion model learns to remove noise from an image, a little at a time. Run that backwards from pure noise and a new picture appears.

Challenge 1SL and HL

The big idea

Take a photo and add a tiny amount of random noise. It still looks like the photo. Add a little more, and a little more, hundreds of times, and eventually you have static that looks like nothing at all.

Key idea: A diffusion model is a neural network trained to undo one small step of that noising. If it can take a slightly noisy image and guess what the noise was, you can subtract that guess and get a slightly cleaner image. Repeat from pure static, and the model "finds" an image that was never in the training data.

The forward process: adding noise

The forward process is fixed. Nothing is learned here.

  • Start with a training image.
  • At each of many steps (often around 1,000 in training), add a small amount of Gaussian noise: random values drawn from a bell-curve distribution.
  • A noise schedule decides how much noise each step adds. By the last step the image is indistinguishable from pure noise.

Because the noise is added by a known formula, the training program can jump straight to any step: "give me this image at step 400" is one calculation, not 400. That makes training efficient.

The reverse process: learning to denoise

Training repeats one simple lesson millions of times:

  1. Pick a training image and a random step number.
  2. Add the right amount of noise for that step, and remember exactly what noise was added.
  3. Give the network the noisy image and the step number. It predicts the noise.
  4. Compare the prediction with the real noise (a loss such as mean squared error) and adjust the weights a little by backpropagation and gradient descent.

Key idea: The network never learns to draw a sofa directly. It learns what noise looks like, at every noise level. That is an easier, very well-defined task, which is a big reason diffusion training is stable.

Generating a new image (sampling)

To make a new image:

  1. Start from an image of pure random noise. A seed decides that starting noise, so the same seed, prompt and settings give the same image again.
  2. Ask the network to predict the noise, and remove part of it.
  3. Repeat for a number of sampling steps.

The original methods used as many steps as training (around 1,000). Modern samplers get good images in roughly 20 to 50 steps, and distilled models in 1 to 4. Key idea: Every step is a full pass through a large network, so the number of steps is the main reason diffusion is slower than a GAN.

Steering it with a text prompt

A diffusion model on its own makes a random plausible image. To follow a prompt:

  • A separate text encoder turns the prompt into a list of numbers (an embedding) that captures its meaning.
  • The denoising network receives that embedding at every step, usually through cross-attention layers, so its noise predictions pull the image towards the description.
  • Classifier-free guidance compares the prediction with and without the prompt and pushes further in the prompt's direction. A higher guidance scale follows the prompt more closely, but images become less varied and can look overcooked.

Most current systems also work in a compressed latent space rather than on pixels. An autoencoder compresses training images into a small latent grid; generation denoises in that grid and the decoder expands the result to pixels at the end, which makes every step far cheaper. That is a hybrid design, covered in the HL topic on hybrid models.

Key terms

Diffusion model
A generative model trained to remove noise from images a step at a time. It creates new images by denoising pure random noise.
Forward process
The fixed process of adding noise to a training image over many steps until it becomes pure noise.
Reverse process
The learned process of removing noise step by step, used to generate images.
Noise schedule
The rule that sets how much noise is added at each step of the forward process.
Gaussian noise
Random values drawn from a normal (bell-curve) distribution, added to images in the forward process.
Sampling steps
The number of denoising passes used to generate one image. More steps is slower but can add detail.
Seed
The number that sets the random starting noise. The same seed, prompt and settings give the same image.
Text encoder
The model that turns a prompt into an embedding the image network can use.
Embedding
A list of numbers that represents the meaning of something, such as a text prompt, so a network can use it.
Cross-attention
Layers that let each part of the image being denoised look at the prompt's embedding, so the text steers the image.
Classifier-free guidance
A technique that compares the denoiser's prediction with and without the prompt and pushes further towards the prompt. Its strength is the guidance scale.
Latent space
A compressed space of numbers that represents images; nearby points give similar images.

See all 65 terms in the glossary

Exam-style questions

In the style of Paper 1 Section B. Write your answer first, then open the marking points and mark yourself honestly. The questions use our own company, Hearth & Oak: an online furniture shop that wants to generate room scenes around its products.

Worked example · Explain · AO2

[4 marks]

Hearth & Oak wants customers to get the same room image if they press "Generate" twice with the same description. Explain how a diffusion model can produce the same image twice, and why it usually produces a different one.

How to approach it

"Explain" needs reasons, not just facts. The question has two halves (same and different), so plan at least one point for each. The key link is: random starting noise, which is set by a seed.

0 words

Marking points and model answer

A model answer

A diffusion model starts every generation from an image of random noise and removes noise from it step by step. If the starting noise is different, the model is guided to a different final image, so pressing "Generate" twice normally gives two different rooms. The starting noise is produced from a seed. If Hearth & Oak stores the seed and uses it again with the same prompt and the same sampler settings, the starting noise is identical, and because the seed also fixes any randomness used during the denoising steps, the final image is the same.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: Generation starts from an image of random noise. (1 mark)
  • Point 2: Different starting noise is denoised into a different image, so by default each press gives a different result. (1 mark)
  • Point 3: The starting noise comes from a seed; keeping the same seed (and prompt and settings) gives the same starting noise. (1 mark)
  • Point 4: The same seed also fixes any random noise added during sampling (or the sampler is deterministic), so the same starting noise gives the same final image. (1 mark)

Also accepted

  • Storing and re-showing the generated image is a valid way to show the same image again (credit point 3), but point 1 and point 2 still need the explanation of why regenerating differs.

Earns nothing

  • "The AI remembers the image" with no mention of noise or seeds.

Mark every point to see your total.

Question 1 · Outline · AO1

[2 marks]

Outline the forward process in a diffusion model.

0 words

Marking points and model answer

A model answer

The forward process takes a training image and adds a small amount of Gaussian noise to it over many steps, following a fixed noise schedule, until the image is indistinguishable from pure random noise. Nothing is learned in this process.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: Noise (Gaussian noise) is added to a training image in many small steps. (1 mark)
  • Point 2: Until the image becomes pure noise / according to a fixed noise schedule (it is not learned). (1 mark)

Earns nothing

  • Describing how the model removes noise: that is the reverse process.

Mark every point to see your total.

Question 2 · Describe · AO1

[4 marks]

Describe how the denoising network in a diffusion model is trained.

0 words

Marking points and model answer

A model answer

For each training example, a real image is taken and a random step number is chosen. Noise is added to the image to match that step, and the exact noise is remembered. The network is given the noisy image and the step number and predicts the noise. The prediction is compared with the real noise using a loss such as mean squared error, and backpropagation with gradient descent adjusts the weights to reduce the error. This is repeated over millions of images and noise levels.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: A training image has a known amount of noise added for a randomly chosen step. (1 mark)
  • Point 2: The network is given the noisy image (and the step number) and predicts the noise that was added. (1 mark)
  • Point 3: The prediction is compared with the real noise using a loss function (for example mean squared error). (1 mark)
  • Point 4: The weights are adjusted using backpropagation / gradient descent, repeated over very many images. (1 mark)

Also accepted

  • Predicting the clean image (or a related quantity) instead of the noise is an accepted variant for point 2.

Earns nothing

  • "It learns from lots of images" with no description of the steps.

Mark every point to see your total.

Question 3 · Suggest · AO2

[4 marks]

Customers using Hearth & Oak's "Design my room" box complain that they wait too long for an image. Suggest two changes to the diffusion system that would reduce the waiting time, and state a disadvantage of each.

0 words

Marking points and model answer

A model answer

First, Hearth & Oak could reduce the number of sampling steps, for example from 50 to 20, using a sampler designed for few steps. Each step is a full pass through the network, so this cuts the time roughly in proportion, but images may lose fine detail such as fabric texture. Second, it could generate at a lower resolution and enlarge the result. Fewer pixels means less computation per step, but the enlarged image may look soft, which matters when customers are judging a product's material.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: A first valid change, for example using fewer sampling steps (with a faster sampler). (1 mark)
  • Point 2: A matching disadvantage, for example lower quality or less detail / more artefacts. (1 mark)
  • Point 3: A second valid change, for example generating at a lower resolution, working in latent space, a smaller or distilled model, or a faster GPU. (1 mark)
  • Point 4: A matching disadvantage, for example blurrier images, lost fine detail on the product, higher cost, or extra training work. (1 mark)

Also accepted

  • Showing a low-quality preview first and refining it afterwards is a valid change; its disadvantage is the extra compute for two passes.
  • A change given with no disadvantage earns the change mark only.

Earns nothing

  • "Use a better computer" with no link to time or cost.

Mark every point to see your total.

All case study topics

  1. Challenge 1

    SL and HL

    How diffusion models make an image

    Noise, denoising, the network that predicts the noise, and how a text prompt steers it.

  2. Challenge 2

    SL and HL

    Training data: ethics, ownership and bias

    Consent, copyright and attribution for training images, and how curation choices shape what the model makes.

  3. Challenge 3

    HL only

    GANs: a generator against a discriminator

    How two networks train against each other, and why that training is unstable.

  4. Challenge 4

    HL only

    Hybrid models and the trade-offs between them

    Systems that combine diffusion, GANs and autoencoders, judged on quality, speed, diversity and complexity.

Written by Spine in our own words. Spine is not affiliated with or endorsed by the International Baccalaureate. Every question, set of marking points and model answer here is our own, set in our own made-up company. Facts about the case study itself come from public guides and are marked “reported”. Last checked 2026-10-23.