Generative Models

Score Matching & Score-Based Generative Models

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

status: publishedimportance: importantdifficulty 4/5math: graduateread: 18mlive demo
Editorial generative-model illustration of noisy samples and score-vector fields pointing back toward high-density structure.

Concept Structure

Score Matching & Score-Based Generative Models

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

2prerequisites
1next concepts
2related links

Learning map

Score Matching & Score-Based Generative Models
BeforeMaximum LikelihoodNow4/4 sections readyTryManipulate one control and predict the visible change.NextFlow Matching & Rectified Flows

Object flow

4/4 sections readyAsk about thisResearch room
ConceptScore Matching & Score-Based Generative ModelsGenerative Models
3 sources attachedLocal snapshot ready
concept:generative-models/score-matching

Conceptual Bridge

What should feel connected as you move through this page.

Carry inMaximum Likelihood

Bring the mental model from Maximum Likelihood; this page will reuse it instead of restarting from zero.

Work hereScore Matching & Score-Based Generative Models

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

Carry outFlow Matching & Rectified Flows

The next edge should feel earned: use the demo prediction here before following Flow Matching & Rectified Flows.

Test the linkManipulate one control and predict the visible change.Then continue to Flow Matching & Rectified Flows
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

If a probability distribution p(x)p(x) is a landscape, then logp(x)\log p(x) is a height map, and the score

s(x)=xlogp(x)s(x)=\nabla_x \log p(x)

is the vector field that points "uphill" toward higher density.

Score-based generative modeling is the idea: instead of learning p(x)p(x) directly (which requires a normalizing constant), learn the gradient of the log-density. With estimated time-dependent scores and a specified reverse-time SDE/ODE or Langevin-style sampler, you can move points from noise toward data-like samples.

In Gaussian-noising diffusion parameterizations, predicting noise ϵ\epsilon at each noise level is often equivalent, up to a known scale, to estimating a score.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

The score function and score matching

For a non-normalized model pθ(x)=qθ(x)/Z(θ)p_\theta(x)=q_\theta(x)/Z(\theta), the data-gradient score ignores the constant Z(θ)Z(\theta):

sθ(x)=xlogpθ(x)=xlogqθ(x),LSM=Epdata[12sθ(x)2+tr(xsθ(x))].\begin{aligned} s_\theta(x) &=\nabla_x\log p_\theta(x) = \nabla_x\log q_\theta(x),\\ \mathcal{L}_{SM} &=\mathbb{E}_{p_{\text{data}}}\left[ \frac{1}{2}\|s_\theta(x)\|^2+\mathrm{tr}(\nabla_x s_\theta(x)) \right]. \end{aligned}

This avoids evaluating the normalizing constant, but is hard to implement directly because the derivative-based objective still includes the divergence term.

Denoising score matching (diffusion-friendly)

Add Gaussian noise. The conditional target, noise-prediction scale, and reverse-time dynamics share the same learned score field:

x~=x+σϵ,ϵN(0,I),x~logqσ(x~x)=x~xσ2=ϵσ,sθ(x~,σ)ϵθ(x~,σ)σ,dxrev=[f(x,t)g(t)2sθ(x,t)]dt+g(t)dwˉ,dxflow=[f(x,t)12g(t)2sθ(x,t)]dt.\begin{aligned} \tilde x &= x+\sigma\epsilon,\qquad \epsilon\sim\mathcal{N}(0,I),\\ \nabla_{\tilde x}\log q_\sigma(\tilde x\mid x) &=-\frac{\tilde x-x}{\sigma^2}=-\frac{\epsilon}{\sigma},\\ s_\theta(\tilde x,\sigma)&\approx -\frac{\epsilon_\theta(\tilde x,\sigma)}{\sigma},\\ dx_{\text{rev}} &=\left[f(x,t)-g(t)^2s_\theta(x,t)\right]dt+g(t)d\bar w,\\ dx_{\text{flow}} &=\left[f(x,t)-\tfrac{1}{2}g(t)^2s_\theta(x,t)\right]dt. \end{aligned}

Denoising score matching trains:

LDSM=Esθ(x~,σ)+ϵ/σ2.\mathcal{L}_{DSM}=\mathbb E\,\big\|s_\theta(\tilde x,\sigma) + \epsilon/\sigma\big\|^2.

So predicting noise ϵθ\epsilon_\theta is equivalent (up to scaling) to predicting the score:

sθ(x~,σ)ϵθ(x~,σ)σ.s_\theta(\tilde x,\sigma) \approx -\frac{\epsilon_\theta(\tilde x,\sigma)}{\sigma}.

The conditional DSM target x~logq(x~x)\nabla_{\tilde x}\log q(\tilde x\mid x) is the label for one known clean source; the marginal score field x~logpσ(x~)\nabla_{\tilde x}\log p_\sigma(\tilde x) averages over possible clean sources.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import numpy as np

