Score-Based Metropolis-Hastings Algorithms

Ahmed Aloui, Ali Hasan, Juncheng Dong, Zihao Wu, Vahid TarokharXiv 2025 · DOI

Abstract

Score-based generative models have emerged as a powerful paradigm for modeling complex data distributions by learning the score function—the gradient of the log-density. However, sampling from these models typically relies on the Unadjusted Langevin Algorithm (ULA), which lacks a correction mechanism, leading to discretization errors and poor mode-mixing. We present Score Balance Matching (SBM), a novel framework that enables the integration of Metropolis-Hastings (MH) adjustment into score-based sampling. By learning the MH acceptance probability directly from scores, our approach significantly improves sample fidelity and robustness across a range of challenging distributions.

Introduction

The success of score-based generative models is largely attributed to their ability to learn the local geometry of the data distribution without requiring an explicit normalized density. Despite this, the standard sampling procedure, ULA, is "unadjusted," meaning it does not account for the errors introduced by finite step sizes. This often results in biased samples and a failure to accurately capture the relative weights of different modes in multi-modal distributions.

In classical Bayesian computation, the Metropolis-Hastings algorithm provides a rigorous way to correct such errors by using the target density to accept or reject proposed moves. The challenge in score-based modeling is that the density is unknown. This paper bridges that gap by demonstrating that the MH acceptance ratio can be estimated using only the learned score function.

Methodology: Score Balance Matching (SBM)

The core innovation is the Score Balance Matching (SBM) objective. Instead of requiring the global density, SBM leverages the detailed balance condition, a fundamental property of Markov chains in equilibrium.

The SBM Objective

The authors define a loss function that minimizes the discrepancy between the gradients of the log-acceptance ratio and the gradients of the score and proposal functions. This allows a neural network to be trained to predict the acceptance probability $a(x', x)$ for any transition from $x$ to $x'$.

Entropy Regularization

A key discovery during development was that the SBM loss admits trivial solutions, such as a model that rejects all samples. To ensure the learned sampler is efficient, an entropy regularization term is added to the objective. This term encourages the model to find solutions with higher average acceptance rates, preventing the Markov chain from becoming "lazy."

Score-Based MH Variants

The learned acceptance function is applied to several standard MH variants, including Score Random Walk (RW), the Score Metropolis-Adjusted Langevin Algorithm (MALA), and Score Preconditioned Crank-Nicolson (pCN).

Key Insights and Results

One of the most compelling findings is that the MH adjustment step allows the sampler to correctly represent the relative weights of different clusters. While ULA often produces an incorrect balance between modes, the score-based MH methods accurately recover the ground truth distribution.

Comparison of sampling methods on a multi-modal distribution. ULA (b) fails to capture the correct mode weights (0.52, 0.48) compared to the original (0.8, 0.2), while Score RW (c) and Score MALA (d) significantly improve the balance.

Performance Benchmarks

  • Synthetic Manifolds: On datasets like Moons and Pinwheel, Score MALA consistently achieved lower Wasserstein distances (W1/W2) and Maximum Mean Discrepancy (MMD) than ULA. For instance, in the Moons dataset, the W1 error was reduced by nearly an order of magnitude.
  • Heavy-Tailed Distributions: Standard Langevin samplers often fail when dealing with heavy-tailed distributions, such as the Generalized Extreme Value (GEV) distribution. Score-based MALA demonstrated remarkable stability, tracking the ground truth even in cases with infinite higher-order moments.
  • High-Dimensional Stability: On the MNIST dataset, "Annealed Score MALA" proved far more robust to changes in the step-size parameter than its unadjusted counterpart, maintaining high sample quality where ULA's performance collapsed.

Conclusion

Score Balance Matching provides a principled way to bring the benefits of Metropolis-Hastings to the score-based modeling pipeline. By re-introducing the adjustment step, we can mitigate discretization bias and improve mode-mixing without needing the underlying density. While training an additional acceptance network introduces some computational overhead, the gains in sample quality and algorithmic robustness make it a promising direction for high-fidelity generative modeling.

Summary updated

BibTeX
@misc{aloui2025score,
  author = {Ahmed Aloui and Ali Hasan and Juncheng Dong and Zihao Wu and Vahid Tarokh},
  title = {{Score-Based Metropolis-Hastings Algorithms}},
  year = {2025},
  eprint = {2501.00467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.00467},
}
Figure