Grammar-Aligned Decoding
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 54 papers in the map (data through 14 Oct 2026). Builds on 14 of its 28 references that are in the map. First posted on arXiv 31 May 2024.
Builds on
14 of 28 references.
References · 14
- 2022Diffusion-LM Improves Controllable Text Generationcited by 1,027
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
- 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
- 2016Guided Open Vocabulary Image Captioning with Constrained Beam Searchcited by 105
- 2022Gradient-Based Constrained Sampling from Language Modelscited by 64
- 2023Zero and Few-shot Semantic Parsing with Ambiguous Inputscited by 16
2 more
Built on by
Citing papers per year: 2024: 5; 2025: 17; 2026: 32.
54 papers.
Sort:
By area:
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlocited by 46
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 43
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 16
- 2025Self-Steering Language Modelscited by 13
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
- 2026SEVerA: Verified Synthesis of Self-Evolving Agentscited by 8
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2024Grammar-based Game Description Generation using Large Language Modelscited by 7
- 2024Mind the Data Gap: Bridging LLMs to Enterprise Data Integrationcited by 7
- 2025Correctness-Guaranteed Code Generation via Constrained Decodingcited by 7
38 more
- 2024Using a Feedback Loop for LLM-based Infrastructure as Code Generationcited by 5
- 2025Constrained Decoding for Safe Robot Navigation Foundation Modelscited by 5
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generationcited by 5
- 2026Sampling for Quality: Training-Free Reward-Guided LLM Decoding via Sequential Monte Carlocited by 5
- 2025XML Prompting as Grammar-Constrained Interaction: Fixed-Point Semantics, Convergence Guarantees, and Human-AI Protocolscited by 4
- 2025The Future of Generative AI in Software Engineering: A Vision from Industry and Academia in the European GENIUS Projectcited by 4
- 2024Approximately Aligned Decodingcited by 3
- 2025Constrained Adaptive Rejection Samplingcited by 3
- 2025Metamodel-Guided Model Generation with Layered Constraintscited by 3
- 2026Hard Constraints Meet Soft Generation: Guaranteed Feasibility for LLM-based Combinatorial Optimizationcited by 3
- 2026Semantic Layers for Reliable LLM-Powered Data Analytics: A Paired Benchmark of Accuracy and Hallucination Across Three Frontier Modelscited by 3
- 2026The Structured Output Benchmark: A Multi-Source Benchmark for Evaluating Structured Output Quality in Large Language Modelscited by 3
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklistcited by 3
- 2025Positional Fragility in LLMs: How Offset Effects Reshape Our Understanding of Memorization Riskscited by 2
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decodingcited by 2
- 2026Naive Prompt Optimization: Rethinking the Need for Complex Prompt Searchcited by 2
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Modelscited by 1
- 2026SEAR: Schema-Based Evaluation and Routing for LLM Gatewayscited by 1
- 2026One Token Away from Collapse: The Fragility of Instruction-Tuned Helpfulnesscited by 1
- 2026From Unstructured Recall to Schema-Grounded Memory: Reliable AI Memory via Iterative, Schema-Aware Extractioncited by 1
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Modelscited by 1
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expandingcited by 1
- 2026Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filteringcited by 1
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraintscited by 1
- 2025textttSEM-CTRL: Semantically Controlled Decodingcited by 0
- 2025Empirical Computation: Prompting versus Programmingcited by 0
- 2026Continuous Diffusion Models Can Obey Formal Syntaxcited by 0
- 2026Specification-Aware Distribution Shaping for Robotics Foundation Modelscited by 0
- 2026LLM-Powered Workflow Optimization for Multidisciplinary Software Development: An Automotive Industry Case Studycited by 0
- 2026ATLAS-RTC: Closing the Loop on LLM Agent Output with Token-Level Runtime Controlcited by 0
- 2026Context-Instrumental Data Distillation for Kubernetes Manifest Generation: Method and Experimental Evaluationcited by 0
- 2026Format Sensitivity Index: Token-Controlled Prompt Wrapper Robustness and Schema Compliance in LLM Benchmarkingcited by 0
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generationcited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026Natural-Language to SysMLv2 Translation via Conformance-Driven Iterative Refinementcited by 0
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decodingcited by 0
- 2026Meta-Ctrl: Guaranteed Plan Generation by Decoupling Syntactic and Semantic Constraintscited by 0
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Modelscited by 0
50 most cited of 54 All 54 (JSON)
- 2026DOGS: Design-Space Sampling for Prompt-Driven Logo Generation7 Oct 2026
- 2026JevSpawn: Adaptive Agentic Inference through Compositional Action Spaces30 Sep 2026
- 2026GrammarRL: Effective Grammar-Constrained Decoding via Reinforcement Learning30 Sep 2026
- 2026Twist, Don't Tilt: Trajectory-Exact Constrained Decoding for Masked Diffusion Models28 Sep 2026
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklist26 Sep 2026
- 2026Naive Prompt Optimization: Rethinking the Need for Complex Prompt Search27 Aug 2026
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Models26 Aug 2026
- 2026Meta-Ctrl: Guaranteed Plan Generation by Decoupling Syntactic and Semantic Constraints23 Aug 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
- 2026Natural-Language to SysMLv2 Translation via Conformance-Driven Iterative Refinement14 Jul 2026
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generation11 Jul 2026
38 more
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026Context-Instrumental Data Distillation for Kubernetes Manifest Generation: Method and Experimental Evaluation25 May 2026
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints13 May 2026
- 2026Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filtering11 May 2026
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decoding8 May 2026
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models4 May 2026
- 2026Format Sensitivity Index: Token-Controlled Prompt Wrapper Robustness and Schema Compliance in LLM Benchmarking2 May 2026
- 2026From Unstructured Recall to Schema-Grounded Memory: Reliable AI Memory via Iterative, Schema-Aware Extraction30 Apr 2026
- 2026The Structured Output Benchmark: A Multi-Source Benchmark for Evaluating Structured Output Quality in Large Language Models28 Apr 2026
- 2026Semantic Layers for Reliable LLM-Powered Data Analytics: A Paired Benchmark of Accuracy and Hallucination Across Three Frontier Models28 Apr 2026
- 2026One Token Away from Collapse: The Fragility of Instruction-Tuned Helpfulness14 Apr 2026
- 2026Sampling for Quality: Training-Free Reward-Guided LLM Decoding via Sequential Monte Carlo7 Apr 2026
- 2026ATLAS-RTC: Closing the Loop on LLM Agent Output with Token-Level Runtime Control29 Mar 2026
- 2026SEVerA: Verified Synthesis of Self-Evolving Agents26 Mar 2026
- 2026LLM-Powered Workflow Optimization for Multidisciplinary Software Development: An Automotive Industry Case Study22 Mar 2026
- 2026SEAR: Schema-Based Evaluation and Routing for LLM Gateways20 Mar 2026
- 2026Specification-Aware Distribution Shaping for Robotics Foundation Models18 Mar 2026
- 2026Continuous Diffusion Models Can Obey Formal Syntax12 Feb 2026
- 2026Hard Constraints Meet Soft Generation: Guaranteed Feasibility for LLM-based Combinatorial Optimization1 Feb 2026
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Models5 Dec 2025
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation27 Nov 2025
- 2025The Future of Generative AI in Software Engineering: A Vision from Industry and Academia in the European GENIUS Project3 Nov 2025
- 2025Metamodel-Guided Model Generation with Layered Constraints29 Oct 2025
- 2025Constrained Adaptive Rejection Sampling2 Oct 2025
- 2025XML Prompting as Grammar-Constrained Interaction: Fixed-Point Semantics, Convergence Guarantees, and Human-AI Protocols9 Sep 2025
- 2025Constrained Decoding for Safe Robot Navigation Foundation Models1 Sep 2025
- 2025Correctness-Guaranteed Code Generation via Constrained Decoding20 Aug 2025
- 2025DINGO: Constrained Inference for Diffusion LLMs29 May 2025
- 2025Positional Fragility in LLMs: How Offset Effects Reshape Our Understanding of Memorization Risks19 May 2025
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlo17 Apr 2025
- 2025Self-Steering Language Models9 Apr 2025
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Sampling7 Apr 2025
- 2025Empirical Computation: Prompting versus Programming13 Mar 2025
- 2025textttSEM-CTRL: Semantically Controlled Decoding3 Mar 2025
- 2025CRANE: Reasoning with constrained LLM generation13 Feb 2025
- 2025Flexible and Efficient Grammar-Constrained Decoding7 Feb 2025
- 2024Mind the Data Gap: Bridging LLMs to Enterprise Data Integration29 Dec 2024
50 newest of 54 All 54 (JSON)
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2025Self-Steering Language Modelscited by 13
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Modelscited by 0
- 2026JevSpawn: Adaptive Agentic Inference through Compositional Action Spacescited by 0
- 2026JevSpawn: Adaptive Agentic Inference through Compositional Action Spaces30 Sep 2026
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Models26 Aug 2026
- 2025Self-Steering Language Models9 Apr 2025
- 2025CRANE: Reasoning with constrained LLM generation13 Feb 2025
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlocited by 46
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 43
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 16
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2024Grammar-based Game Description Generation using Large Language Modelscited by 7
- 2024Mind the Data Gap: Bridging LLMs to Enterprise Data Integrationcited by 7
- 2025Correctness-Guaranteed Code Generation via Constrained Decodingcited by 7
- 2024Using a Feedback Loop for LLM-based Infrastructure as Code Generationcited by 5
- 2025Constrained Decoding for Safe Robot Navigation Foundation Modelscited by 5
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generationcited by 5
12 most cited of 42 All 42 (JSON)
- 2026DOGS: Design-Space Sampling for Prompt-Driven Logo Generation7 Oct 2026
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklist26 Sep 2026
- 2026Meta-Ctrl: Guaranteed Plan Generation by Decoupling Syntactic and Semantic Constraints23 Aug 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
- 2026Natural-Language to SysMLv2 Translation via Conformance-Driven Iterative Refinement14 Jul 2026
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generation11 Jul 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026Context-Instrumental Data Distillation for Kubernetes Manifest Generation: Method and Experimental Evaluation25 May 2026
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints13 May 2026
- 2026Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filtering11 May 2026
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
12 newest of 42 All 42 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammars
- 2026Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding
- 2023Don't Fine-Tune, Decode: Syntax Error-Free Tool Use via Constrained Decoding
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generation
- 2025p-less Sampling: A Robust Hyperparameter-Free Approach for LLM Decoding
- 2025(G)I-DLE: Generative Inference via Distribution-preserving Logit Exclusion with KL Divergence Minimization for Constrained Decoding
- 2024DeAL: Decoding-time Alignment for Large Language Models
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Models