Constrained Decoding of Diffusion LLMs with Context-Free Grammars
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have shown promising performance across diverse domains. Many practical applications of LLMs, such as code completion and structured data extraction, require adherence to syntactic constraints specified by a formal language. Yet, due to their probabilistic nature, LLM output is not guaranteed to adhere to such formal languages. Prior work has proposed constrained decoding as a means to restrict LLM generation to particular formal languages. However, existing works are not applicable to the emerging paradigm of diffusion LLMs, when used in practical scenarios such as the generation of formally correct C++ or JSON output. In this paper we address this challenge and present the first constrained decoding method for diffusion models, one that can handle formal languages captured by context-free grammars. We begin by reducing constrained decoding to the more general additive infilling problem, which asks whether a partial output can be completed to a valid word in the target language. This problem also naturally subsumes the previously unaddressed multi-region infilling constrained decoding. We then reduce this problem to the task of deciding whether the intersection of the target language and a regular language is empty and present an efficient algorithm to solve it for context-free languages. Empirical results on various applications, such as C++ code infilling and structured data extraction in JSON, demonstrate that our method achieves near-perfect syntactic correctness while consistently preserving or improving functional correctness. Importantly, our efficiency optimizations ensure that the computational overhead remains practical.
Key facts. Cited by 14 papers in the map (data through 14 Oct 2026). Builds on 30 of its 52 references that are in the map. First posted on arXiv 13 Aug 2025.
Builds on
30 of 52 references.
References · 30
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023GPT-4 Technical Reportcited by 18,396
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2024Gemma 2: Improving Open Language Models at a Practical Sizecited by 1,998
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2025Large Language Diffusion Modelscited by 912
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
18 more
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2022Efficient Training of Language Models to Fill in the Middlecited by 255
- 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 189
- 2025DiffuCoder: Understanding and Improving Masked Diffusion Models for Code Generationcited by 187
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2024CodeGemma: Open Code Models Based on Gemmacited by 150
- 2024SWT-Bench: Testing and Validating Real-World Bug-Fixes with Code Agentscited by 133
- 2023What Formal Languages Can Transformers Express? A Surveycited by 124
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 101
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 69
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 41
- 2025Type-Constrained Code Generation with Language Modelscited by 35
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 16
- 2025Enhancing Code Generation for Low-Resource Languages: No Silver Bulletcited by 10
- 2024Constrained Decoding for Fill-in-the-Middle Code Language Models via Efficient Left and Right Quotienting of Context-Sensitive Grammarscited by 8
- 2018Live Functional Programming with Typed Holescited by 7
- 2024Subsequence Matching and Analysis Problems for Formal Languagescited by 1
Built on by
Citing papers per year: 2025: 2; 2026: 12.
14 papers.
Sort:
By area:
- 2025Exploring the Potential of Diffusion Large Language Models in Code Generationcited by 16
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 7
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 4
- 2025DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Patterncited by 2
- 2026AnCoder: Anchored Code Generation via Discrete Diffusion Modelscited by 1
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Modelscited by 1
- 2026Constrained Code Generation with Discrete Diffusioncited by 1
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Modelscited by 1
- 2026The Alignment Problem in Constrained Code Generationcited by 1
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliancecited by 1
- 2026Continuous Diffusion Models Can Obey Formal Syntaxcited by 0
- 2026Beyond the Autoregressive Horizon: A Comprehensive Survey of Diffusion Models, World Modelling, and State Space Models for Codecited by 0
- 2026Intent-Triggered Anchoring for Multi-Token Format Units in Parallel Decoding of Diffusion Language Models12 Oct 2026
- 2026Constraints Are Graphs, Not Chains: Exact Decoding for Diffusion Language Models26 Sep 2026
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliance28 Aug 2026
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata8 Jul 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Models30 May 2026
- 2026Constrained Code Generation with Discrete Diffusion16 May 2026
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models4 May 2026
- 2026Beyond the Autoregressive Horizon: A Comprehensive Survey of Diffusion Models, World Modelling, and State Space Models for Code9 Apr 2026
- 2026Continuous Diffusion Models Can Obey Formal Syntax12 Feb 2026
- 2026AnCoder: Anchored Code Generation via Discrete Diffusion Models5 Feb 2026
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars31 Jan 2026
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 4
- 2026AnCoder: Anchored Code Generation via Discrete Diffusion Modelscited by 1
- 2026Constrained Code Generation with Discrete Diffusioncited by 1
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Modelscited by 1
- 2026Continuous Diffusion Models Can Obey Formal Syntaxcited by 0
- 2026Constraints Are Graphs, Not Chains: Exact Decoding for Diffusion Language Modelscited by 0
- 2026Intent-Triggered Anchoring for Multi-Token Format Units in Parallel Decoding of Diffusion Language Modelscited by 0
- 2026Intent-Triggered Anchoring for Multi-Token Format Units in Parallel Decoding of Diffusion Language Models12 Oct 2026
- 2026Constraints Are Graphs, Not Chains: Exact Decoding for Diffusion Language Models26 Sep 2026
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata8 Jul 2026
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Models30 May 2026
- 2026Constrained Code Generation with Discrete Diffusion16 May 2026
- 2026Continuous Diffusion Models Can Obey Formal Syntax12 Feb 2026
- 2026AnCoder: Anchored Code Generation via Discrete Diffusion Models5 Feb 2026
- 2025Exploring the Potential of Diffusion Large Language Models in Code Generationcited by 16
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 7
- 2025DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Patterncited by 2
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Modelscited by 1
- 2026The Alignment Problem in Constrained Code Generationcited by 1
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliancecited by 1
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliance28 Aug 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models4 May 2026
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars31 Jan 2026
- 2025DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Pattern29 Sep 2025
- 2025Exploring the Potential of Diffusion Large Language Models in Code Generation14 Sep 2025
Similar, not cited
Close in wording, no citation either way
- 2026Locally Coherent Parallel Decoding in Diffusion Language Models
- 2024Grammar-Aligned Decoding
- 2025Free Draft-and-Verification: Toward Lossless Parallel Decoding for Diffusion Large Language Models
- 2025Fast-dLLM: Training-free Acceleration of Diffusion LLM by Enabling KV Cache and Parallel Decoding
- 2025Accelerating Diffusion LLM Inference via Local Determinism Propagation
- 2026d3LLM: Ultra-Fast Diffusion LLM using Pseudo-Trajectory Distillation
- 2025Beyond Confidence: Adaptive and Coherent Decoding for Diffusion Language Models
- 2026HaloBlock: Faster and Better Decoding for Diffusion Large Language Models