Diffusion models are generative neural networks that learn to turn random noise into data, one small denoising step at a time. During training they watch real images get gradually destroyed by noise and learn to undo each step. To generate, they start from pure noise and run that learned clean-up in reverse. Most image and video generators you will use in 2027 are built on this idea or its close relative, flow matching, and so are many audio models.
This guide explains diffusion models with eight diagrams and charts instead of a wall of equations, from the forward and reverse processes through to text guidance and flow matching. To make the trade-offs concrete, I trained a tiny diffusion model and a tiny flow-matching model on 2D data with the same network and budget. Then I measured how sample quality changes with the number of sampling steps.

Key takeaways
- Diffusion models learn one simple skill, removing a little noise, and apply it many times to generate data.
- Training is stable and easy to scale: add noise to a real example, ask the network to predict it, repeat.
- Latent diffusion runs the process in a compressed space, which is what made high-resolution image generation affordable.
- Flow matching trains a model to follow straight paths from noise to data. In my test it reached near-best quality in 8 to 32 steps where the diffusion sampler needed 64 or more.
- Modern image and video generators use transformer backbones and flow-matching objectives, as in Stable Diffusion 3.
What are diffusion models?
A diffusion model is a generative model built around two processes:
- A forward process that slowly adds Gaussian noise to a real example until nothing recognisable is left. This part is fixed and needs no learning.
- A reverse process that starts from noise and removes it step by step. A neural network learns this part.
The approach comes from physics-inspired work by Sohl-Dickstein and colleagues in 2015. It took off with Denoising Diffusion Probabilistic Models (DDPM) by Ho, Jain and Abbeel in 2020, which reached an FID of 3.17 on CIFAR-10, a state-of-the-art score at the time, and sample quality on 256 × 256 LSUN scenes similar to ProgressiveGAN, one of the best GANs of the time.
Within two years, diffusion models had largely replaced GANs for image generation. They train more stably, cover the variety in a dataset better, and accept conditioning such as text prompts naturally.
Diffusion models vs other generative models
| Model family | How it generates | Strength | Weakness |
|---|---|---|---|
| GANs | a generator fools a discriminator | fast, sharp samples | unstable training, can miss variety |
| VAEs | decode a sample from a learned latent space | fast, smooth latent space | blurrier outputs |
| Autoregressive models | predict the next token or pixel | excellent for text | slow for large images |
| Diffusion models | denoise from random noise over many steps | quality, variety, stable training | many steps per sample |
| Flow matching | follow a learned velocity field from noise | fewer steps, simpler maths | newer, same backbone needs |
Insight 1: diffusion models start by destroying an image slowly

The strip above is a real photo run through the forward process with a cosine noise schedule. (Photo: flower by vultilion on Flickr, CC BY 2.0, from scikit-learn’s sample images, with noise added.) At each step the image is scaled down slightly and fresh Gaussian noise is added. By the end, nothing of the photo remains.
A useful property makes training fast: you never have to run the steps one by one. For any step t, you can jump straight to the noisy version with one formula:
x_t = √ᾱ_t · x₀ + √(1 − ᾱ_t) · ε
Here x₀ is the clean image and ε is random noise. The number ᾱ_t (alpha-bar) runs from 1 down to 0 and says how much of the original signal survives at step t. Early steps keep almost everything; the final step keeps almost nothing.
Insight 2: the network learns to predict the noise

The training loop of a DDPM-style diffusion model is short:
- Pick a real training example x₀.
- Pick a random step t between 1 and T (DDPM used T = 1,000).
- Draw random noise ε and build the noisy example x_t with the formula above.
- Give the network x_t and t, and ask it to predict ε.
- Measure the squared error between predicted and actual noise, and update the weights.
That is the whole objective. There is no adversary, no balancing act between two networks, and the loss goes down smoothly. This simplicity is a big reason diffusion models scale so well.
Generation runs the other way. Start from pure noise x_T. At each step, the network estimates the noise, the sampler removes a portion of it and, in the original DDPM sampler, adds back a little fresh noise. After all T steps you have a sample.
What the denoising network is
The noise predictor needs to output something the same shape as its input. Two backbones dominate:
| Backbone | Used in | Notes |
|---|---|---|
| U-Net with attention layers | DDPM, Stable Diffusion 1.x and 2.x, SDXL | convolutional encoder and decoder with skip connections |
| Diffusion transformer (DiT) | Stable Diffusion 3, most recent image and video models | image split into patches, processed as tokens |
The move to transformers follows the same pattern as language models: transformers scale predictably with more data and compute. Our transformer architecture guide explains the blocks these models reuse.
Insight 3: the noise schedule shapes how diffusion models learn

