Skip to content
Generating text

Diffusion models

How image generators turn pure static into a picture by removing a little noise at a time.

Intermediate · 6 steps

Read first:Neural networksLoss and gradient descent

Step 1 of 6· Toy denoiser that knows the target picture; the DDPM noise schedule, noising formula and DDIM update are real

in one minute

A diffusion model creates an image by starting from pure random noise and cleaning it up step by step. It learns how by studying the opposite process: training images are gradually buried under noise, and the network is taught to predict the noise that was added at any stage. To generate, it starts from static, predicts the noise, removes some of it and repeats until a clean picture remains. Each step is one pass through the network, so fewer steps are faster but rougher. A text prompt fed in at every step steers what the picture becomes.

Why it matters for your product

Diffusion is the idea behind many image generators, including text-to-image systems built on latent diffusion. Its cost grows with the number of denoising steps: every step is a full network pass, so faster samplers cut latency and spend directly. For product teams the practical dials are step count, guidance strength and resolution, which trade speed, diversity and quality against each other. Outputs are samples, not retrievals, so review them for accuracy, rights and brand fit before use.

For engineersShow the maths

xₜ = √ᾱₜ · x₀ + √(1 − ᾱₜ) · ε, ε ~ N(0, I)

Any noisy version is a weighted mix of the clean image and fresh Gaussian noise; ᾱₜ shrinks from 1 towards 0 as t grows.

Worked example: With DDPM's linear schedule, ᾱ at step 500 ≈ 0.079, so x₅₀₀ = 0.28 · image + 0.96 · noise: under 8% of the picture's variance is left.

Loss = ‖ε − ε_θ(xₜ, t)‖²

Show the network a noisy image and its step number, and penalise the squared gap between the noise it predicts and the noise actually added.

Worked example: If the true noise at two pixels is (0.5, −1.0) and the network predicts (0.3, −0.6), the loss is 0.2² + 0.4² = 0.20.

x̂₀ = (xₜ − √(1 − ᾱₜ) · ε̂) / √ᾱₜ

From a noise guess the sampler can estimate the clean image directly; DDIM then re-noises that estimate to a slightly lower level and repeats.

where it stops working

Generation needs many network passes, so it is slower than single-pass generators unless few-step samplers or distillation are used. The model produces plausible samples shaped by its training images, not faithful records, so nothing in a generated picture is guaranteed to be true.

Key terms

The words you will hear

Forward process

The fixed procedure that adds a little Gaussian noise at each step until the data becomes pure noise.
Where it came from

Primary sources

  1. 01Deep Unsupervised Learning using Nonequilibrium ThermodynamicsSohl-Dickstein et al. · 2015
  2. 02Denoising Diffusion Probabilistic ModelsHo et al. · 2020
  3. 03Denoising Diffusion Implicit ModelsSong et al. · 2020
  4. 04High-Resolution Image Synthesis with Latent Diffusion ModelsRombach et al. · 2021
  5. 05Classifier-Free Diffusion GuidanceHo, Salimans · 2022

Want this working on your data?

We design and build the systems these ideas power: retrieval, agents, voice and the models behind them. Start with a free discovery call.