Score-Based Generative Model

Machine Learning
Introduced by
Song, Y. & Ermon, S.
Year
2019
Type
Score-based generative model (SDE framework)

What does it do?

A score-based generative model, introduced by Yang Song and Stefano Ermon in 2019 and generalized to the stochastic differential equation (SDE) framework in 2021, learns the score, which is the gradient of the log data density, and uses it to generate new samples.

Within the SDE framework, it is a continuous-time formulation that generalizes diffusion models.

The intuition behind the method

Instead of memorizing what the data looks like, the model learns which direction to nudge any point so that it moves toward regions where real data is dense. That direction is the score: the gradient of the log-density. Once you can point toward higher density from anywhere, you can start from pure noise and follow these directions step by step until you arrive at a realistic sample.

History

Score-based generative modeling was introduced by Song and Ermon in 2019 as generative modeling by estimating gradients of the data distribution. In 2021 Song and colleagues recast the idea in a stochastic differential equation framework, showing that score matching across continuous noise levels generalizes diffusion models and unifies several earlier generative formulations under a single continuous-time view.

When to use it

Consider a score-based model for generating continuous data, such as images, when a large training set is available or a pretrained model can be adapted. Score estimation is data-hungry: the dataset size needed depends on data dimensionality, model size and the noise schedule, and with small datasets the learned score is less reliable. The method does not assume a particular parametric form for the data, but its sampler must be built from the same forward SDE used in training. Density-related tasks are possible, but they require additional computation beyond the learned score. Training and sampling of large models are typically run on GPU or TPU hardware, so limited compute is a practical constraint.

Limitations and considerations

  • The score is estimated reliably only with a large training set or when a pretrained model is used; the sample size needed depends on data dimensionality, model size and the noise schedule.
  • Training and sampling of large models are typically run on GPU or TPU hardware, because sampling requires many network evaluations; smaller models can run on CPU, but more slowly.
  • The reverse-time sampler is determined by the chosen forward drift f and diffusion coefficient g(t), so the sampler configuration must follow the SDE choice.
  • With limited data, the learned score may be poorly estimated, and the generated samples may not reflect the training data.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Learns the gradient of the data log-density directly, so generation follows a score-based description of the data rather than a fixed density family.
  • The continuous-time SDE framework places several diffusion formulations under one description.
  • The score is estimated by a neural network, so no parametric density family has to be specified in advance.
  • Can generate samples of continuous data. Density-related quantities can be derived from the learned score, but only with additional computation.

Applications

  • Generation of continuous data such as images.
  • Density-related modeling of complex continuous data distributions, using likelihood computations that go beyond the raw score.
  • Continuous-time generative modeling, in which discrete-time diffusion formulations can be viewed as discretizations of the SDE framework.

How it works

How it works

1

A neural network s_theta(x, t) is trained to estimate the score of the data distribution, meaning the gradient of the log-density with respect to the input, at a range of noise levels t. Training typically uses a weighted denoising score-matching objective: data are perturbed by the forward process, and the network is regressed onto the score of the perturbation kernel. For Gaussian noise, this score is proportional to the added noise, so equivalent noise-prediction parameterizations are also used in diffusion models. The approach is usually presented as a generalization of diffusion models within the SDE framework.

Formula
s_\theta(x) \approx \nabla_x \log p(x)
2

A forward stochastic differential equation gradually corrupts data into noise over continuous time, with a drift term and a diffusion term injecting Gaussian noise. This defines a smooth family of increasingly noisy distributions whose scores the network learns across all noise levels.

Formula
dx = f(x,t)\,dt + g(t)\,dw
3

Generation uses the reverse-time SDE, in which the unknown score term is replaced by the learned network. The drift f and the diffusion coefficient g(t) come from the forward SDE, so the same functions must be used when sampling. Samples are obtained by numerically integrating this equation from noise back toward the data distribution, for example with the Euler-Maruyama method, or with a predictor-corrector scheme that adds Langevin corrector steps. The number of integration steps and the noise schedule, which fixes how the noise level varies with t, affect both sample quality and computational cost.

Formula
dx = [f(x,t) - g(t)^2 \nabla_x \log p_t(x)]\,dt + g(t)\,d\bar{w}

Common pitfalls

  • Applying the method to a small dataset without a pretrained model, where the score estimate is unreliable.
  • Using a reverse-time sampler written for a different forward drift or diffusion coefficient than the one used in training, which generates samples from the wrong process.
  • Treating the network output as a probability value: the network estimates the gradient of the log-density, which is not itself a normalized density, so density estimates need additional computation.
  • Expecting fast sampling of large models on CPU-only hardware, since sampling requires many network evaluations.

Frequently asked questions

What is the score that the model learns?

The score is the gradient of the log probability density with respect to the input. Knowing it at every point and noise level lets the model push samples toward where real data is concentrated.

How is this related to diffusion models?

It is the mathematical generalization of diffusion models: by formulating the forward corruption and reverse generation as continuous-time stochastic differential equations, score-based modeling unifies diffusion approaches under one framework.

How much data do I need?

No fixed sample size applies in general. Score estimation usually needs a large training set, and the requirement depends on data dimensionality, model size and the noise schedule. With small datasets the learned score is less reliable, so a pretrained model or a simpler generative model may be more suitable, depending on the task and data.

What hardware does it require?

Large models are typically trained and sampled on GPU or TPU hardware, since sampling requires many network evaluations. The sampler must be built from the same forward SDE used in training.

Related methods

Sources

  1. Song, Y. & Ermon, S. (2019). Generative Modeling by Estimating Gradients of the Data Distribution. NeurIPS 32, 11895–11907.

    Open publication reference
  2. Song, Y. et al. (2021). Score-Based Generative Modeling through Stochastic Differential Equations. ICLR.

    Open publication reference