Manuscript Offprint

arXiv:2609.00905

When Metropolis and Hastings Meet Bradley and Terry: Exact MCMC From Preference Voting

Ariel Smogorghevski, Nir Rosenfeld, Yaniv Romano

Abstract

Sampling from distributions conditioned on desired semantic properties is an emerging challenge in modern generative modeling. Metropolis–Hastings (MH) provides a principled route to conditional sampling, but requires access to exact pointwise target-density evaluations, which are not available in generative settings. Meanwhile, pairwise comparisons by humans or model “judges” are highly accessible and have proved valuable across diverse applications. We introduce Pref-MH, a general exact MH sampler for judge-induced conditional distributions using only stochastic binary pairwise comparisons. Our key observation is that the MH unnormalized density ratio matches the preference odds of the Bradley–Terry (BT) choice model. The central challenge is that while MH requires precise ratio computation, BT judges provide only sampled binary feedback. To this end, we develop a valid accept/reject rule whose resulting Markov chain provably converges to the target distribution. We further show that, for a fixed proposal kernel and budget, Pref-MH is optimal in the Peskun–Tierney sense among this class of exact reversible acceptance rules. Experiments on text generation and molecular design with LLM judges, as well as image generation with VLM judges, demonstrate that Pref-MH provides a practical and flexible approach to conditional sampling when comparative feedback is relatively easy to obtain.

1 Introduction

Drawing samples from conditional distributions is a fundamental challenge in computational statistics and machine learning. Markov Chain Monte Carlo (MCMC) methods provide a canonical framework for this task, with Metropolis–Hastings (MH) serving as one of their most widely used instances [1, 2]. Such methods have found widespread use in probabilistic machine learning and across diverse applications ranging from statistical physics to computational biology [3–8]. Unlike methods that return a single “best” solution, MCMC enables repeated sampling of plausible instances from a target distribution. This makes it especially well suited to tasks requiring multiple diverse outputs, or settings in which a human selects a preferred option from a set of candidates. For example, in molecular design, MCMC can generate multiple molecules that satisfy a given criterion yet differ in their trade-offs across key properties such as efficacy, toxicity, and synthesizability [9–12].

Modern generative models, such as large language models (LLMs) and vision-language models (VLMs), offer the potential to unlock a wide range of new applications that require sampling from

Code is available online at https://github.com/Ariels34/Pref-MH.

Figure

Figure 1: Illustration of our proposed Pref-MH for molecular design for drug discovery. At each step tt: (i) a proposal sample x′x' is generated given the current state x(t)x^{(t)}; (ii) x′x' is then compared against x(t)x^{(t)} by using NN stochastic judge votes; (iii) the proposal x′x' is either accepted or rejected according to our vote-based acceptance rule αN\alpha_N. The right panel summarizes the results of a molecular-design experiment (Section 4.4), highlighting that Pref-MH outperforms the score-based baselines (lower is better).

semantically meaningful conditional distributions over complex modalities [13–17]. However, while sampling from generative models in itself is straightforward, it is unclear how to rigorously ensure that instances are indeed drawn from the correct and full target conditional distribution. For example, if we wish to generate responses that are 'helpful', 'polite', and in 'Shakespearean style', then prompting for these properties does not guarantee that generated completed sequences truly satisfy them, nor does it provide control over the nature of variation across samples.

Our work addresses this gap by introducing a novel Metropolis-Hastings (MH) algorithm tailored to generative models that enables principled conditional sampling. MH algorithms work by repeatedly proposing a candidate sample given the current sample, which is either accepted or rejected according to a predefined acceptance rule designed to ensure convergence to the desired conditional distribution [2, 18, 19]. The key methodological challenge is that implementing the acceptance rule requires access to the true unnormalized density ratios of the target conditional distribution. For current generative models, this is typically infeasible [20]: informally, in our example, this would require computing the probability of any given text under the distribution of all texts that are 'helpful', 'polite', and 'Shakespearean'. Similarly, in molecular design, it would require assigning exact conditional likelihoods to molecules satisfying complex and often competing properties such as efficacy, toxicity, and synthesizability.

To overcome this challenge, we leverage the fact that pairwise comparisons have become ubiquitous in generative modeling, whether in model alignment via human comparative feedback [21–25] or in the use of generative models as “judges” for benchmarks and competitions [26]. Such binary pairwise comparisons are readily obtainable, broadly applicable across tasks, and have often proven effective in practice. However, using pairwise comparisons for conditional sampling raises two difficulties. First, the canonical MH algorithm innately depends on access to pointwise density ratios, making it unclear how to incorporate pairwise feedback. Second, it requires computing density ratios precisely in order to guarantee convergence to the target distribution, whereas judges provide only sample access to stochastic binary votes between alternatives.

This structural limitation raises a fundamental question: how to formulate an exact MCMC sampler when the target distribution is accessible only through stochastic, binary pairwise comparisons? Exactness here means that the resulting chain's stationary distribution matches the desired target judge-induced conditional distribution. In this paper, we show that such exact sampling is indeed possible by introducing Pref-MH: the first exact MH framework that uses only binary pairwise preference comparisons, with support for general state spaces and arbitrary proposal kernels. Figure 1 visualizes the method in the context of de novo molecular design, where the goal is to generate molecules (SMILES-encoded) for downstream drug discovery campaigns; a task we revisit later in our experiments.