The noise schedule decides how quickly the signal disappears. The chart plots ᾱ_t, the share of the original signal’s variance left at each step, for two common schedules:
- The linear schedule from the DDPM paper increases the noise per step evenly from 0.0001 to 0.02 over 1,000 steps. It destroys most of the signal well before the end, so many late steps are spent on almost pure noise.
- The cosine schedule, proposed by Nichol and Dhariwal in 2021, removes signal more gradually and spends more steps in the middle range where the image is partly visible.
Which steps the model trains on matters as much as the schedule itself. Stable Diffusion 3, for example, samples training timesteps from a logit-normal distribution that focuses on the middle of the process, where the denoising task is hardest.
Insight 4: latent diffusion made it affordable

Running diffusion directly on pixels is expensive. A 1,024 × 1,024 colour image has over 3 million numbers, and the network processes all of them at every step.
Latent diffusion, introduced by Rombach and colleagues in 2021, moved the process into a compressed space:
- A variational autoencoder (VAE) is trained once to compress images into a smaller latent grid and decompress them back.
- The diffusion model learns to denoise in that latent space instead of pixel space.
- At generation time, the model denoises a random latent, and the VAE decoder turns the result into a full-resolution image.
The paper tested downsampling factors from 1 (pixel space) to 32 and found that factors of 4 to 16 “strike a good balance between efficiency and perceptually faithful results.” Too little compression trained slowly; too much lost detail. This design became Stable Diffusion, and nearly every image generator since works in a latent space.
Insight 5: text guidance steers the noise
A diffusion model with no conditioning produces random plausible images. To follow a prompt, the denoiser gets the text as an extra input.
- A text encoder (CLIP, T5 or a language model) turns the prompt into vectors.
- The denoiser reads those vectors through cross-attention (in U-Nets) or by mixing text and image tokens in the same transformer (in MMDiT-style models).
- Stable Diffusion 3 uses three text encoders at once: two CLIP models and T5-XXL, according to its paper.
Classifier-free guidance
Conditioning alone often produces images that only loosely match the prompt. Classifier-free guidance, introduced by Ho and Salimans, fixes this with a simple trick:
- During training, drop the prompt for a random fraction of examples, so the same network learns both conditional and unconditional denoising.
- During generation, run the network twice per step: with the prompt, then without it.
- Push the prediction further in the direction the prompt suggests, scaled by a guidance weight.
Higher guidance gives images that match the prompt more closely but look less varied and, at extremes, oversaturated. The “CFG scale” slider in image tools controls exactly this weight.
Insight 6: flow matching takes straighter paths
Flow matching, introduced by Lipman and colleagues in 2022, and the closely related rectified flow reframe generation as moving along a path from noise to data.
The simplest version connects each data point to a noise sample with a straight line:
x_t = (1 − t) · x₀ + t · ε
The network learns the velocity along that line (in the simplest case, ε − x₀). To generate, you start from noise at t = 1 and take steps along the predicted velocity until t = 0.
Why does this help? Diffusion paths curve, and following a curved path with large steps cuts corners. Straighter paths can be followed accurately with fewer, larger steps. Stable Diffusion 3 trains with a rectified-flow objective on a multimodal transformer and scaled it to 8 billion parameters, and flow matching has since become standard in image and video generation.
| DDPM-style diffusion | Flow matching | |
|---|---|---|
| Path from noise to data | curved, defined by the noise schedule | straight lines (in the basic form) |
| What the network predicts | the added noise | the velocity along the path |
| Typical sampler | DDPM, DDIM and newer solvers | ODE solvers such as Euler steps |
| Steps needed | many without special samplers | fewer for the same quality |
| Used in | DDPM, Stable Diffusion 1.x and 2.x, SDXL | Stable Diffusion 3 and most 2025 to 2026 generators |
Insight 7: fewer steps, tested on a tiny model
To see the difference between the two approaches with my own eyes, I trained two tiny generative models on the classic “two moons” 2D dataset using scikit-learn’s MLPRegressor. Both had the same network (three hidden layers of 256 units), the same 200,000 noisy training pairs built from 4,000 real points, and the same budget of up to 40 passes over the data. The only difference was the objective:
- the diffusion model learned to predict noise under a cosine schedule with 1,000 steps
- the flow-matching model learned the velocity along straight paths
I then generated 2,000 points with each model at different step counts and measured how far the samples were from 2,000 held-out real points, using sliced Wasserstein distance (lower is better). Two reference points help read the table: a second sample of real data scores 0.025, and pure Gaussian noise scores 0.219.
| Sampling steps | Diffusion (DDIM sampler) | Flow matching (Euler steps) |
|---|---|---|
| 1 | 2.565 | 0.793 |
| 2 | 2.553 | 0.379 |
| 4 | 0.629 | 0.209 |
| 8 | 0.416 | 0.100 |
| 16 | 0.216 | 0.083 |
| 32 | 0.158 | 0.041 |
| 64 | 0.108 | 0.062 |
| 1,000 (DDPM ancestral sampler) | 0.050 |


