Score-Based Models and Langevin Dynamics
Rather than learning a data distribution directly, a score-based model learns the direction that makes any point more probable, and then generates samples by repeatedly nudging random noise along that direction with a bit of extra randomness mixed in.
Prerequisites: Denoising Diffusion Probabilistic Models, Gradient Descent
Most generative models try to learn , the probability of seeing data point , directly. That's harder than it sounds — has to integrate to over all possible , a global constraint that makes direct estimation awkward for complex, high-dimensional data. A score-based model sidesteps the problem by learning something that doesn't need to integrate to anything in particular: the score, — the direction, at any point , in which probability increases fastest. Knowing that direction everywhere turns out to be enough to generate samples from , without ever computing itself.
The analogy: finding the top of a hill in the fog
Imagine standing somewhere on a hillside in thick fog, unable to see the whole landscape (you don't know ), but able to feel which way is uphill from wherever you're standing (you know at your current location). Repeatedly stepping uphill, using only that local feel, eventually gets you near a peak — a high-probability region — even though you never once saw the whole hill's shape. That's the entire strategy: learn the local "which way is more probable" direction everywhere, and let repeated small steps do the rest.
Langevin dynamics: uphill steps plus noise
Pure gradient ascent on would march straight to the single highest peak and get stuck there, generating the same point every time. Langevin dynamics fixes this by adding a controlled amount of noise to every step:
In words: take a small step in the uphill (higher-probability) direction, sized by step size , and then add a small random jolt scaled by . The uphill pull keeps you near high-probability regions; the noise stops you from collapsing onto one exact point, and, run for long enough with a properly decreasing , the sequence of 's ends up distributed according to itself, not just clustered near its mode.
Worked example 1: one Langevin step by hand
Say , and the learned score at that point is (probability increases toward smaller here), step size , and a sampled noise . Then:
The deterministic pull moved down by (toward higher probability), but the noise term pushed it up by more, landing slightly higher than overall — a reminder that any single step can move either way; it's the accumulated pull over many steps, with shrinking over time, that converges toward the true distribution's shape rather than one point.
Worked example 2: why the score doesn't need 's normalizing constant
Suppose the true (unnormalized) density is , so the true, normalized density is for some constant that makes it integrate to 1. The score is:
The constant vanished under the gradient, since it doesn't depend on . At : score (already at the peak). At : score (strong pull back toward ). This is the whole reason score-based models are tractable where direct likelihood models struggle — the impossible-to-compute normalizing constant simply never appears in the quantity being learned.
Each wiggly path above is exactly a Langevin trajectory with the deterministic drift term switched off — pure noise. Score-based sampling is this same random walk with a learned "pull toward higher probability" added back in at every step.
A score-based model learns — the local uphill direction of probability — without ever needing 's normalizing constant, and Langevin dynamics generates samples by repeatedly stepping along that direction with injected noise, which keeps the process exploring the full distribution instead of collapsing onto its single peak.
What this means in practice
Score-based models are the mathematical backbone of modern diffusion models: a diffusion model is, at its core, a network trained to estimate the score at every noise level, with sampling implemented as a discretized Langevin-like process run from pure noise down to a clean sample. Understanding the score/Langevin view explains why diffusion sampling needs many small steps rather than one big jump — each step is only a local, noisy uphill move, not a leap to the answer.
The score is only reliable where the model has actually seen data — in low-density regions far from the training distribution, the learned score can be essentially arbitrary, since there was little signal there to learn from. This is why naive Langevin sampling struggles to mix between separate high-probability regions separated by a low-density gap, and why practical diffusion models add noise at multiple scales rather than relying on the score at the original data scale alone.
Related concepts
Practice in interviews
Further reading
- Song & Ermon, Generative Modeling by Estimating Gradients of the Data Distribution (2019)