Generative modelling at 2,000 ft¶
A generative model learns the distribution the data came from, well enough to draw new samples from it. Every image generator, voice clone, video model and multimodal assistant is one. This track builds the four families that matter (VAEs, GANs, diffusion and flows) from first principles, then shows how they are assembled with transformers into the systems that see, draw, speak and simulate.
10,000 ft
Discriminative models answer questions about data: what is in this image? Generative models answer a harder one: what does data like this look like, in all its variety? To generate a convincing face a model must capture lighting, anatomy, texture and the correlations between millions of pixels, so generative modelling is also the deepest form of representation learning. A large language model is a generative model of text, trained autoregressively; this track covers the other half of the story: continuous, high-dimensional data such as images, audio and video, where predicting the next token is not the natural fit. The ideas here run through the whole of modern AI: the ELBO of variational inference, the adversarial game behind GANs (and, in spirit, behind reward hacking in RLHF), the denoising objective of diffusion that now also generates proteins, robot actions and text, and the shared embedding spaces of CLIP that let one model read and write across modalities.
2,000 ft
Every family solves the same problem: make \(p_\theta\) close to \(p_\text{data}\) when you can only see samples. They differ in what they let you compute.
- Autoregressive models factor \(p(\mathbf x) = \prod_i p(x_i\mid x_{<i})\): exact likelihood, slow sequential sampling. They rule text and are the backbone of vision-language models and audio-token models.
- VAEs add a latent code and maximise a lower bound on the likelihood: fast sampling, blurry on their own, indispensable as compressors.
- GANs drop the likelihood and train a generator against a learned critic: sharp, fast, unstable, prone to dropping modes.
- Diffusion models learn to undo gradual noising, one small step at a time: stable regression training, full mode coverage, many sampling steps.
- Score and flow models learn a vector field that carries noise to data; flow matching is the straight-line version that trains today's largest image and video models.
- Multimodal systems combine these: an autoencoder compresses pixels or audio, a transformer models the result, and a contrastive encoder ties it to language.
The family tree¶
The dashed arrows are the surprises of the last five years: diffusion models turned out to be score-based energy models and continuous normalising flows at the same time, which is why score matching and flow matching can unify them.
What each family optimises¶
| Family | What the network learns | Training signal | Divergence (idealised) | Sampling cost | Typical failure | Where it lives in 2026 |
|---|---|---|---|---|---|---|
| Autoregressive | next-element conditional | cross-entropy | forward KL (exact MLE) | one pass per token | slow for pixels, exposure bias | LLMs, VLMs, audio tokens |
| VAE | encoder + decoder | ELBO | forward KL (bound) | one pass | blur, posterior collapse | latent compressors, tokenisers |
| GAN | generator + critic | adversarial game | JS, Wasserstein, reverse KL-like | one pass | mode collapse, instability | losses in autoencoders, vocoders, distillation |
| Diffusion | noise / score per noise level | denoising regression | forward KL (weighted ELBO) | 20–1,000 passes | slow sampling | images, video, audio, proteins |
| Flow matching | velocity field | velocity regression | transport along a chosen path | 1–50 passes | curved paths need steps | SD3, FLUX, Movie Gen, π0 |
Xiao, Kreis and Vahdat (2021) named the tension in the last columns the generative learning trilemma: high sample quality, mode coverage and fast sampling, pick two. GANs had quality and speed, likelihood models had coverage, and diffusion had quality and coverage. Much of the research since 2022 (distillation, consistency models, rectified flow, adversarial post-training) is about getting all three.
Worked example: how big is the space a generative model must learn?
A 256×256 RGB image with 8-bit channels has \(256\cdot256\cdot3 = 196{,}608\) numbers, so there are \(256^{196{,}608}\approx 10^{473{,}479}\) possible images. Natural images are a vanishing fraction of them, concentrated near a low-dimensional manifold. Likelihood is reported in bits per dimension: the negative log-likelihood in bits divided by the number of subpixels. A uniform model scores 8 bits/dim. On CIFAR-10 (32×32×3 = 3,072 dimensions) Song et al.'s score-based SDE model reported 2.99 bits/dim (score matching): about 9,185 bits per image instead of 24,576, so the model assigns a typical test image roughly \(2^{15{,}391}\) times the probability the uniform model does. That ratio is what "learning the distribution" means quantitatively, and it is why likelihood is a poor guide to visual quality: most of those bits describe noise-level detail nobody sees (latent diffusion is built on that observation).
The map of the track¶
Arrows mean "builds on". The left half is the theory of generation; the right half is how pixels, sound and language are turned into representations those generators can use.
How to work through this track¶
The track is two units. Unit 1 (this page and the next four) is the theory of generative modelling, from the ELBO to flow matching. Unit 2 applies it to images, language, sound and video.
- Autoencoders and VAEs (about 90 minutes). Latent variables, the ELBO and the reparameterisation trick. The single most reusable idea in the track; do its Build it section.
- Generative adversarial networks (90 minutes). The adversarial game, why it fails and how it was stabilised. Run the Dirac-GAN.
- Diffusion models (2 hours). Forward noising, the ε-prediction loss, DDPM and DDIM sampling, and a diffusion model trained from scratch in NumPy.
- Score matching and flow matching (2 hours). The continuous-time view: scores, SDEs, the probability-flow ODE and flow matching as regression.
- Latent diffusion and guidance (75 minutes). How Stable Diffusion and FLUX are built; classifier-free guidance.
- Vision transformers and CLIP (75 minutes), then vision-language models (80 minutes): how images become tokens and how LLMs learn to see.
- Speech and audio (90 minutes) and video and world models (90 minutes): the same machinery for sound and for space-time.
Budget 14 hours of real study, plus a project. Three faster paths:
- "I want to understand Stable Diffusion": 1 → 3 → 5, with CLIP alongside 5.
- "I build with multimodal LLMs": 1 (first half), then CLIP → vision-language models → speech and audio.
- "I want the mathematics": 1 → 3 → 4, doing every collapsible derivation, then the score-SDE and flow-matching papers in their Go deeper lists.
The one project that teaches the most
Train a diffusion model and a flow-matching model on the same 2-D dataset, from scratch, in NumPy or PyTorch. The diffusion page and the flow-matching page give working starting points. Then sample both with 1, 4, 16 and 64 steps and plot the results side by side. You will have reproduced, in an afternoon, the central trade-off of the field.
Every page in the track¶
-
Compression as a training signal, the ELBO, reparameterisation, posterior collapse, VQ-VAE and the autoencoder inside every latent diffusion model.
-
Generative adversarial networks
The minimax game, D* and Jensen–Shannon, mode collapse, the Dirac-GAN, WGAN, spectral norm, R1, StyleGAN, FID.
-
Forward noising, the ε-prediction loss as an ELBO, DDPM and DDIM, schedules and SNR, U-Nets and DiTs, fast sampling.
-
Score matching and flow matching
Scores and Langevin dynamics, denoising score matching, SDEs and the probability-flow ODE, flow matching, rectified flow, one-step models.
-
Diffusion in an autoencoder's latent space, text conditioning by cross-attention, classifier and classifier-free guidance.
-
Images as sequences of patches, and contrastive training that puts images and text in one embedding space.
-
How LLMs learn to see: encoders, connectors, interleaved training and native multimodal models.
-
Spectrograms, recognition, neural codecs, vocoders and speech generation.
-
Generating space-time, video diffusion transformers, and models that simulate the world for agents.
Generative AI in twelve dates¶
| Year | Event | Read |
|---|---|---|
| 2013 | Kingma and Welling's variational autoencoder | VAEs |
| 2014 | Goodfellow et al.'s generative adversarial networks | GANs |
| 2015 | Sohl-Dickstein et al. propose diffusion probabilistic models | diffusion |
| 2017 | VQ-VAE turns images and audio into discrete tokens | VAEs |
| 2018 | StyleGAN and BigGAN: photorealistic GAN samples | GANs |
| 2019 | Song and Ermon's noise-conditional score networks | score matching |
| 2020 | Ho et al.'s DDPM; Song et al.'s score SDEs | diffusion |
| 2021 | CLIP; Diffusion Models Beat GANs; latent diffusion | CLIP, latent diffusion |
| 2022 | DALL·E 2, Imagen and the open release of Stable Diffusion; flow matching and rectified flow | latent diffusion, flow matching |
| 2023 | Open vision-language assistants built by connecting image encoders to LLMs | vision-language models |
| 2024 | Rectified-flow transformers (SD3, FLUX.1); text-to-video at scale | flow matching, video |
| 2025 | One-step generators trained from scratch (MeanFlow); masked diffusion language models at 8B parameters | flow matching, diffusion |
The narrative history, people and companies are in the story of AI.
Prerequisites from other tracks¶
You need these before unit 1:
- Probability from first principles and the distributions that run AI: Gaussians, mixtures, sampling.
- Entropy, cross-entropy and KL divergence: every objective in this track is a divergence.
- Estimation: MLE, MAP and Bayes: what maximum likelihood is and why it is the default.
- Clustering, mixtures and EM: the latent-variable model in its simplest form.
- Backpropagation, convolutional networks and residual networks: the networks inside the generators.
For unit 2, add attention, the transformer block and the language-modelling objective. For score and flow matching, the chain rule and Jacobians helps.
The five best resources for this track¶
- Stanford CS236: Deep Generative Models (2023) — Stefano Ermon. A whole university course on exactly this track's unit 1: autoregressive models, VAEs, flows, GANs, energy-based, score-based and diffusion models. Course site at deepgenerativemodels.github.io.
- Understanding Deep Learning — Simon J. D. Prince, MIT Press 2023, free PDF. Chapters 14–18 (unsupervised learning, GANs, normalising flows, VAEs, diffusion) are the best-illustrated textbook treatment.
- But how do AI images and videos actually work? — Welch Labs for 3Blue1Brown, 2025. The visual intuition for diffusion, score fields and CLIP in one video.
- MIT 6.S184: Introduction to Flow Matching and Diffusion Models — Peter Holderrieth and Ezra Erives. Lectures, labs and self-contained notes (arXiv 2506.02070) on the modern continuous-time view.
- Probabilistic Machine Learning: Advanced Topics — Kevin P. Murphy, MIT Press 2023, free draft. Its part on generation covers every family here with rigorous, consistent notation; the reference to keep beside the track.
Where this leads¶
- Start the track: Autoencoders and VAEs.
- Here for Stable Diffusion? Go to diffusion models, then latent diffusion and guidance.
- Here for multimodal assistants? Go to vision transformers and CLIP, then vision-language models.
- After this track: world models and neuro-symbolic AI and AI for science, where generative models become simulators.