What the results show:
- Flow matching reached 0.083 in 16 steps and 0.041 in 32 steps, close to the real-data reference of 0.025.
- The diffusion model with a deterministic DDIM sampler needed many more steps. It was still at 0.108 after 64 steps, and its original 1,000-step sampler reached 0.050.
- With 1 or 2 steps the diffusion sampler fell apart completely, while flow matching produced a rough but recognisable shape at 2 steps.
- Flow matching’s score bounced between 32 and 64 steps (0.041 then 0.062). With a toy network, the remaining errors come from the network itself, not from the step size.
This is a toy: 2D points, a small multilayer perceptron, one random seed. It does not prove one method beats the other on images. It does show the mechanism behind the field’s shift: straight paths need fewer steps.
The heart of the flow-matching training data is three lines:
t = rng.uniform(0, 1, (n, 1)) # a random time for each example
x_t = (1 - t) * x0 + t * noise # a point on the straight line from data to noise
velocity_target = noise - x0 # the network learns to predict this
Insight 8: the cost of diffusion models is in the steps
Generation cost is roughly the cost of one network pass multiplied by the number of steps, doubled again if classifier-free guidance runs the network with and without the prompt. That makes step count the main lever for speed.

| Technique | What it does | Typical effect |
|---|---|---|
| Better samplers (DDIM and higher-order solvers) | take larger, smarter steps | 1,000 steps down to tens |
| Flow matching or rectified flow | straighter paths | good results in fewer steps |
| Distillation (consistency models, adversarial distillation) | train a student to jump several steps at once | 1 to 4 steps |
| Latent diffusion | work in a compressed space | each step is much cheaper |
| Guidance distillation | fold the guided result into one pass | removes the second network call |
Distillation is how “turbo” and “lightning” versions of image models produce images in one to four steps. The student model learns to imitate many steps of the teacher in one. Our guide to LLM distillation covers the same teacher-student idea for language models.
How diffusion models are evaluated
Judging generative models is harder than judging a classifier, because there is no single correct output. Papers and teams use a mix of measures:
| Measure | What it checks | Weakness |
|---|---|---|
| FID (Fréchet Inception Distance) | how close the statistics of generated images are to real ones | depends on an old image network; can miss text and fine detail |
| CLIP score | how well an image matches its prompt | rewards literal matches, not quality |
| Human preference studies | which output people prefer side by side | slow and expensive, varies with the raters |
| Prompt-following benchmarks | counting, colours, positions, text in the image | each covers a narrow skill |
| Distribution distances on toy data | how close samples are to the real data | only works for simple data, as in my 2D test |
FID made diffusion models famous: DDPM’s 3.17 on CIFAR-10 was the headline number. For text-to-image systems, human preference has become the main yardstick. The Stable Diffusion 3 paper, for example, reports that its largest models beat SDXL, PixArt-α and DALL-E 3 in human preference ratings as well as automatic metrics.
When you read a claim that one of the new diffusion models is “better”, check which of these it measured. A model can win on FID and lose on prompt following, or the other way round.
Training costs and practical limits
Diffusion models are cheap to train at toy scale and expensive at production scale. My 2D models each trained in under three minutes on two CPU cores. A small DDPM on CIFAR-10 is a realistic project on one rented GPU. Training a competitive text-to-image model from scratch, by contrast, needs a large captioned image dataset, a strong text encoder and a sizeable GPU cluster.
For most developers, the practical route is to start from an open pre-trained model and adapt it:
- LoRA adapters teach a new style or subject with a small set of images.
- Fine-tuning on a domain dataset (product photos, medical scans, satellite images) adapts the whole model.
- Control methods condition generation on edges, depth maps or poses to steer the layout.
Licences matter here too. Open image model weights come with very different terms, from permissive to non-commercial, so check them before building a product. Our guide to open-weight vs open-source models explains what to look for.
Where diffusion models are used in 2027
| Area | What diffusion or flow matching does |
|---|---|
| Image generation and editing | text-to-image, inpainting, upscaling, style transfer |
| Video | text-to-video and image-to-video with transformer backbones over space and time |
| Audio and music | speech synthesis and music generation in latent audio spaces |
| 3D and design | generating shapes, textures and multi-view images |
| Science | protein structure and molecule generation, weather and climate ensembles |
| Robotics | “diffusion policies” that generate action sequences |
| Text | diffusion language models are an active research area, with autoregressive models still dominant |
Common misconceptions about diffusion models
- “They copy and blend training images.” They learn a denoising function from data. Memorisation of individual images can happen, especially for heavily duplicated training images, which is why deduplication matters, but it is not how generation normally works.
- “Diffusion means slow.” Original samplers used 1,000 steps. Better samplers and flow matching bring this to tens, and distillation goes down to one to four steps.
- “Stable Diffusion is one model.” It is a family. Versions 1.x and 2.x use U-Nets; Stable Diffusion 3 uses a rectified-flow transformer.
- “The model draws the image from left to right.” Every step updates the whole image at once. Coarse structure settles first and fine detail last.
- “Flow matching replaced diffusion.” They are closely related, and many papers show they can be written as the same family with different paths and weightings.
How to learn diffusion models hands-on
- Reproduce a 2D toy like the one above. Seeing points move from noise to the data shape builds intuition fast.
- Train a small DDPM on MNIST or CIFAR-10 in PyTorch with a small U-Net.
- Switch the objective to flow matching and compare samples at a few step counts.
- Use a pre-trained latent diffusion model and experiment with guidance scale and step count.
- Read the DDPM paper first, then latent diffusion, then Stable Diffusion 3.
The deep learning roadmap for 2027 shows where generative models fit after the fundamentals.
FAQ
How do diffusion models work in simple terms?
They are trained to remove a little noise from a noisy example. To generate something new, they start from pure random noise and apply that skill over and over, each time producing a slightly cleaner result, until a realistic image (or sound or video) appears.
What is the difference between diffusion models and GANs?
A GAN trains a generator against a discriminator and produces a sample in one pass. A diffusion model trains a single denoising network with a simple loss and produces a sample over many steps. Diffusion models train more stably and capture more variety; GANs are faster at generation.
What is latent diffusion?
Latent diffusion runs the noise and denoising process inside a compressed representation made by an autoencoder, instead of on raw pixels. The final latent is decoded back to an image. It cuts the compute per step dramatically and is the basis of Stable Diffusion.
Is flow matching better than diffusion?
For generation speed, flow matching with straight paths usually needs fewer sampling steps for similar quality, which is why recent image models such as Stable Diffusion 3 use it. The two are closely related, and quality depends more on the network and training data than on the objective alone.
Why do image generators have a guidance scale setting?
That setting controls classifier-free guidance. The model predicts the next step with and without your prompt and exaggerates the difference. Higher values follow the prompt more strictly but reduce variety and can oversaturate the image.
The one idea to keep
Diffusion models generate by repeatedly removing noise, using a network trained on one easy task. Everything else in this guide is about running that loop with fewer and cheaper steps that are better aimed at the target. Once that picture is clear, every new image or video model paper becomes easier to read.


