Grammar-Aligned Decoding
Open accessThe DOI matches its Crossref record; 7 of the 11 references it cites were found in a registry or an index, and 4 are not checked yet.
Abstract
Large Language Models (LLMs) struggle with reliably generating highly structured outputs, such as program code, mathematical formulas, or well-formed markup. Constrained decoding approaches mitigate this problem by greedily restricting what tokens an LLM can output at each step to guarantee that the output matches a given constraint. Specifically, in grammar-constrained decoding (GCD), the LLM's output must follow a given grammar. In this paper, we demonstrate that GCD techniques (and in general constrained decoding techniques) can distort the LLM's distribution, leading to outputs that are grammatical but appear with likelihoods that are not proportional to the ones given by the LLM, and so ultimately are low-quality. We call the problem of aligning sampling with a grammar constraint, grammar-aligned decoding (GAD), and propose adaptive sampling with approximate expected futures (ASAp), a decoding algorithm that guarantees the output to be grammatical while provably producing outputs that match the conditional probability of the LLM's distribution conditioned on the given grammar constraint. Our algorithm uses prior sample outputs to soundly overapproximate the future grammaticality of different output prefixes. Our evaluation on code generation and structured NLP tasks shows how ASAp often produces outputs with higher likelihood (according to the LLM's distribution) than existing GCD techniques, while still enforcing the desired grammatical constraints.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Figures









Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
The source backs part of the claim, not all of it — or backs it for a different population, condition or comparison.
In the citing paper
“Type II systems (Figure 2, right) use formal methods to post-process LLM outputs so that it satisfies specifications by construction (e.g., constrained decoding [25, 28, 29], program completion [35]).”
From Position: Vibe Coding Needs Vibe Reasoning: Improving Vibe Coding with Formal Verification (2025) · cites this paper as [28]
Experimental — accuracy not yet measured
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
The publisher hasn’t deposited this paper’s reference list.
Research works printed but not linked: 13
- Lakshya A Agrawal, Aditya Kanade, Navin Goyal, Shuvendu K. Lahiri, and Sriram K. Raja- mani. 2023. Monitor-guided decoding of code lms with static analysis of repository context. In Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023.
- Afra Amini, Li Du, and Ryan Cotterell. 2024. Structured voronoi sampling. Advances in Neural Information Processing Systems, 36.
- Peter Anderson, Basura Fernando, Mark Johnson, and Stephen Gould. 2016. Guided open vocabulary image captioning with constrained beam search. arXiv preprint arXiv:1612.00576. · arXiv
- Saibo Geng, Martin Josifoski, Maxime Peyrard, and Robert West. 2023. Grammar-constrained decoding for structured NLP tasks without finetuning. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, Singapore. Association for Computational Linguistics.
- Chris Hokamp and Qun Liu. 2017. Lexically constrained decoding for sequence generation using grid beam search. arXiv preprint arXiv:1704.07138. · arXiv
- J Edward Hu, Huda Khayrallah, Ryan Culkin, Patrick Xia, Tongfei Chen, Matt Post, and Benjamin Van Durme. 2019. Improved lexically constrained decoding for translation and monolingual rewriting. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 839-850.
- Sachin Kumar, Biswajit Paria, and Yulia Tsvetkov. 2022. Gradient-based constrained sampling from language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 2251-2277.
- Xiang Li, John Thickstun, Ishaan Gulrajani, Percy S Liang, and Tatsunori B Hashimoto. 2022. Diffusion-lm improves controllable text generation. Advances in Neural Information Processing Systems, 35:4328-4343.
- Yixuan Li, Julian Parsert, and Elizabeth Polgreen. 2024. Guiding enumerative program synthesis with large language models. In International Conference on Computer Aided Verification, pages 280-301. Springer.
- Matt Post and David Vilar. 2018. Fast lexically constrained decoding with dynamic beam allocation for neural machine translation. arXiv preprint arXiv:1804.06609. · arXiv
- Lianhui Qin, Sean Welleck, Daniel Khashabi, and Yejin Choi. 2022. Cold decoding: Energy- based constrained text generation with langevin dynamics. In Advances in Neural Information Processing Systems.
- Alex Renda, Aspen K. Hopkins, and Michael Carbin. 2023. Can LLMs generate random numbers? evaluating LLM sampling in controlled domains. In ICML 2023 Workshop: Sampling and Optimization in Discrete Space.
- Brandon T Willard and Rémi Louf. 2023. Efficient guided generation for large language models. arXiv e-prints, pages arXiv-2307.
Cited by
Items 101–145 of 145
Wang, Y., Li, M., Liu, S., & Xue, L. (2026) · Expert Systems with Applications · doi:10.1016/j.eswa.2026.134222
CASD: A Contract-Aware Speculative Decoding Method for Constrained Output Generation
Tian, F., Wu, S., Chen, C., Li, Z., Liu, G., & Dou, W. (2026) · IEEE International Conference on Software Services Engineering (SSE) · doi:10.1109/sse72781.2026.00040
SwiftGram: Dynamic Lexical Forking for Precise and Efficient Grammar-Constrained Decoding
Ling, S., Kang, L., Liu, J., Wang, S., Ma, Z., & Ye, D. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3834419
Yamauchi, K., & Katsurai, M. (2026) · ACM/IEEE Joint Conference on Digital Libraries · doi:10.1145/3805696.3846040
JevSpawn: Adaptive Agentic Inference through Compositional Action SpacesPreprint
Su, H., & Huang, W. (2026) · arXiv · doi:10.48550/arxiv.2610.00437
Alviano, M., Capalbo, M., Gottlob, G., Grillo, L., Kareem, I., Lo Scudo, F., Piccolo, S. A., & Rodriguez Reiners, L. A. (2026) · Journal of Artificial Intelligence Research · doi:10.1613/jair.1.21678
Narcissus: Program Synthesis Using Context-Aware LLM ApproximationsPreprint
Hinnerichs, T., Dumančić, S., & Yorke‐Smith, N. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.25657
Provably Tractable NFA-Constrained Language Generation via HMMsPreprint
Sun, J., & Meel, K. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.40185
Maghera, R., Arya, A. T., Babikian, A. A., Chechik, M., & Dehnavi, M. M. (2026) · arXiv
FactorSpec: Serving Exact Relational Constraints as Speculative DraftsPreprint
Su, J., Xiang, D., & Zhang, W. E. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2611.02297
Cao, S., Ma, J., Chai, W., Tian, Y., Du, L., & Zheng, D. (2026) · arXiv · doi:10.48550/arxiv.2610.30920
Metamodel-Guided LLM Decoding for Consistent DSL GenerationPreprint
Chen, B.-Q., Babikian, A. A., & López, J. A. H. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.29749
Breaking the Space Barrier and its Application to Language Model InferencePreprint
Asadulaev, A. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.09139
GrammarRL: Effective Grammar-Constrained Decoding via Reinforcement LearningPreprint
Tuccio, G., Furnari, A., Gangemi, A., & Mongiovì, M. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.39869
Fang, Y., Liu, Y., & Xing, L. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.10537
Chermsirivatana, T., & MacCormick, J. (2026) · arXiv · doi:10.48550/arxiv.2608.25761
The Parser Already Knows: Lightweight Bias Correction in Constrained DecodingPreprint
Özgü, I., Wu, Y., den Broeck, G. V., & Kim, M. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.10137
GRID: Grammar-Railed Decoding for Enterprise SQL GenerationPreprint
Arjmandi, M. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2607.11951
Kozachok, A., Bakaev, A. A., Kozachok, A., Магомедов, Ш., & Noev, A. N. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2605.25835
Towards Practical Automata-Based Steering of Large Language Models for Diverse Structured Generation
Luan, X., Wei, Z., Zhang, Y., Wang, K., & Sun, M. (2026) · Formal Aspects of Computing · doi:10.1145/3858629
Ткачук, А. В. (2026) · Таврійський науковий вісник Серія Технічні науки · doi:10.32782/tnv-tech.2026.2.1.38
Reliable Generation of Feature Models in the Universal Variability Language using Constrained LLMs
Stümpfle, J., Tunc, F., Jazdi, N., & Weyrich, M. (2026) · ACM/IEEE International Conference on Model Driven Engineering Languages and Systems (MODELS) · doi:10.1145/3837062.3839369
DOGS: Design-Space Sampling for Prompt-Driven Logo GenerationPreprint
Zou, G., Dai, C., Self, N., Piper, K., Seethiraju, R. R., Shyamsunder, K., Lu, C.-T., & Naren, R. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.10760
SSR: Symbolic-Neural Soft Reasoning for Robust and Verifiable Thinking Chains
Wang, R., Wei, Z., Zhang, Y., & Luan, X. (2026) · Conference on Empirical Methods in Natural Language Processing (EMNLP) · doi:10.18653/2026.emnlp-main.1241
Kayali, M. (2026) · ResearchWorks at the University of Washington (University of Washington)
Mehta, D. P. (2026) · arXiv · doi:10.48550/arxiv.2607.09665
Zeng, X. (n.d.) · PhilPapers (PhilPapers Foundation)
Li, L., Jin, Z., Zhang, Y., Jin, D., He, Y., Zhang, H., Zhang, X., Luosang, G., & Tashi, N. (2026) · arXiv · doi:10.48550/arxiv.2607.26397
Provably reliable machine learning systems
Ugare, S. (2025) · Illinois Digital Environment for Access to Learning and Scholarship (University of Illinois at Urbana-Champaign)
Verifiable reasoning of large language models over structured spatial data
Essam, K., & Romaniuk, R. S. (2026) · International Journal of Electronics and Telecommunications · doi:10.24425/ijet.2026.6314 · Cited by 1
Stateful CARS: Exact Cross-History Reuse for Policy-Constrained LLM AgentsPreprint
Shihab, I. F., Swaqeeb, M. N., & Ahsan, A. S.-A. M. M.-I. A. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.08282
ZeroGR: Filtering-First Constrained Decoding for Generative RecommendationPreprint
Yang, X., Yang, J., Zeng, L., Ding, D., Liu, Z., Tian, B., Peng, C., Zhao, Y., Zhang, F., Liu, J., et al. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2611.04715
Padding to k: A Minimum Count in the Schema Makes Open-Weight Models Pad Their Extraction ListsPreprint
Barali, A., & Paudel, A. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.30997
No More Import Errors: Constrained Decoding for Guaranteed Valid Imports in LLM-Generated TestsPreprint
Kitsios, K., Biagiola, M., Salvaneschi, G., & Bacchelli, A. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.41878
Cheang, K., Hulette, G., Kumar, R., Monteiro, F. R., Mora, F., Salkeld, R., Tan, L., & Taşiran, S. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.05493
Shi, K., Li, Z., Hu, H., Zhang, L., Wang, D., Han, Y., & Wang, X. (2026) · EAI Endorsed Transactions on Energy Web · doi:10.4108/ew.14132
An, X., Zhang, R., Zhong, C., Shen, X., Sun, J., Wu, J., & He, W. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.09876
Structural Automata for Neural Semantic ParsingPreprint
Zhang, X. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.13896
When Copying Is Hard: Copy-Constrained Decoding for Exact Span ReproductionPreprint
Zhang, J., Gao, L., Liu, Z., Zeng, R., Song, Z., Yan, R., Inui, K., & Chen, X. (2026) · arXiv · doi:10.48550/arxiv.2610.28393 · Cited by 1
Schema-Hierarchical Soft Prompts for Structured Information Extraction
Dey, S., Tenneti, S. V., Mishra, B., Niranjan, S., & Datar, M. (2026) · Conference on Empirical Methods in Natural Language Processing (EMNLP) · doi:10.18653/2026.emnlp-industry.124
Specification-Guided Generation for Large Language ModelsPreprint
Previti, A., Vandikas, K., Alviano, M., Carlsson, M., Forsberg, A. L., Nikou, A., Karapantelakis, A., & Vulgarakis, A. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.41511
Abdelrahman, A. (2026) · Research Square · doi:10.21203/rs.3.rs-11641294/v1
Dgrammar: Efficient Constrained Decoding for DLMs
Chiu, G.-M., & Liu, J.-Y. (2026) · International Joint Conference on Natural Language Processing and Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics (IJCNLP-AACL) · doi:10.18653/2026.aacl-long.225
Controllable Generation via Locally Constrained Resampling
Ahmed, K., Chang, K., & den Broeck, G. V. (2025) · International Conference on Learning Representations
Metadata
- Authors
- Park, K., Wang, J., Berg-Kirkpatrick, T., Polikarpova, N., & D'Antoni, L.
- Venue
- Advances in Neural Information Processing Systems 37
- Published
- 2024
- Pages
- 24547-24568
- ISSN
- 1049-5258 (ISSN-L)
- OpenAlex
- W4415798509
- Cited by
- 10
- References
- 0
- Citations by year
- 2026: 9 · 2025: 1
- FWCI
- 2.89
- Type
- conference paper
- Language
- en
- Open access
- green
- arxiv.org
- Licence
- cc-by-nc-sa
- Locations
- neural information processing systems (publishedVersion)
- arXiv (Cornell University) (submittedVersion, cc-by-nc-sa)
- arXiv (Cornell University)
- Funders
- National Science Foundation (1918211, 2023222, 1955457, 2422214, 2211968, 2402833, 2200333, 2446711)
- Topics
- Physical Sciences › Computer Science › Artificial Intelligence › Natural Language Processing Techniques
- Social Sciences › Arts and Humanities › Language and Linguistics › Syntax, Semantics, Linguistic Variation
- Social Sciences › Psychology › Developmental and Educational Psychology › Language Development and Disorders
- Keywords
- grammatical inference, natural language generation
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.