core34 min studyLesson 18 in Engineering

Generative models: factorization and denoising

Compare autoregressive and diffusion objectives through their assumptions, training signals, and sampling procedures.

On this page

What you’ll understand

  • Factor a sequence distribution into conditional probabilities.
  • Explain the forward-noising objective of a DDPM.
  • Separate sample plausibility from factual correctness and coverage.

A generative model specifies or learns a distribution from which new examples can be sampled. It is not just a classifier run backward. Autoregressive models build a joint distribution through ordered conditionals; diffusion models learn a reverse process related to a chosen noising process. Both can produce compelling samples, but their objectives, computational costs, and failure modes are different enough to deserve separate mental models.

Autoregression makes a joint distribution tractable

The probability chain rule expresses a sequence's joint probability as a product of next-element conditional probabilities. Choosing an ordering is a modeling decision; the identity itself does not assume independence. A neural network parameterizes each conditional using an allowed prefix. Training on observed prefixes can evaluate many token losses in parallel with a causal mask, while ordinary left-to-right sampling must choose earlier tokens before conditioning on them to generate later ones.

Negative log likelihood sums the negative logarithms of conditional probabilities. This teaches the model to assign probability to observed sequences, not to verify the truth of every sentence. At generation time, a model may condition on its own earlier mistakes rather than the clean prefixes seen during training. Sampling temperature or truncation changes the generation policy and its output distribution. A fluent sample can still be false, unsafe for a particular use, or unrepresentative of rare training modes.

−log⁡pθ(x1:T)=−∑t=1Tlog⁡pθ(xt∣x<t)-\log p_\theta(x_{1:T})=-\sum_{t=1}^{T}\log p_\theta(x_t\mid x_{<t})
This is exact for the autoregressive factorization. Training examples require the intended tokenization and causal prefix; reducing by sequence or token count creates different weighting when lengths vary.↔ Scroll wide equations horizontally.

Diffusion learns to reverse a specified corruption

A standard Gaussian DDPM defines a forward process that gradually adds noise to continuous data. A useful property is that a noisy sample at any chosen timestep can be generated directly from a clean example and Gaussian noise, without simulating every earlier step. The cumulative noise schedule determines how much original signal remains. A network receives the noisy sample and timestep and can be trained to predict the added noise under a commonly used simplified squared-error objective.

Generation begins from an approximate terminal noise distribution and applies a learned reverse procedure. The reverse conditionals depend on the data distribution; simply negating the forward noise does not recover an unknown original. Finite-step DDPMs use a parameterized reverse model, and alternative samplers can trade step count against error and sample behavior. Do not generalize the continuous Gaussian formula to discrete tokens without changing the corruption model and associated derivation. Conditioning, such as text guidance, also changes the learned or sampling distribution.

xt=α‾t x0+1−α‾t ϵ,ϵ∼N(0,I),α‾t=∏s=1t(1−βs)x_t=\sqrt{\overline\alpha_t}\,x_0+\sqrt{1-\overline\alpha_t}\,\epsilon,\qquad \epsilon\sim\mathcal N(0,I),\quad\overline\alpha_t=\prod_{s=1}^{t}(1-\beta_s)
This marginal formula assumes the standard variance-preserving Gaussian forward process with 0<beta_s<1. x_0 is continuous, preprocessed data, and epsilon is independent Gaussian noise.↔ Scroll wide equations horizontally.

Objectives and samples answer different questions

A denoising objective tells the network which noise component to estimate at each corruption level. A small training loss alone does not establish high-quality generation or complete coverage of the data distribution. A sampler can generate visually appealing common cases while missing uncommon modes. Likelihood-based scores, perceptual measures, diversity tests, and human or task-specific evaluations probe different properties and may disagree. State which failure would matter in the intended application before choosing a metric.

Inspect training-data provenance and evaluation contamination. A generator may reproduce a memorized item rather than create a meaningfully new one. Compare near-duplicates and evaluate on cases separated from training sources where possible. Generated data can support simulation or prototyping, but a plausible sample is not an observation of the world. For a scientific or operational claim, require external evidence or a validated generative model with clearly stated assumptions, uncertainty, and a defined domain of use.

Lsimple=Ex0,t,ϵ[∥ϵ−ϵθ(xt,t)∥22]L_{\mathrm{simple}}=\mathbb E_{x_0,t,\epsilon}\left[\lVert\epsilon-\epsilon_\theta(x_t,t)\rVert_2^2\right]
This is a common DDPM noise-prediction training objective with a specified timestep sampling distribution. It is a simplified weighted-objective choice, not a claim that every diffusion model uses this exact loss.↔ Scroll wide equations horizontally.

Follow signal and noise numerically

For one scalar coordinate, let x₀=2, cumulative alpha=0.64, and sampled noise epsilon=−1. Construct x_t and compare the signal and noise contributions.

  1. The signal coefficient is sqrt(0.64)=0.8, so the clean-data contribution is 0.8×2=1.6.

  2. The noise coefficient is sqrt(1−0.64)=0.6, so the sampled noise contribution is 0.6×(−1)=−0.6.

  3. Add the contributions to obtain x_t=1.0. Given x_t alone, the network does not know x₀ or epsilon uniquely; it learns a statistical noise estimate from many training pairs and the timestep.

The result

The noisy coordinate equals 1.0. This constructed pair gives a known training target, not an exact inversion algorithm for an arbitrary unseen noisy coordinate.

Explore the model

Interactive lab

Interactive lab · probability

A distribution is more than one sample

Change p and n in the exact binomial lab to compare probability mass across possible outcomes. This discrete model illustrates coverage and distribution shape; it is not a DDPM, Gaussian noising process, or text generator.

A distribution is more than one sampleThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA generative model must be assessed as a distribution, not only through a few attractive selected samples.

Check your understanding

What makes the displayed Gaussian diffusion training pair directly constructible?

Try it yourself

An autoregressive binary sequence model has p(x₁=1)=0.6 and p(x₂=0|x₁=1)=0.25. Find the probability and negative log likelihood of the sequence (1,0).

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Multiply conditional probabilities before taking the negative natural logarithm, or add their negative logs.

Compare with the solution

The joint probability is 0.6×0.25=0.15. The negative log likelihood is −ln(0.15), approximately 1.897. No independence assumption was made: the second probability is explicitly conditioned on the first outcome. A different prefix can have a different second-step distribution.

Take it with you

  • Autoregressive likelihood is a sum of conditional log losses.
  • A DDPM learns a reverse model tied to a specified forward corruption.
  • Plausibility, novelty, coverage, and truth require different evidence.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.