Chapter 1: Introduction to Generative Models
Understand the landscape of generative modeling: how machines learn to create new data, the fundamental difference between generative and discriminative approaches, and why diffusion models have emerged as the state-of-the-art framework for high-fidelity generation.
- Topics
- 6
- Demo
- 1
- Videos
- 3
- Min read
- 41
Chapter Overview
Generative models are at the heart of modern AI's creative capabilities. From photorealistic image synthesis to drug molecule design, these models learn the underlying distribution of data and generate novel samples that are statistically indistinguishable from real observations.
This chapter builds the conceptual foundation you need before diving into diffusion models specifically. We start with the fundamental distinction between generative and discriminative modeling, then survey the major families of generative models that have been developed over the past decade. You will learn how likelihood-based training works, why latent variables are essential for modeling complex data, and how researchers evaluate the quality and diversity of generated samples.
By the end of this chapter, you will understand:
- Generative vs Discriminative: Why modeling is fundamentally harder than
- Model Taxonomy: The strengths and weaknesses of GANs, VAEs, Normalizing Flows, and Autoregressive models
- Likelihood Training: Maximum likelihood estimation, tractable and intractable densities, and the ELBO
- Latent Variables: How hidden representations enable complex generation through simple priors
- Evaluation Metrics: FID, IS, precision/recall, and why measuring generative quality is an open problem
- The Case for Diffusion: Why diffusion models solve the key problems that plagued earlier approaches
Chapter Roadmap
Click any topic to jump in
Generative vs Discriminative
The fundamental split — modeling data distributions vs learning decision boundaries.
Taxonomy
GANs, VAEs, flows, autoregressive, diffusion — the landscape of generative approaches.
Direct likelihood vs latent variables
Likelihood-Based
Normalizing flows and autoregressive models — directly maximizing log-likelihood.
Latent Variable
VAEs and the ELBO — learning compressed representations through variational inference.
Evaluation and why diffusion wins
Evaluation
FID, IS, precision/recall — measuring quality and diversity of generated samples.
Why Diffusion?
Training stability, mode coverage, sample quality — why diffusion surpassed GANs and VAEs.
Topics
6 topics in this chapter
Suppose you want a machine that does more than sort photos into 'cat' and 'dog' --- you want it to invent a brand-new cat that has never existed. That single wish exposes the deepest divide in machine learning. A classifier only needs to know where the boundary between cats and dogs lies; it never has to understand what a cat truly is. A model that can dream up new cats must learn the entire visual world of cats: every pose, fur pattern, and lighting condition. This chapter opens the diffusion study plan by making that divide precise. Discriminative models learn the conditional --- given an input, which label? Generative models learn the data distribution itself --- what does plausible data look like? The distinction decides what a model can do, how it is trained, and how much data it needs. It is also strictly ordered: knowing lets you recover by Bayes' rule, but a classifier can never be run backwards to synthesise data. We build this idea first because every generative family in the coming topics is one answer to the same question: how do you actually learn ?
Definition
A discriminative model estimates the conditional distribution , mapping an input directly to a label or value. A generative model estimates the full data distribution , or the joint , so it can assign a likelihood to any point and draw new samples from it. Generative modeling is the strictly harder, more general task.
In this topic
- 1Discriminative Models: Learning P(y|x)
- 2Generative Models: Learning P(x)
- 3Joint vs Conditional Distributions
- 4When to Use Each Approach
Discriminative Models: Learning P(y|x)
A discriminative model directly estimates the conditional probability of label given input . The formula is Bayes' rule: is the class-conditional likelihood, the prior over labels, and the evidence --- but a discriminative model skips all three and models directly, learning only the decision boundary that separates classes. Logistic regression, SVMs, and classification CNNs are examples. They train easily and reach high accuracy because they ignore within-class structure, but they fail on inputs far from the training distribution: with no model of , they cannot tell a novel input from a familiar one and still return a confident label.
Discriminative models project high-dimensional input onto a decision surface. The conditional discards all information about the data manifold itself — it only needs the boundary where class posteriors cross . Statistically, this means fewer parameters to estimate and faster convergence rates, since the model ignores within-class variance entirely.
A CNN classifies images as cat or dog. Does it need to understand what cats look like in general, or just what distinguishes cats from dogs?
Generative Models: Learning P(x)
A generative model learns the full joint probability distribution of the data. Once learned, it can generate new samples by drawing from this distribution. The formula above shows the latent variable formulation: the data distribution is expressed as a marginalization over latent variables . Learning is fundamentally harder because the model must capture all variation in the data --- every texture, every pose, every lighting condition --- not just the features that distinguish classes.
Learning requires estimating density in the full ambient space, which is exponentially harder due to the curse of dimensionality. The integral marginalizes over latent factors, and tractability depends on whether this integral has closed form. When it does not, variational bounds or MCMC become necessary — the starting point for diffusion models.
If you have a generative model that has learned the distribution of face images, what tasks can it perform beyond generation?
Joint vs Conditional Distributions
The joint distribution contains complete information about both the data and labels. Generative models that learn can derive both (by marginalization) and (by conditioning). Conditional distributions capture only part of the picture. The chain rule of probability connects them: knowing any two of lets you derive the others. This is why generative models are more powerful but harder to train --- they must learn more information.
The chain rule reveals an information hierarchy: the joint contains strictly more information than any conditional. Bayes' theorem converts between conditionals, but requires the marginal — which is exactly the intractable quantity in generative modeling. This asymmetry is why generative models are universal but harder to train.
Given a dataset of handwritten digits with labels, compare what a generative vs discriminative model learns.
When to Use Each Approach
Use discriminative models when you have labeled data and only need predictions: classification, regression, ranking. They are more data-efficient for supervised tasks because they focus capacity on the decision boundary.
Use generative models when you need to: create new data (images, text, molecules), understand data structure, detect outliers, handle missing data, or perform semi-supervised learning. Generative models also enable data augmentation, privacy-preserving synthetic data, and creative applications.
In practice, the lines are blurring. Modern systems like CLIP combine discriminative and generative objectives, and diffusion models can be conditioned on text to bridge generation and classification.
From an information-theoretic view, discriminative models compress data into bits (the label), while generative models must represent the full entropy of the data distribution. When , the discriminative model is vastly more efficient for classification — but it cannot reconstruct, generate, or detect anomalies.
A hospital wants to (a) diagnose diseases from X-rays, and (b) generate synthetic X-rays for training. Which approach for each?
Theory Exercise
Problem:
Prove that if you have a perfect generative model , you can always derive a perfect discriminative model , but the reverse is not true. What does this imply about the relative difficulty of generative vs discriminative learning?
Hints:
- Use the definition of conditional probability: P(y|x) = P(x,y) / P(x)
- Consider what information is lost when you only learn P(y|x)
- Think about whether P(y|x) alone lets you sample new data points x
Related Problems on PixelBank
Having established in the previous topic that generative models must learn the full distribution , an obvious question follows: how? Learning a distribution over millions of pixels is not one problem but many, and the field has answered it in five distinct ways, each trading off something different. This topic surveys that landscape so you can see where diffusion models fit and why they were a genuine breakthrough. The five families are Generative Adversarial Networks, Variational Autoencoders, Normalizing Flows, Autoregressive Models, and Diffusion Models. They differ along four axes that will recur throughout this plan: is training stable, are samples sharp, can you evaluate the likelihood, and how fast is sampling? No single family before diffusion scored well on all four --- GANs are sharp but unstable, VAEs are stable but blurry, flows are exact but constrained, autoregressive models are exact but slow. Understanding each family's core objective and its characteristic failure mode is the map you need before the diffusion machinery of the next chapters makes sense.
Definition
The taxonomy of generative models groups approaches by how they represent and optimize : adversarial games (GANs), variational bounds on likelihood (VAEs), exact invertible transforms (Normalizing Flows), sequential factorizations of the joint (Autoregressive), and iterative denoising of a fixed noising process (Diffusion). Each choice fixes a distinct trade-off between sample quality, training stability, likelihood tractability, and sampling speed.
In this topic
- 1Generative Adversarial Networks (GANs)
- 2Variational Autoencoders (VAEs)
- 3Normalizing Flows
- 4Autoregressive Models
Generative Adversarial Networks (GANs)
GANs (Goodfellow et al., 2014) train two networks in a minimax game: a generator maps random noise to fake samples , and a discriminator outputs the probability that its input is real. The objective rewards for driving toward 1 on real data and toward 0 on fakes, while is trained to fool it. At the game's equilibrium, 's samples are indistinguishable from real data. GANs yield sharp, high-quality images but train unstably --- mode collapse and vanishing gradients are common --- and provide no way to evaluate the likelihood of a sample.
The GAN minimax objective defines a two-player game whose Nash equilibrium is . However, the loss landscape is non-convex and saddle-point optimization is notoriously unstable. Mode collapse occurs when the generator finds a local minimum that fools the discriminator without covering the full support of . The Jensen-Shannon divergence at equilibrium equals .
A GAN generator produces realistic face images, but all faces look like the same person. What is happening?
Variational Autoencoders (VAEs)
VAEs (Kingma & Welling, 2014) learn a latent representation of the data. An encoder maps data to a distribution over latent codes , and a decoder reconstructs data from latent codes . Training maximizes the Evidence Lower Bound (ELBO), which balances reconstruction quality against keeping the latent space well-structured. VAEs provide stable training and tractable likelihood bounds but produce blurry samples because the decoder must average over posterior uncertainty.
The ELBO decomposes into reconstruction and KL regularization . The gap measures posterior approximation quality. Blurriness arises because the Gaussian decoder minimizes , which averages over modes when has uncertainty.
Why do VAE-generated images tend to be blurrier than GAN-generated images?
Normalizing Flows
Normalizing flows (Rezende & Mohamed, 2015) transform a simple base distribution (e.g., Gaussian) into a complex data distribution through a sequence of invertible transformations . Because each transformation is invertible with a tractable Jacobian determinant, exact likelihood computation is possible via the change of variables formula. The trade-off is architectural constraints: every layer must be invertible, limiting expressiveness and requiring specialized architectures like RealNVP, Glow, or Neural Spline Flows.
The change-of-variables formula requires each layer to be invertible with a tractable Jacobian determinant. The total log-likelihood accumulates across layers. This constrains architectures — coupling layers partition dimensions to achieve Jacobian computation instead of . The expressiveness-tractability trade-off limits flow models in practice.
A normalizing flow maps a 2D Gaussian to a crescent-shaped distribution using 3 invertible layers. How do you compute the exact likelihood of a data point ?
Autoregressive Models
Autoregressive models (van den Oord et al., 2016) decompose the joint distribution into a product of conditionals using the chain rule of probability. Each dimension is generated sequentially, conditioned on all previously generated dimensions. This provides exact, tractable likelihood computation and avoids the blurriness of VAEs. However, generation is inherently sequential --- each dimension must wait for all previous ones --- making sampling slow. Examples include PixelCNN for images and GPT for text.
The chain rule is exact — no approximation. Each conditional is modeled by a neural network with masked attention or causal convolutions. The factorization gives exact log-likelihood in time, but generation is sequential: each depends on all previous values. For images, this means serial steps where is the number of pixels.
An autoregressive model generates a 256x256 RGB image pixel by pixel. How many sequential steps does generation require?
Theory Exercise
Problem:
Fill in this comparison table: For each model family (GANs, VAEs, Flows, Autoregressive), state whether it provides (a) exact likelihood computation, (b) fast single-pass sampling, (c) stable training, and (d) sharp high-resolution outputs. Which model family would you choose for generating high-resolution images with exact density estimation?
Hints:
- GANs use adversarial training --- think about what the minimax objective means for stability
- VAEs optimize a lower bound, not the exact likelihood
- Consider the architectural constraints of normalizing flows
Related Problems on PixelBank
The taxonomy in the previous topic sorted generative models partly by whether they can evaluate a likelihood --- and that word, likelihood, deserves a topic of its own, because it is the currency almost every generative model is trained in. Here is the problem it solves. Given a dataset, how do you say one model is better than another? The likelihood answers this: it is the probability the model assigns to the real data, and training simply pushes that probability up, placing density where data actually lives. But there is a catch that shapes the entire field. For expressive models the likelihood requires integrating over hidden variables, and that integral usually has no closed form. This topic traces the resulting tension between expressiveness and tractability: maximum likelihood estimation as the ideal, the split between models with exact densities and those without, and the variational lower bound (the ELBO) that rescues the intractable case. That bound is exactly the objective diffusion models are trained on, so this topic is the direct on-ramp to how they learn.
Definition
A likelihood-based model is trained by maximizing , the probability it assigns to observed data. When that density can be computed exactly the likelihood is tractable; when it requires an intractable integral over latent variables, training instead maximizes a lower bound on the log-likelihood, the ELBO. Diffusion models fall in this second class.
In this topic
- 1Maximum Likelihood Estimation (MLE)
- 2Tractable vs Intractable Likelihoods
- 3The Evidence Lower Bound (ELBO)
Maximum Likelihood Estimation (MLE)
MLE finds the parameters that maximize the probability the model assigns to the observed data. Here is the model's density at data point and the sum runs over all examples; taking the log turns the product of per-example probabilities into a numerically stable sum. Maximizing this is equivalent to minimizing the forward KL divergence between the true and model distributions. MLE is the gold standard: a model at the global optimum has matched the data distribution exactly. Its weakness is that it needs a computable --- the very thing latent-variable models lack.
MLE minimizes , the forward KL from data to model. Since by the law of large numbers, MLE finds the information-theoretic projection of the data distribution onto the model family. The Fisher information matrix determines the local geometry of this optimization.
Fit a 1D Gaussian to the data points using MLE. What are the optimal and ?
Tractable vs Intractable Likelihoods
A likelihood is tractable when can be computed exactly in polynomial time. Normalizing flows and autoregressive models have tractable likelihoods by construction. A likelihood is intractable when it requires integrating over latent variables , and this integral has no closed-form solution. VAEs and diffusion models have intractable likelihoods because the marginalization over involves summing over all possible latent configurations --- an exponentially large or continuous space. For intractable models, we resort to variational bounds.
Tractability depends on whether can be computed in closed form. For continuous in , the integral has cost on a grid — exponential in dimension. Monte Carlo estimation gives unbiased estimates but grows with the mismatch between the prior and the true posterior . This variance problem motivates importance-weighted bounds and variational inference.
A VAE has a 128-dimensional latent space. Why can we not compute exactly?
The Evidence Lower Bound (ELBO)
When the true likelihood is intractable, we optimize a lower bound instead. The ELBO consists of two terms: a reconstruction term that measures how well the decoder reconstructs data from latent codes, and a KL regularization term that penalizes the encoder for deviating from the prior . The gap between and the ELBO equals , which measures how well the approximate posterior matches the true posterior. A tighter ELBO means better training.
The ELBO derivation uses Jensen's inequality: applied to . The bound is tight when exactly. In diffusion models, the ELBO decomposes into per-step KL terms , each of which reduces to a simple denoising MSE loss.
If a VAE has ELBO nats for a datapoint, and the true nats, what is the KL gap and what does it mean?
Theory Exercise
Problem:
Derive the ELBO starting from . Show that , and explain why maximizing the ELBO is a valid proxy for maximizing the log-likelihood.
Hints:
- Start by writing log P(x) = log integral P(x,z) dz
- Multiply and divide by q(z|x) inside the log
- Use Jensen's inequality to move the log inside the expectation
The previous topic ended on a cliffhanger: for the most expressive models the likelihood is intractable because it hides an integral over unobserved variables. This topic is about those variables and why they are worth the trouble. Start with the problem. A face image has millions of pixels, yet it is really controlled by a handful of factors --- pose, expression, lighting, identity. Modeling all those pixels directly is hopeless; modeling the few hidden factors plus a decoder that paints pixels from them is tractable and, crucially, gives you a knob for each factor. That is the latent-variable idea: sample a simple code from a fixed prior, then transform it through a learned map into data. The price is the inference problem --- recovering which produced a given requires the same intractable marginal . We meet the encoder-decoder framework that sidesteps this with an approximate posterior. This machinery matters here because a diffusion model is, formally, a deep stack of latent-variable models with one latent per noise level.
Definition
A latent-variable model explains observed data through a few hidden variables : draw from a simple prior , then generate via a learned decoder . The data likelihood marginalizes over , and recovering the posterior is the central, generally intractable inference problem.
In this topic
- 1Latent Variables and the Generative Process
- 2The Inference Problem
- 3Encoder-Decoder Framework
Latent Variables and the Generative Process
In a latent variable model, data generation is a two-step process: (1) sample a latent code from a simple prior distribution , typically a standard Gaussian, and (2) transform it through a complex decoder to produce observable data. The prior is deliberately simple --- the complexity is pushed entirely into the decoder. The marginal likelihood integrates over all possible latent codes, which is why it is typically intractable.
The generative process defines a probabilistic graphical model. The manifold hypothesis says real data lies near a low-dimensional manifold in ambient space — the latent dimension captures this. The decoder maps the smooth prior through a nonlinear function, and the image of this map approximates the data manifold.
A latent variable model for face images uses . Dimension controls pose (left-right), controls expression (smile-frown). How would you generate a smiling face looking right?
The Inference Problem
Given observed data , the posterior tells us which latent codes could have produced it. By Bayes' rule it equals divided by the marginal --- and that denominator is the same intractable integral from the likelihood topic. This intractability is the fundamental bottleneck of latent-variable models: without you cannot normalize the posterior. The fix is approximate inference --- replace the true posterior with a tractable family chosen to be close in KL divergence. A VAE's encoder network outputs exactly this approximation, amortizing inference across the whole dataset.
Posterior inference requires Bayes' rule: . The denominator marginalizes over all , which is intractable for nonlinear decoders. The KL divergence measures inference quality and equals the ELBO gap. Amortized inference (training a single encoder network) trades per-example optimality for computational efficiency across the dataset.
Given a photo of a person smiling and facing right, what is intuitively?
Encoder-Decoder Framework
The encoder-decoder framework solves the inference problem by training two networks jointly: an encoder that approximates the intractable posterior (mapping data to latent codes), and a decoder that maps latent codes back to data. The encoder is parameterized as a Gaussian , where neural networks output the mean and variance. Training optimizes the ELBO, which encourages the encoder to match the true posterior while the decoder learns to reconstruct accurately.
The encoder parameterizes . The reparameterization trick makes the sampling path differentiable. Gradients flow through and while is treated as constant noise. This enables end-to-end backpropagation through the stochastic encoder — the same trick used in diffusion model training.
An encoder outputs and for an input image. Sample a latent code using the reparameterization trick.
Theory Exercise
Problem:
A latent variable model has a 2D latent space with prior and decoder where . (a) What is the dimensionality reduction ratio? (b) Can you compute analytically in this case? (c) What family of models does this represent?
Hints:
- This is a linear decoder with Gaussian noise --- a very special case
- When both the prior and likelihood are Gaussian, the marginal is also Gaussian
- Think about Principal Component Analysis (PCA)
Related Problems on PixelBank
So far this chapter has shown how to build models of and how to train them by likelihood; the previous topic added latent variables to make that tractable. But a trained model raises a new question with a surprisingly hard answer: is it any good? For a classifier, accuracy gives one clean number. For a generator there is no ground-truth label to check against --- you are comparing distributions, not predictions. A good generator must satisfy two goals that pull against each other: quality, meaning every individual sample looks realistic, and diversity, meaning the samples cover all of the data's modes. A model that memorizes ten perfect images scores high on quality and near zero on diversity; one that outputs many blurry blends does the reverse. This topic surveys the metrics built to capture both --- Frechet Inception Distance, Inception Score, and precision/recall --- along with their blind spots. Knowing what these numbers do and do not measure is essential, because every diffusion paper you read next reports them as evidence of progress.
Definition
Evaluating a generative model means quantifying how well its samples match the data distribution along two competing axes: quality (each sample is individually realistic) and diversity (the samples cover every mode). Standard metrics --- FID, Inception Score, and precision/recall --- estimate these from features of a pretrained network, and each captures only part of the picture.
In this topic
- 1Frechet Inception Distance (FID)
- 2Inception Score (IS)
- 3Precision and Recall for Generative Models
- 4Perceptual Quality vs Distribution Matching
Frechet Inception Distance (FID)
FID (Heusel et al., 2017) is the most widely used metric for image generation. It extracts features from both real and generated images using a pretrained Inception network, then computes the Frechet distance between the two feature distributions (modeled as Gaussians with means and covariances ). Lower FID means the generated distribution is closer to the real distribution. FID captures both quality (are features realistic?) and diversity (does the feature distribution match?), but it assumes Gaussian feature distributions and is sensitive to sample size.
FID computes the Frechet distance (Wasserstein-2 distance for Gaussians) between feature distributions: . The matrix square root couples the covariance structures. FID is zero iff the Gaussian approximations of both feature distributions are identical, but it ignores all non-Gaussian structure in the feature space.
Model A has FID = 10 on CIFAR-10. Model B has FID = 50. Model C has FID = 3 but was trained on the test set. Which is best?
Inception Score (IS)
The Inception Score (Salimans et al., 2016) measures two properties using a pretrained Inception classifier: (1) quality --- each generated image should be confidently classified (low entropy ), and (2) diversity --- the marginal class distribution should be uniform across all classes (high entropy). The KL divergence between these captures both. Higher IS indicates better quality and diversity. IS has notable limitations: it ignores intra-class diversity, does not compare to real data, and is biased toward ImageNet classes.
IS computes . When every sample is confidently classified () and classes are uniformly represented (), IS achieves its maximum . The metric conflates quality and diversity into a single number — it cannot distinguish a model that generates one perfect image per class from one that generates thousands of varied images per class.
A model generates 1000 images. Every image is confidently classified as 'cat' by Inception. What is the Inception Score, and is this model good?
Precision and Recall for Generative Models
Precision and recall (Sajjadi et al., 2018; Kynkaanniemi et al., 2019) separate quality from diversity. Precision measures the fraction of generated samples that fall within the real data distribution (quality). Recall measures the fraction of real data that falls within the generated distribution (diversity/coverage). A model with high precision but low recall generates realistic but repetitive samples (mode collapse). A model with high recall but low precision covers all modes but with poor sample quality. FID conflates both into a single number; precision/recall gives a more nuanced picture.
Precision estimates and recall estimates using -NN manifold estimation. The -th nearest neighbor distance defines a local radius around each sample, approximating the support. This is a geometric measure — it captures whether generated and real samples occupy the same regions of feature space, not just whether their summary statistics match.
Model X: precision = 0.95, recall = 0.30. Model Y: precision = 0.70, recall = 0.85. Which should you choose for (a) a product catalog, (b) data augmentation?
Perceptual Quality vs Distribution Matching
There is a fundamental tension in generative model evaluation between perceptual quality (does each sample look good to humans?) and distribution matching (does the model capture the true data distribution?). FID and IS use pretrained classifiers as proxies for human judgment, but they can be fooled by adversarial examples or textures that activate classifier features without looking realistic to humans. Human evaluation remains the gold standard for perceptual quality but is expensive and subjective. Recent metrics like CMMD (CLIP Maximum Mean Discrepancy) and DINOv2-based FID try to use better feature extractors, but no single metric fully captures generative quality.
Perfect distribution matching () implies perfect perceptual quality, but the converse is false. Metrics based on pretrained features measure quality in a learned representation space, not pixel space. The Information-Distortion plane from rate-distortion theory formalizes this: at finite capacity, models must trade off between how much of the data distribution they cover and how accurately they represent each mode.
Two diffusion models produce similar FID scores on ImageNet. Model A generates photorealistic images but occasionally has artifacts (extra fingers in hands). Model B generates slightly softer images with no artifacts. Human evaluators strongly prefer Model B. Why does FID miss this?
Theory Exercise
Problem:
A researcher reports: 'Our model achieves FID = 5.2, IS = 210, precision = 0.92, recall = 0.45 on ImageNet 256x256.' Provide a detailed interpretation. What are the strengths and weaknesses of this model? What additional evaluation would you recommend?
Hints:
- FID of 5.2 is competitive with state-of-the-art models
- The precision-recall gap tells you about mode coverage
- Think about what these automated metrics miss
The previous topic gave us the scoreboard --- quality versus diversity, and the metrics that measure them. Now we can ask the question this whole chapter has been building toward: given every generative family and every way to grade them, why did diffusion models win? The honest answer is that no earlier family scored well on all the axes at once. GANs were sharp but unstable and prone to mode collapse; VAEs were stable but blurry; flows and autoregressive models gave exact likelihoods but paid in constrained architectures or glacial sampling. Diffusion models reach for all of it with one deceptively simple idea: define a fixed process that slowly adds noise until data becomes pure static, then train a network to undo that process one small step at a time. Because each step is a tiny, easy denoising problem, training is a stable regression --- no adversarial game --- yet the many steps compose into sharp, diverse, high-fidelity samples. This topic makes the case concrete, comparing diffusion against each prior family before the next chapter builds its mathematics.
Definition
Diffusion models generate data by learning to reverse a fixed, gradual noising process. A forward Markov chain adds Gaussian noise over many steps until data becomes pure noise; a neural network is trained to denoise one step at a time. This turns generation into a sequence of simple, stable regression problems that together yield sharp, diverse samples.
In this topic
- 1The Core Idea: Gradual Denoising
- 2Advantages Over GANs
- 3Advantages Over VAEs
- 4The Flexibility of the Diffusion Framework
The Core Idea: Gradual Denoising
The forward process gradually adds Gaussian noise to data over steps (typically ), transforming any data distribution into pure noise. The reverse process learns to undo each step of this noising. Because each step makes only a small change, the reverse process at each step is approximately Gaussian --- a simple distribution that neural networks can model accurately. This is the key insight: instead of learning to generate data in one shot (which is very hard), diffusion models break generation into many small, easy denoising steps.
Each reverse step approximates , which is nearly Gaussian when is small. This is because the reverse of a small perturbation is itself a small perturbation — formally, when , the reverse transition converges to a Gaussian by the central limit theorem applied to the posterior. Breaking generation into small steps converts one hard problem into easy regression problems.
A diffusion model uses steps to convert a face image to pure noise. At step , what does look like?
Advantages Over GANs
Diffusion models solve GANs' three biggest problems:
-
Training stability: No adversarial game. The training objective is a simple denoising loss (mean squared error), which is stable and well-understood. There is no discriminator to balance against the generator.
-
Mode coverage: The forward process visits all data modes uniformly, and the denoising objective ensures the reverse process covers them all. There is no mechanism for mode collapse because the model is trained on every data point at every noise level.
-
Evaluation: Diffusion models provide tractable likelihood bounds (via the variational lower bound on the reverse process), unlike GANs which have no density estimation capability.
The trade-off is sampling speed: GANs generate in one forward pass, while diffusion models require many iterative steps.
The diffusion training loss is a simple mean-squared error with no adversarial component. There is no discriminator to collapse, no gradient penalty to tune, and no equilibrium to maintain. The loss landscape is smooth and well-conditioned because the denoising targets are drawn uniformly across all noise levels, ensuring the model sees every data mode at every scale.
A research team switches from StyleGAN2 (FID=3.8) to a diffusion model (FID=2.1) on FFHQ. What practical differences should they expect?
Advantages Over VAEs
Diffusion models also address VAEs' key weaknesses:
-
Sample sharpness: VAEs produce blurry samples because the decoder averages over posterior uncertainty. Diffusion models generate sharp samples because each denoising step makes a definite prediction, and the iterative process allows the model to commit to specific details progressively.
-
Expressiveness: VAE posteriors are typically simple Gaussians. Diffusion models implicitly define a highly expressive posterior over denoising trajectories, with each step refining the approximation.
-
Architecture flexibility: The denoising network can be any architecture (U-Net, Transformer, etc.) without the encoder-decoder bottleneck constraint of VAEs.
Diffusion models can be viewed as a hierarchical VAE with latent layers, where each layer's prior is conditioned on the layer above.
Diffusion models can be viewed as hierarchical VAEs with stochastic layers, where each layer's prior is the forward process posterior. The key difference: the forward process is fixed (not learned), eliminating the posterior collapse problem. The ELBO decomposes into independent denoising terms, each a simple MSE. The effective posterior is the full reverse trajectory — far more expressive than a single Gaussian.
A VAE generates a face image that is blurry around the eyes. How would a diffusion model handle the same generation?
The Flexibility of the Diffusion Framework
Beyond raw quality, diffusion models offer remarkable flexibility:
-
Conditional generation: Guide the denoising process with text, class labels, or other signals via classifier-free guidance. This enables text-to-image (Stable Diffusion, DALL-E 3), text-to-video, and text-to-audio.
-
Inpainting and editing: Start the reverse process from a partially noised version of an existing image to edit specific regions while preserving the rest.
-
Super-resolution: Condition the denoising on a low-resolution input to generate high-resolution outputs.
-
Latent space control: Latent diffusion models (Rombach et al., 2022) run the diffusion process in a compressed latent space for efficiency, enabling Stable Diffusion to run on consumer GPUs.
-
Theoretical connections: Diffusion models connect to score matching, stochastic differential equations, and optimal transport, providing rich theoretical foundations.
Classifier-free guidance modifies the score: . This steers sampling toward high-likelihood regions under the conditional model without requiring a separate classifier. The guidance weight controls the quality-diversity trade-off: higher gives sharper, more condition-adherent samples at the cost of reduced variety.
How can the same diffusion model perform both unconditional image generation and text-conditioned generation?
Theory Exercise
Problem:
Compare diffusion models with the four previous generative model families (GANs, VAEs, Flows, Autoregressive) across five criteria: (1) training stability, (2) sample quality, (3) mode coverage, (4) sampling speed, (5) likelihood estimation. Create a ranking from 1 (worst) to 5 (best) for each criterion and each model family. Where do diffusion models win, and where do they lose?
Hints:
- Diffusion models trade sampling speed for nearly everything else
- Flows and autoregressive models have exact likelihoods
- GANs are the fastest samplers but the least stable