Constrained Decoding of Diffusion LLMs with Context-Free Grammars
Niels Mündler, Jasper Dekoninck, Martin Vechev
摘要
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. To address this, prior work has proposed constrained decoding to restrict LLM generation to particular formal languages. However, existing works are not applicable to the emerging paradigm of diffusion LLMs, as this requires supporting token generation in arbitrary order instead of the traditional left-to-right order. 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 with holes 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 this task 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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 2 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- OctoPack: Instruction Tuning Code Large Language Models 引用了 Language Models are Few-Shot Learners
- Large Language Diffusion Models 引用了 Language Models are Few-Shot Learners
- Continuous Diffusion Models Can Obey Formal Syntax 引用了 Large Language Diffusion Models
- Synchromesh: Reliable Code Generation from Pre-trained Language Models 引用了 Language Models are Few-Shot Learners
- Lookahead-Then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars 引用了 Large Language Diffusion Models
引用它的顶会 Paper2
它引用的 Paper12
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- SWE-bench: Can Language Models Resolve Real-world Github Issues?Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao 等ICLR 2024 · 2,082 次引用
- Large Language Diffusion ModelsShen Nie, Fengqi Zhu, Zebin You, Xiaolu Zhang 等NeurIPS 2025 · 949 次引用
- OctoPack: Instruction Tuning Code Large Language ModelsNiklas Muennighoff, Qian Liu, Armel Randy Zebaze, Qinkai Zheng 等ICLR 2024 · 203 次引用
- Synchromesh: Reliable Code Generation from Pre-trained Language ModelsGabriel Poesia, Alex Polozov, Vu Le, Ashish Tiwari 等ICLR 2022 · 200 次引用
相关 Paper
- DINGO: Constrained Inference for Diffusion LLMsTarun Suresh, Debangshu Banerjee, Shubham Ugare, Sasa Misailovic 等NeurIPS 2025 · 17 次引用
- Flexible and Efficient Grammar-Constrained DecodingKanghee Park, Timothy Zhou, Loris D'AntoniICML 2025
- Grammar-Constrained Decoding for Structured NLP Tasks without FinetuningSaibo Geng, Martin Josifoski, Maxime Peyrard, Robert WestEMNLP 2023 · 33 次引用
- Guiding LLMs The Right Way: Fast, Non-Invasive Constrained GenerationLuca Beurer-Kellner, Marc Fischer, Martin T. VechevICML 2024 · 93 次引用
- Earley-Driven Dynamic Pruning for Efficient Structured DecodingXintong Sun, Chi Wei, Minghao Tian, Shiwen NiICML 2025
