A diffusion model is a generative model that learns to create data by reversing a gradual noising process. It is trained to remove noise step by step, turning pure random noise into a coherent sample such as an image.
What a Diffusion Model Is
A diffusion model is a class of generative model that produces new data by learning to undo a corruption process. Training defines a fixed forward process that slowly adds Gaussian noise to a real sample over many steps until almost nothing of the original remains. A neural network then learns the reverse process: given a noisy sample at any step, predict how to make it slightly less noisy. To generate, the model starts from pure noise and applies that learned denoising repeatedly until a clean sample emerges.
The modern formulation was set out by Jonathan Ho, Ajay Jain, and Pieter Abbeel in the 2020 paper Denoising Diffusion Probabilistic Models (DDPM). They framed the method as a latent variable model inspired by nonequilibrium thermodynamics, and showed it could match or beat earlier generative approaches on image benchmarks such as CIFAR-10. The same noising and denoising structure underpins later text-to-image systems.
Diffusion models are most associated with image synthesis, but the framework is general. The same idea has been applied to audio, video, molecular structures, and other continuous data, because the only requirement is a sensible way to add and remove noise on the data type in question.
- Generation is iterative: it walks from noise to data over many small denoising steps.
- The forward noising process is fixed and has no learned parameters.
- Only the reverse denoising process is learned by a neural network.
- The 2020 DDPM paper by Ho, Jain, and Abbeel is the standard reference formulation.
The Forward Noising Process
The forward process is a Markov chain that gradually adds Gaussian noise across T steps. At each step it scales the previous sample down slightly and injects a fixed amount of noise governed by a variance schedule beta_t. Because each step depends only on the one before it, the whole chain is fully specified once the schedule is chosen, with no training required.
A useful property is that the result of many noising steps has a closed form. By defining alpha_t as 1 minus beta_t and alpha_bar_t as the running product of those alpha values, a noisy sample at step t can be drawn directly from the clean sample x_0 in a single shot. This means training never has to simulate the full chain; it can jump straight to any step t.
By the final step T, the variance schedule is set so the sample is essentially indistinguishable from standard Gaussian noise. That endpoint is what generation starts from, which is why the same simple noise prior can seed every new sample the model produces.
- The forward process adds Gaussian noise step by step following a schedule beta_t.
- alpha_t equals 1 minus beta_t, and alpha_bar_t is the cumulative product of alpha values.
- A closed form lets you sample any noised step directly from the clean input.
- After T steps the data has become close to pure standard Gaussian noise.
Training: Predicting the Noise
The network is trained to reverse the forward process, but DDPM does this in a specific way: instead of predicting the clean sample or the reverse mean directly, it predicts the noise that was added. A training step picks a random data point x_0, a random step t, and a random Gaussian noise vector epsilon, builds the noised sample using the closed form, and asks the network to recover that epsilon. This is called noise prediction or epsilon-prediction.
Ho and colleagues found that a simplified objective worked better in practice than the full variational bound. The simplified loss, called L_simple, is just the mean squared error between the true noise epsilon and the network's prediction epsilon_theta, averaged over random steps and inputs. Dropping the theoretical weighting terms made training more stable and produced higher quality samples.
The network itself is typically a U-Net, a convolutional architecture with skip connections, conditioned on the step index t so it knows how much noise to expect. Because every training example reduces to predicting one Gaussian noise vector, the objective is simple to implement and scales well with data and compute.
- The network predicts the added noise epsilon rather than the clean sample directly.
- L_simple is the mean squared error between true and predicted noise.
- The simplified loss drops the variational weighting and trains more stably.
- A U-Net conditioned on the step index t is the usual backbone.
Sampling: DDPM, DDIM, and the Score View
Generation runs the learned reverse process. Starting from pure Gaussian noise at step T, the model uses its noise prediction to estimate a slightly cleaner sample, optionally adds a small amount of fresh noise, and repeats down to step 0. Standard DDPM sampling is stochastic and uses the same number of steps as training, often several hundred to a thousand, which makes it slow.
Denoising Diffusion Implicit Models (DDIM), introduced by Jiaming Song, Chenlin Meng, and Stefano Ermon in 2020, reformulate sampling as a non-Markovian process with the same training objective. DDIM can produce high quality samples in far fewer steps, reported at 10 to 50 times faster than DDPM, and its deterministic variant maps each starting noise to a single output, which enables smooth interpolation between samples.
A parallel line of work by Yang Song and colleagues, published as Score-Based Generative Modeling through Stochastic Differential Equations in 2021, recast diffusion as a continuous process. In that view the network estimates the score, the gradient of the log data density, and sampling solves a reverse-time stochastic differential equation. DDPM and score-based models are two faces of the same underlying mathematics.
- DDPM sampling is stochastic and typically uses hundreds to a thousand steps.
- DDIM reaches comparable quality 10 to 50 times faster and can be deterministic.
- Fewer sampling steps trade some fidelity for much lower generation cost.
- The score-based SDE view by Song et al. unifies diffusion and score matching.
Conditioning and Latent Diffusion
To control what a diffusion model generates, the network is conditioned on extra information such as a text prompt or a class label. Classifier-free guidance, introduced by Jonathan Ho and Tim Salimans in 2022, is the standard technique. The model is jointly trained with and without the condition, and at sampling time the conditional and unconditional noise predictions are combined with a guidance scale that trades sample diversity for closer adherence to the prompt, without needing a separate classifier.
Running diffusion directly on high resolution pixels is expensive. Latent diffusion models, proposed by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer in 2022, address this by first compressing images into a smaller latent space with a pretrained autoencoder, then running the entire diffusion process there. Cross-attention layers inject the text condition into the denoising network.
This latent diffusion design is the technical basis of Stable Diffusion. Operating in a compact latent space cut the compute needed for high resolution synthesis enough to make text-to-image generation practical on consumer hardware, which is a large part of why diffusion-based image models became widely accessible.
- Conditioning feeds a text prompt or class label into the denoising network.
- Classifier-free guidance mixes conditional and unconditional predictions, no classifier needed.
- Latent diffusion runs the process in a compressed autoencoder space to save compute.
- Latent diffusion (Rombach et al., 2022) is the foundation of Stable Diffusion.
Diffusion Versus GANs and Autoregressive Models
Before diffusion took over image generation, generative adversarial networks (GANs) were dominant. GANs pit a generator against a discriminator and produce samples in a single forward pass, which is fast, but training can be unstable and prone to mode collapse, where the generator covers only part of the data distribution. Diffusion models trade speed for stability: training is a straightforward regression on noise, and they tend to cover the data distribution more fully, though sampling takes many steps.
Autoregressive image models generate one pixel or one token at a time, conditioning each output on those already produced. They model the data likelihood directly and can be very high quality, but generation is inherently sequential and slow at high resolution. Diffusion models instead refine the whole image in parallel at each step, which suits the spatial structure of images.
There is no single winner. Diffusion models currently lead much of high quality image and video synthesis, GANs remain useful where single-pass speed matters, and autoregressive transformers dominate language and increasingly compete in multimodal generation. The boundaries continue to shift as methods such as few-step distillation narrow diffusion's sampling cost.
- GANs generate in one pass but can be unstable and suffer mode collapse.
- Diffusion training is a stable regression and covers the data distribution well.
- Autoregressive image models are high quality but generate sequentially and slowly.
- Distillation methods are steadily shrinking diffusion's many-step sampling cost.
Key takeaways
- A diffusion model generates data by reversing a fixed Gaussian noising process step by step.
- DDPM trains a network to predict the noise added at a random step using the L_simple loss.
- A closed form lets training noise any step directly from the clean sample.
- DDIM and step reduction make sampling far faster than the original DDPM loop.
- Classifier-free guidance steers generation toward a prompt without a separate classifier.
- Latent diffusion runs the process in a compressed space and underpins Stable Diffusion.
Frequently asked questions
Related terms
Related reading
Sources
- Ho, Jain, Abbeel. Denoising Diffusion Probabilistic Models (2020)
- Song, Meng, Ermon. Denoising Diffusion Implicit Models (DDIM, 2020)
- Song et al. Score-Based Generative Modeling through SDEs (2021)
- Rombach et al. High-Resolution Image Synthesis with Latent Diffusion Models (2022)
- Ho, Salimans. Classifier-Free Diffusion Guidance (2022)
Put the idea into practice
MemX is an AI memory agent built on these ideas: store anything, skip the folders, and find it again by asking in plain English.
Try MemX Free