Constrained Sampling for Language Models Should Be Easy: An MCMC Perspective
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 14 papers in the map (data through 14 Oct 2026). Builds on 25 of its 57 references that are in the map. First posted on arXiv 6 Jun 2025.
Builds on
25 of 57 references.
References · 25
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Diffusion-LM Improves Controllable Text Generationcited by 1,027
- 2023LeanDojo: Theorem Proving with Retrieval-Augmented Language Modelscited by 427
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
- 2022Efficient Training of Language Models to Fill in the Middlecited by 255
- 2017Lexically Constrained Decoding for Sequence Generation Using Grid Beam Searchcited by 237
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 197
- 2018Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translationcited by 182
- 2021Constrained Language Models Yield Few-Shot Semantic Parserscited by 163
- 2022COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamicscited by 161
- 2021NeuroLogic A*esque Decoding: Constrained Text Generation with Lookahead Heuristicscited by 154
- 2020NeuroLogic Decoding: (Un)supervised Neural Text Generation with Predicate Logic Constraintscited by 149
13 more
- 2016Guided Open Vocabulary Image Captioning with Constrained Beam Searchcited by 105
- 2024Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Modelscited by 96
- 2023Sequential Monte Carlo Steering of Large Language Models using Probabilistic Programscited by 80
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 71
- 2023Tractable Control for Autoregressive Language Generationcited by 65
- 2022Gradient-Based Constrained Sampling from Language Modelscited by 64
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 43
- 2018Evaluating Fuzz Testingcited by 32
- 2024Adaptable Logical Control for Large Language Modelscited by 30
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2023Zero and Few-shot Semantic Parsing with Ambiguous Inputscited by 16
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
- 2022CodePAD: Sequence-based Code Generation with Pushdown Automatoncited by 7
Built on by
Citing papers per year: 2025: 3; 2026: 11.
14 papers.
Sort:
By area:
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generationcited by 5
- 2025Constrained Adaptive Rejection Samplingcited by 3
- 2026The Format Taxcited by 3
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Modelscited by 1
- 2026LatticeBridge: Rare-Event Sequential Inference for Faithful Structured Sequence Synthesiscited by 1
- 2026The Alignment Problem in Constrained Code Generationcited by 1
- 2026DecompressionLM: Deterministic, Diagnostic, and Zero-Shot Concept Graph Extraction from Language Modelscited by 0
- 2026Continuous Diffusion Models Can Obey Formal Syntaxcited by 0
- 2026Length Value Model: Scalable Value Pretraining for Token-Level Length Modelingcited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decodingcited by 0
- 2026Provably Tractable NFA-Constrained Language Generation via HMMs30 Sep 2026
- 2026Explore Broadly, Reason Sharply: Push Small Models toward the Frontier via Sampling29 Sep 2026
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding10 Aug 2026
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code15 Jul 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026Length Value Model: Scalable Value Pretraining for Token-Level Length Modeling29 Apr 2026
- 2026LatticeBridge: Rare-Event Sequential Inference for Faithful Structured Sequence Synthesis22 Apr 2026
- 2026The Format Tax4 Apr 2026
- 2026Continuous Diffusion Models Can Obey Formal Syntax12 Feb 2026
- 2026DecompressionLM: Deterministic, Diagnostic, and Zero-Shot Concept Graph Extraction from Language Models30 Jan 2026
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Models5 Dec 2025
- 2026Continuous Diffusion Models Can Obey Formal Syntaxcited by 0
- 2026Continuous Diffusion Models Can Obey Formal Syntax12 Feb 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generationcited by 5
- 2025Constrained Adaptive Rejection Samplingcited by 3
- 2026The Format Taxcited by 3
- 2026LatticeBridge: Rare-Event Sequential Inference for Faithful Structured Sequence Synthesiscited by 1
- 2026The Alignment Problem in Constrained Code Generationcited by 1
- 2026DecompressionLM: Deterministic, Diagnostic, and Zero-Shot Concept Graph Extraction from Language Modelscited by 0
- 2026Length Value Model: Scalable Value Pretraining for Token-Level Length Modelingcited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decodingcited by 0
- 2026Provably Tractable NFA-Constrained Language Generation via HMMscited by 0
- 2026Provably Tractable NFA-Constrained Language Generation via HMMs30 Sep 2026
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding10 Aug 2026
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code15 Jul 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026Length Value Model: Scalable Value Pretraining for Token-Level Length Modeling29 Apr 2026
- 2026LatticeBridge: Rare-Event Sequential Inference for Faithful Structured Sequence Synthesis22 Apr 2026
- 2026The Format Tax4 Apr 2026
- 2026DecompressionLM: Deterministic, Diagnostic, and Zero-Shot Concept Graph Extraction from Language Models30 Jan 2026
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation27 Nov 2025
- 2025Constrained Adaptive Rejection Sampling2 Oct 2025