☆ Save SMLD (Score Matching with Langevin Dynamics) — Score-Based Sampling
09/13/2026
SMLD (Score Matching with Langevin Dynamics) is a generative approach that learns how to move a sample toward higher-density regions of the data distribution. For high-dimensional data such as images, explicitly evaluating the probability density across the entire space is usually impractical. SMLD avoids that problem by learning a local direction of increasing density rather than the probability value at every point. Langevin Dynamics then uses that learned direction to update an initially noisy sample through a sequence of small steps, gradually moving it toward regions where real data is more likely to lie.
Intuitively: start with something that looks like noise rather than a meaningful image. If we know which direction would make the current sample more consistent with real data, we can move it a little in that direction and repeat. The Score Function provides this local direction, Score Matching trains the model to estimate it, and Langevin Dynamics combines the estimated score with a small amount of noise to carry out the sampling process step by step.
SMLD repeatedly updates a noisy sample by following the learned score
How SMLD Works
-
Learning a direction instead of explicit probability values
- To generate new images, a generative model needs to capture how real images are distributed in data space. Regions containing many plausible samples have high probability density, while unusual or rarely observed configurations lie in lower-density regions.
- For image data, directly evaluating the probability density at every possible point is not realistic because the space is extremely high-dimensional. SMLD therefore focuses on a different quantity: the local direction in which probability density increases.
- That direction is given by the Score Function. At a point x, the score is the gradient of the log probability density, so it indicates the direction of steepest local increase in log density.
- Score Matching trains a model to estimate this Score Function from data samples. Once trained, the model can evaluate the score of the current sample during generation and use it to decide how the sample should move next.
-
From the score to an actual sample update
- Knowing the score is not enough to generate an image by itself. The score tells us which direction is favorable at the current position, but another mechanism is needed to actually move the sample.
- In SMLD, Langevin Dynamics performs that update. It takes the current sample xt and shifts it in the direction suggested by the score.
- This is not a one-shot transformation from noise to a finished image. The algorithm takes a small step, evaluates the score again at the new position, and continues with another small update.
- Put differently, Score Matching is how the model learns where to move, while Langevin Dynamics is how that learned direction is used during sampling.
-
Langevin Dynamics and noise
- Langevin Dynamics does not follow the score deterministically. Each update also includes a small noise term. The score pulls the sample toward regions of higher probability density, while the added noise introduces stochastic variation into the trajectory.
- Without noise, the same starting point and the same score would lead to the same next step. With noise, the score still shapes the overall direction, but the exact path can vary from one run to another.
- This is what separates sampling from simple optimization. SMLD is not trying to converge to a single high-density point; it is designed to generate samples that follow the underlying probability distribution.
- In Langevin Dynamics, the score provides directional guidance, noise keeps the motion stochastic, and repeating both components allows different samples to emerge.
-
Langevin Dynamics update
-
Each Langevin Dynamics step adds two terms to the current sample: one driven by the score and one driven by random noise. The update can be written as follows.
-
$$ x_{t+1}=x_t+\frac{\eta}{2}s(x_t)+\sqrt{\eta}z_t $$
x_t is the current sample, s(x_t) is the score evaluated at that sample, η is the step size controlling the size of each update, and z_t is newly sampled Gaussian noise.
-
The score term nudges the sample toward a region that is more likely under the data distribution. The noise term adds a random perturbation. Together, these two changes transform xt into the next state, xt+1.
-
The process does not stop at xt+1. The score is evaluated again at the new state, another noise sample is drawn, and the next update is computed. Repeating this cycle is the basic idea behind Langevin sampling.
-
-
One update on a 3×3 image
-
For an image, xt is not a single number but a high-dimensional object representing the entire sample. To make the mechanics easier to see, consider the following simplified 3×3 image.
-
$$ x_t=\begin{bmatrix}0.2&0.7&0.4\\0.8&0.3&0.5\\0.1&0.6&0.9\end{bmatrix} $$
Each value represents one element of the simplified image, and the matrix as a whole is the current sample x_t.
-
Assume the model estimates the following score at xt, with η=0.1. Each entry indicates how that dimension should change so that the overall sample moves toward a region of higher probability density.
-
$$ s(x_t)=\begin{bmatrix}0.2&-0.4&0.2\\-0.2&0.4&0.2\\0.4&-0.2&-0.4\end{bmatrix} $$
$$ \frac{\eta}{2}s(x_t)=\begin{bmatrix}0.01&-0.02&0.01\\-0.01&0.02&0.01\\0.02&-0.01&-0.02\end{bmatrix} $$
With η=0.1, the algorithm takes only a small step in the direction indicated by the score instead of applying the full score vector at once.
-
Now suppose the noise contribution for this step is the matrix below. Adding both the score-driven update and the noise term to the current sample gives the next image state.
-
$$ \sqrt{\eta}z_t=\begin{bmatrix}-0.01&0.01&0\\0.01&-0.01&0\\0&0.01&-0.01\end{bmatrix} $$
$$ x_{t+1}=\begin{bmatrix}0.20&0.69&0.41\\0.80&0.31&0.51\\0.12&0.60&0.86\end{bmatrix} $$
The score-driven change and the noise term are applied across the entire sample x_t, producing the new image state x_{t+1}.
-
The important point is that the algorithm updates the entire image state, not one isolated pixel at a time. Once xt+1 has been produced, the model estimates a new score there, adds fresh noise, and takes another step. Repeating this process gradually moves a sample that began as noise toward regions occupied by the data distribution.
-
-
Relationship to diffusion models
- Diffusion models use a forward diffusion process that progressively adds noise to real data and a reverse process that reconstructs data from noisy states. During the reverse process, the model needs information about how the current noisy sample should change to move toward the data distribution.
- The score provides that information locally. It indicates the direction in which probability density increases from the current state, giving the sampler a way to move a noisy sample toward more likely regions of the data space.
- Langevin Dynamics is therefore useful for understanding reverse sampling because it shows how a learned score can be converted into a sequence of stochastic sample updates.
- SMLD can be summarized as learning the direction of the data distribution with Score Matching → repeatedly updating the sample with the score and noise through Langevin Dynamics → generating new samples that follow the probability distribution.
Significance and Limitations
The key idea behind SMLD is the connection between learning a score and using that score to generate samples. Even when the full probability density is difficult to evaluate directly, Score Matching can learn the local directional information needed for generation, and Langevin Dynamics can turn that information into actual sample updates. Because the update combines the score with noise, the process does not merely seek a single high-probability point. Instead, it performs stochastic sampling from the underlying distribution. This perspective is also useful for understanding score-based generative models and reverse sampling in diffusion models.
The main drawback is efficiency. Langevin Dynamics relies on many small updates, so sampling becomes more expensive as the number of steps increases. Sample quality also depends heavily on the accuracy of the learned Score Function; if the score estimate is poor, the trajectory can drift away from the true data distribution. The step size η matters as well because it controls how far the sample moves in each update. In practice, a useful SMLD system must balance reliable score estimation with a stable and computationally efficient sampling procedure.
Recommended prerequisite reading (3/5)
+2
- 8.6 Data Distribution Modeling — How Generative Models Learn Data Distributions
- 8.9 Diffusion Models — Generating Data by Adding and Reversing Noise
- 8.7 Normalizing Constant — Turning Model Scores into Valid Probability Distributions
- Likelihood-Based Modeling — Learning Data Distributions with Maximum Likelihood
- Synthesis and Sampling — How New Data Is Generated from a Model’s Learned Distribution
Recommended next reading (5/16)
+5
- 8.3 Inverse Problems — Understanding Forward and Inverse Problems
- 8.8 Deep Generative Models — Major Approaches to Probability Distribution Modeling
- 8.5 Approximate Inference — Approximating Posterior Distributions with MCMC and Variational Inference
- Sampling-based Inference — Why Probabilistic Token Selection Matters in LLM Decoding
- Distribution Matching — How Generative Models Learn Real-World Data Distributions
- Top-p Sampling (Nucleus Sampling) — Why the Number of Candidates Changes Dynamically
- Likelihood-Free Modeling — Inferring Generative Processes with Simulation-Based Inference
- Conditional Generation — How Generative Models Control Their Outputs
- Sample Generation — How LLMs Select Tokens from a Probability Distribution
- NADE (Neural Autoregressive Distribution Estimator) — How Generative Models Learn Probability Distributions
- Model Distribution — How LLMs Learn Output Probabilities
- Flow-based Models — Learning Data Distributions Through Invertible Transformations
- Conditional Density Modeling — Learning Data Distributions Under Specific Conditions
- 8.4 Posterior Inference — Posterior Distributions and Why Exact Inference Is Hard
- Latent Variable Models — Modeling the Relationship Between Observed and Hidden Variables
- Latent Variable Inference — Inferring Hidden Structure from Observed Data
Posts on the same topic (3/3)
- PixelCNN — How Autoregressive Image Generation Learns Pixel Probabilities
- Density Modeling — How Probability Density Is Estimated from Image Vectors
- Data Distribution vs Model Distribution — How Generative Models Approximate Real-World Data
Related concepts (5/5)
- Score Matching — Learning Data Distributions Through the Score Function
- Stochastic Inference — Reasoning with Uncertainty in AI
- Probability Normalization — How Softmax Converts Model Outputs into a Probability Distribution
- Probability Distribution Comparison — How to Measure and Interpret Differences Between Distributions
- Unnormalized Probability Models — Why Models Use Scores Before Normalization
📍 Where this concept fits in the AI learning map
See where this concept sits within the full AI Universe.
📍 Current position in AI Universe
☰
Reset Show completed · Login required Loading…
🌌 AI Universe
‹
›
⭐ Concept
Select a star.
« Unnormalized Probability…|Score-based Generative M… »
🔖 Tags: Generative Models · Langevin Dynamics · Probability Distribution · sampling · Score Function · Score Matching · SMLD