rng = np.random.default_rng(0)
x = rng.normal(loc=1.5, scale=1.0, size=(5,))
sigma = 0.7
eps = rng.standard_normal(x.shape)
xt = x + sigma * eps

score_from_eps = -eps / sigma
score_from_xt = -(xt - x) / (sigma**2)  # same quantity

print("x:  ", np.round(x, 3))
print("xt: ", np.round(xt, 3))
print("max|diff|:", float(np.max(np.abs(score_from_eps - score_from_xt))))
04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

Use the demo to see the score field and how diffusion "noise prediction" corresponds to a scaled score estimate.

Live Concept Demo

Explore Score Matching & Score-Based Generative Models

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 4/5graduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what Score Matching & Score-Based Generative Models should make visible before reading the result.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

Prediction open01 / Intuition
Editorial generative-model illustration of noisy samples and score-vector fields pointing back toward high-density structure.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Score Matching & Score-Based Generative Models should make visible.

Visual Inquiry

Make the image answer a mathematical question

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Score Matching & Score-Based Generative Models easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

paper · 2005Estimation of Non-Normalized Statistical Models by Score MatchingHyvarinen

Introduces score matching for models where the normalizing constant is intractable.

Open source
paper · 2011A Connection Between Score Matching and Denoising AutoencodersVincent

Grounds denoising score matching as learning to recover clean structure from noisy samples; publisher DOI is 10.1162/NECO_a_00142.

Open source
paper · 2020Score-Based Generative Modeling through Stochastic Differential EquationsSong et al.

Connects learned score fields to reverse-time stochastic dynamics for generation.

Open source

Claim Review

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources3 references

hyvarinen-2005-score-matching, vincent-2011-denoising-score, song-2020-score-sde

Witnesses4 local objects

Use equation, code, and demo objects to check whether the source support is operational.

Substantively reviewedScore matching fits a model score grad_x log p_theta(x) while avoiding the normalizing constant; under Gaussian corruption x_tilde=x+sigma epsilon, the conditional denoising target is -(x_tilde-x)/sigma^2=-epsilon/sigma; estimated time-dependent scores can drive reverse-time SDE/ODE sampling dynamics.Claim metadata: source checked

Hyvarinen supports score matching for continuous non-normalized models because the data score removes Z(theta). Vincent supports the Gaussian DSM target (x-x_tilde)/sigma^2 and DSM/SM equivalence. Song supports reverse SDE sampling and probability-flow ODE dynamics from estimated time-dependent scores. Local math/code/demo cover the score, DSM scaling, conditional-vs-marginal distinction, and reverse bridge.

Sources: Estimation of Non-Normalized Statistical Models by Score Matching, A Connection Between Score Matching and Denoising Autoencoders, Score-Based Generative Modeling through Stochastic Differential EquationsChecks the score, Gaussian conditional DSM label under x_tilde=x+sigma epsilon, and estimated-score reverse SDE/probability-flow ODE bridge. Does not claim exact solvers, conditional labels equal marginal scores, high-dimensional quality, or full DDPM/ELBO training.A bounded review summary is present; still check caveats and exact source scope.

Hyvarinen supports non-normalized score matching: the data-gradient score removes Z(theta) and the implicit objective uses squared score plus divergence terms. Vincent supports the Gaussian conditional DSM target (x-x_tilde)/sigma^2 = -epsilon/sigma and DSM/SM equivalence. Song supports estimated time-dependent scores in reverse SDE sampling and probability-flow ODEs. Local math, code, and demo align with this bounded mechanism without pre-reveal target leakage.

Reviewer: codex+oracle+codex-5.3; reviewed 2026-05-08

Practice Loop

Try the idea before it explains itself

Learn the score field grad_x log p(x) without normalizing constants. Denoising score matching turns diffusion training into simple regression on noise.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Score Matching & Score-Based Generative Models.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Object research drawerClose
ConceptScore Matching & Score-Based Generative ModelsGenerative Models

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptGenerative Models

Score Matching & Score-Based Generative Models

Anchored question

What is the smallest example that makes Score Matching & Score-Based Generative Models click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:generative-models/score-matching.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: hyvarinen-2005-score-matching, vincent-2011-denoising-score, song-2020-score-sde
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Score Matching & Score-Based Generative Models Object key: concept:generative-models/score-matching Context: Generative Models Anchor id: concept/concept-notebook/generative-models/score-matching Open question: What is the smallest example that makes Score Matching & Score-Based Generative Models click without losing the math? Evidence to inspect: - Source ids to inspect: hyvarinen-2005-score-matching, vincent-2011-denoising-score, song-2020-score-sde - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

Open source object
concept/concept-notebook/generative-models/score-matching concept:generative-models/score-matching