Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Constrained Sampling for Language Models Should Be Easy: An MCMC Perspective

About

Constrained decoding enables Language Models (LMs) to produce samples that provably satisfy hard constraints. However, existing constrained-decoding approaches often distort the underlying model distribution, a limitation that is especially problematic in applications like program fuzzing, where one wants to generate diverse and valid program inputs for testing purposes. We propose a new constrained sampling framework based on Markov Chain Monte Carlo (MCMC) that simultaneously satisfies three core desiderata: constraint satisfying (every sample satisfies the constraint), monotonically converging (the sampling process converges to the true conditional distribution), and efficient (high-quality samples emerge in few steps). Our method constructs a proposal distribution over valid outputs and applies a Metropolis-Hastings acceptance criterion based on the LM's likelihood, ensuring principled and efficient exploration of the constrained space. Empirically, our sampler outperforms existing methods on both synthetic benchmarks and real-world program fuzzing tasks.

Emmanuel Anaya Gonzalez, Sairam Vaidya, Kanghee Park, Ruyi Ji, Taylor Berg-Kirkpatrick, Loris D'Antoni• 2025

Related benchmarks

TaskDatasetResultRank
Text-to-SQLSpider (dev)
EX56.9
196
PlanningPDDL
Progress Rate100
33
XML FuzzingXML fuzzing benchmarks
Mean Lines Covered8.02e+3
27
JSON FuzzingJSON
Line Coverage3.24e+3
24
FuzzingJSON fuzzing target
Generations to Find 100 Valid Samples1.00e+3
24
Molecular GenerationHydrocarbon Chains
Sample Efficiency1.00e+3
21
Molecule GenerationIsocyanates
Sample Efficiency1.00e+3
21
Molecular GenerationAcrylates (Acry.)
Sample Efficiency1.00e+3
21
SQL fuzzingSQL fuzzing benchmarks
Mean Lines Covered2.18e+4
19
Molecular GenerationMolecular synthesis Acrylates, Chain Extenders, and Isocyanates classes
Validity79
7
Showing 10 of 10 rows

Other info

Follow for update