Generative Image Models (Diffusion)

How an algorithm learned to generate dogs from snowfall — with the patience of a monk.

Architectures 10 min Intermediate June 15, 2026

In the previous article, you learned how language models pick their next word. Now the same generative principle — start with randomness, apply learned structure — creates images.

This article reveals the surprisingly simple idea behind DALL-E, Midjourney, and Stable Diffusion: teach a model to recognise noise, then run the process backwards.

Learning by Destruction — The Forward Process

Forward Process

AnalogyDefinition
Imagine a painting on a table. You throw a thin layer of sand on it, then another, then another — a thousand times. By the end, the painting is invisible under sand. Training a diffusion model is like training a robot to recognise, at every single layer, exactly which grains were just added.

If the robot can do that, it can brush them off in reverse. Key insight: the robot learns grain patterns, not the painting itself — the model does not memorise training images.

Imagine a 64x64 photo of a cat. Step 0: pristine photo. Step 250: slightly fuzzy, details blurred. Step 500: recognisable shape but colours washed out. Step 750: vague blob. Step 1,000: pure random static, indistinguishable from any other noise image.

~1,000
Training Steps Noise is added in ~1,000 small steps

Common Misconception: The Model Memorises Training Images

The model learns the statistical structure of noise removal, not specific images. However, with enough training on limited data, fragments of training images can be reproduced — which is why the copyright question is real and unresolved.

Why is noise added in a thousand tiny steps rather than all at once? Because each small step creates a learnable prediction task. One massive noise dump gives the model no gradient signal to learn from. The variance schedule determines how much noise is added at each step — too little and the model learns trivial predictions, too much and structure is lost too early.

Creation from Chaos — The Reverse Process

Reverse Process

AnalogyDefinition
The trained robot from Concept 1 now works on a fresh, random pile of sand (no painting underneath). Using everything it learned about grain patterns, it brushes away one layer at a time. Because the robot's expertise encodes the structure of "real paintings," the sand naturally settles into a painting-like pattern.

There is no painting under the sand — the model creates structure from learned statistics, not from hidden data. Different sand piles (seeds) produce different paintings.

Stable Diffusion: start with random noise in latent space, run 50 denoising steps. Step 1: pure chaos. Step 10: vague shapes and colour patches. Step 25: recognisable object (cat outline visible). Step 50: sharp, detailed final image.

~50
Denoising Steps In practice, ~50 steps suffice for image generation

Common Misconception: More Steps Always Produce Better Images

There are diminishing returns. Beyond roughly 50 steps, quality plateaus while compute cost keeps growing linearly. Modern schedulers like DDIM and DPM++ achieve good results in as few as 20 steps.

Making It Practical — Latent Diffusion & Text-Conditioning

Latent Diffusion

AnalogyDefinition
Instead of sculpting a life-size marble statue directly (pixel space), you first sculpt a small clay maquette (latent space). The maquette captures all essential proportions in miniature. Only when it's finished does a machine scale it up to full size (VAE decoder). Meanwhile, a client's brief (text prompt via CLIP) tells the sculptor what to carve at every step.

The maquette captures essentials without knowing every detail of the original — just as the latent space compresses key image features. The client's brief guides but does not dictate — which is why unusual prompts can produce surprising results.

Pixel Space

~786,000 values (512x512x3). Denoising directly on pixels. Requires data-centre GPUs with enormous memory. Historically first diffusion models (DDPM, 2020).

Latent Space

~16,000 values (64x64x4). Denoising on compressed representation. Runs on consumer GPUs. Stable Diffusion (Rombach et al., 2022).

~50x
Compression Factor ~50x less data through latent-space compression

Common Misconception: The Model Understands My Prompt

The model follows statistical associations between text embeddings and image features learned during training. It has no concept of "dog" or "moon" — only learned correlations. This is why unusual prompts sometimes produce surprising or incoherent results.

The Complete Pipeline

Stable Diffusion Pipeline

Enter text prompt
CLIP encodes the text into an embedding vector
Generate random noise in latent space (64x64x4)
U-Net denoises in ~50 steps (cross-attention with text embedding)
VAE decoder converts latent image to 512x512 pixel image
1
Real image (training)
2
Add noise (T steps)
3
Pure noise
4
Predict & remove noise (T steps)
5
Generated image

The forward process (training) and reverse process (generation) are mirror images: what is destroyed during training is reconstructed during generation.

Interactive: How the Model Learns to Denoise

During training, the U-Net learns to predict the noise that was added. In each step, it compares its prediction with the actual noise and adjusts its weights. Watch how the prediction error (loss) decreases with each optimization step — this exact process is what makes the model increasingly better at reconstructing images from noise.

1
2
3
4
5
Parameter wLoss L(w)Minimum
Step 1 / 5Starting position

The ball starts far left of the minimum. The loss is high (L=105.8). The gradient points steeply downhill to the right — the algorithm knows which direction to go.

Limitations & Copyright

  • Diminishing returns: Beyond ~50 denoising steps, image quality barely improves while compute time grows linearly.
  • Memorisation: In rare cases, diffusion models reproduce recognisable fragments of training images — especially when certain images appear disproportionately often in training.
  • Copyright: Whether AI-generated images infringe the copyrights of training data is legally unresolved and the subject of active debate.

Summary

  1. The forward process teaches the model what noise looks like at every stage of destruction — this is the training signal.
  2. The reverse process creates images by iteratively subtracting predicted noise from random static, step by step.
  3. Latent diffusion compresses images before denoising by ~50x, enabling generation on consumer GPUs.
  4. Text-conditioning via CLIP and cross-attention steers what emerges from the noise — but the model does not "understand" the prompt in any human sense.

This article completes Path I.G (Modern Architectures). From RNNs through attention, transformers, fine-tuning, and sampling, you've arrived at the most visible application of generative AI: image generation. Ready for the next sector?

Quiz: Generative Image Models (Diffusion)

Question 1 / 6
Not completed

What is the training objective of a diffusion model during the forward process?

Select one answer
Answer Key: 1) B · 2) B · 3) C · 4) C · 5) B · 6) C

Knowledge Check

  • Why do developers train the model to predict noise rather than simply memorising the finished image?
  • How does a finished image emerge from pure random noise, and why does a different seed produce a completely different result?
  • Why is it possible to run a modern image model like Stable Diffusion on a decent home computer, even though the first models required huge servers?