References (77)

  • Equation of state calculations by fast computing machines
  • Bayesian parameter estimation in ising and potts models: A comparative study with applications to protein modeling
  • New monte carlo algorithms for protein folding
  • Bayesian inference of phylogeny and its impact on evolutionary biology
  • Improving bayesian population dynamics inference: a coalescent-based model for multiple loci
  • Image segmentation by data-driven markov chain monte carlo
  • Metropolis-hastings generative adversarial networks
  • Computer-aided multi-objective optimization in small molecule discovery
  • Nicolaou and Nathan Brown
  • MARS: Markov molecular sampling for multi-objective drug discovery
  • Mimosa: Multi-constraint molecule sampling for molecule optimization
  • Toward controlled generation of text
  • Plug and play language models: A simple approach to controlled text generation
  • FUDGE: Controlled text generation with future discriminators
  • GeDi: Generative discriminator guided sequence generation
  • Controllable text generation for large language models: A survey, 2024
  • Understanding the metropolis-hastings algorithm
  • Are we really tilting? the mechanics of reward guidance in flow and diffusion models, 2026
  • Deep reinforcement learning from human preferences
  • Learning to summarize from human feedback
  • Training language models to follow instructions with human feedback
  • Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback
  • Direct preference optimization: Your language model is secretly a reward model
  • Judging LLM-as-a-judge with MT-bench and chatbot arena
  • Rank analysis of incomplete block designs: I. the method of paired comparisons
  • Noisy monte carlo: convergence of markov chains with approximate transition kernels
  • Extracting medicinal chemistry intuition via preference machine learning
  • Perfect sampling from pairwise comparisons
  • Markov chain monte carlo with people
  • Uncovering mental representations with markov chain monte carlo
  • Gibbs sampling with people
  • Exposing the implicit energy networks behind masked language models via metropolis-hastings
  • Mix and match: Learning-free controllable text generation using energy language models
  • A block metropolis-hastings sampler for controllable energy-based text generation
  • Principled gradient-based MCMC for conditional sampling of text
  • Constrained sampling for language models should be easy: An MCMC perspective
  • A. Faria, Sweta Agrawal, António Farinhas, Ricardo Rei, José G. C. de Souza, and André F. T. Martins
  • Reasoning with sampling: Your base model is smarter than you think
  • Sergey Levine. Reinforcement learning and control as probabilistic inference: Tutorial and review. arXiv preprint arXiv:1805.00909, 2018. (opens arXiv in a new tab)
  • Roberts and Jeffrey S. Rosenthal
  • Adversarial diffusion distillation
  • SDXL: Improving latent diffusion models for high-resolution image synthesis
  • Qwen3-vl technical report
  • Quantifying the chemical beauty of drugs
  • Estimation of synthetic accessibility score of drug-like molecules based on molecular complexity and fragment contributions
  • Qwen3 technical report, 2025
  • Training verifiers to solve math word problems, 2021
  • Theoretical guarantees on the best-of-n alignment policy
  • Scaling laws for reward model overoptimization
  • A survey of multi-objective sequential decision-making
  • A practical guide to multi-objective reinforcement learning and planning
  • Transforming and combining rewards for aligning large language models
  • DExperts: Decoding-time controlled text generation with experts and anti-experts
  • COLD decoding: Energy-based constrained text generation with langevin dynamics
  • Reward-augmented decoding: Efficient controlled text generation with a unidirectional reward model
  • Controlled decoding from language models
  • The pseudo-marginal approach for efficient monte carlo computations
  • MCMC for doubly-intractable distributions
  • Barker's algorithm for Bayesian inference with intractable likelihoods
  • Efficient bernoulli factory markov chain monte carlo for intractable posteriors
  • Fine-Tuning Language Models from Human Preferences
  • G-eval: NLG evaluation using gpt-4 with better human alignment
  • Aligning with human judgement: The role of pairwise preference in large language model evaluators
  • Chatbot arena: an open platform for evaluating llms by human preference
  • Self-rewarding language models
  • Self-refine: Iterative refinement with self-feedback
  • Selfcheck: Using LLMs to zero-shot check their own step-by-step reasoning
  • Mcmc methods for functions: modifying old algorithms to make them faster
  • The chembl database in 2023: a drug discovery platform spanning multiple bioactivity data types and time periods
  • Findings of the 2023 conference on machine translation (WMT23): LLMs are here but not quite there yet
  • Tower: An open multilingual large language model for translation-related tasks
  • Qwen2.5 technical report, 2024
  • Scaling up CometKiwi: Unbabel-IST 2023 submission for the quality estimation shared task
  • Bleu: a method for automatic evaluation of machine translation
  • A study of translation edit rate with targeted human annotation
  • xCOMET: Transparent machine translation evaluation through fine-grained error detection
  • Theory of point estimation