Langevin Sampling
From the book
Chapter 17: Score Function and Energy-Based Models. In the chapter mind map this icon labels Langevin Sampling & Score-Based Diffusion. The discussion below is excerpted and lightly edited from § Applications of Score-Based Models in Mathematics for AI and Machine Learning. Related material also appears in Chapter 18 (Energy Models: Sampling from EBMs).
__Image Generation__: NCSN[^ncsn] and DDPM[^ddpm] train one network $\mathbf{s}_\theta(\mathbf{x}, \sigma)$ on all noise levels with the multi-scale DSM objective above; by @eq:dsm-optimal it is also a denoiser at every level. Generation starts from noise at the largest $\sigma$ and follows the score while $\sigma$ shrinks, with the Langevin updates previewed below (Chapter the referenced section) or their continuous-time limits (Chapters the referenced section and the referenced section).
__Example: Classifier-Free Guidance__: Text-to-image models sample from a sharpened conditional $p_w(\mathbf{x}\mid y)\propto p(\mathbf{x})\,p(y\mid\mathbf{x})^{1+w}$ with guidance weight $w\geq 0$. Its normalizer does not depend on $\mathbf{x}$, and by Bayes' rule $\nabla_{\mathbf{x}}\log p(y\mid\mathbf{x})=\nabla_{\mathbf{x}}\log p(\mathbf{x}\mid y)-\nabla_{\mathbf{x}}\log p(\mathbf{x})$, so
Classifier guidance plugs a separately trained classifier into $\nabla_{\mathbf{x}}\log p(y\mid\mathbf{x})$; classifier-free guidance needs none, because one network trained with the label randomly dropped gives both scores. With $\mathbf{s}=-\boldsymbol\xi_\theta/\sigma$ from Tweedie's formula, @eq:classifier-free-guidance becomes the noise-prediction rule $\hat{\boldsymbol\xi}=(1+w)\,\boldsymbol\xi_\theta(\tilde{\mathbf{x}},y)-w\,\boldsymbol\xi_\theta(\tilde{\mathbf{x}})$ used in text-to-image diffusion models: $w=0$ is plain conditional sampling, and $w>0$ extrapolates away from the unconditional prediction, trading diversity for fidelity to the prompt. The same rule holds for any prediction that is an affine function of the score with coefficients that do not depend on $y$, because the weights $1+w$ and $-w$ sum to one. A flow-matching velocity is such a function (the matrix chapter), so a guided flow integrates $\mathbf v_w = (1+w)\,\mathbf v_\theta(\mathbf x, t, y) - w\,\mathbf v_\theta(\mathbf x, t)$.
__Connection to Variational Autoencoders__: A VAE (Chapter the referenced section) maximizes the ELBO of Section the referenced section, which falls short of $\log p(\mathbf{x})$ by the posterior KL gap. DSM involves no bound: its minimizer is the exact noisy score (@eq:dsm-optimal). The two combine in latent diffusion: a VAE compresses images to codes $\mathbf{z}$, and a score model is trained on $\mathbf{z}$, where the dimension is far smaller and sampling is cheaper.
__Connection to Generative Adversarial Networks__: A GAN solves a minimax game (Chapter the referenced section, Section the referenced section) whose ideal value is the JS divergence (Section the referenced section), and its generator is prone to the mode collapse described for reverse KL in Section the referenced section. DSM is a plain regression against fixed targets: no adversary, no saddle point. Every training sample asks for the correct score near itself, so a mode that holds data cannot be ignored without paying in the loss.
Score matching has the opposite weakness: it sees every mode but is blind to how much mass each mode holds. Take the mixture of Example the referenced section in one dimension, with unit variances, modes at $\pm a$, and weights $\pi$ and $1 - \pi$. Writing $p_\pi(x) \propto e^{-(x^2 + a^2)/2}\left(\pi e^{-ax} + (1-\pi) e^{ax}\right)$ and differentiating the logarithm gives
What this drawing shows
What you see. Langevin MCMC chain: each step follows score-driven drift (blue) plus injected noise (red), gradually exploring toward a density mode.
In the mind map. Chapter 17 — Langevin Sampling & Score-Based Diffusion. See From the book above for definitions, figures, and worked examples.
Also appears in Ch. 18 (Energy Models: Sampling from EBMs).
Where to read next
Read the full definitions, figures, and worked examples in Chapter 17: Score Function and Energy-Based Models — see the mind-map node Langevin Sampling & Score-Based Diffusion.
This concept is also referenced in Chapter 18 (Energy Models: Sampling from EBMs).