SynCode: LLM Generation with Grammar Augmentation
Not on the map. Why?
Abstract (arXiv)
LLMs are widely used in complex AI applications. These applications underscore the need for LLM outputs to adhere to a specific format, for their integration with other components in the systems. Typically the format rules e.g., for data serialization formats such as JSON, YAML, or Code in Programming Language are expressed as context-free grammar (CFG). Due to the hallucinations and unreliability of LLMs, instructing LLMs to adhere to specified syntax becomes an increasingly important challenge. We present SynCode, a novel framework for efficient and general syntactical decoding with LLMs, to address this challenge. SynCode ensures soundness and completeness with respect to the CFG of a formal language, effectively retaining valid tokens while filtering out invalid ones. SynCode uses an offline-constructed, efficient lookup table, the DFA mask store, derived from the DFA of the language's grammar for efficient generation. SynCode seamlessly integrates with any language defined by CFG, as evidenced by experiments focusing on generating JSON, Python, and Go outputs. Our experiments evaluating the effectiveness of SynCode for JSON generation demonstrate that SynCode eliminates all syntax errors and significantly outperforms state-of-the-art baselines. Furthermore, our results underscore how SynCode significantly reduces 96.07% of syntax errors in generated Python and Go code, showcasing its substantial impact on enhancing syntactical precision in LLM generation. Our code is available at https://github.com/uiuc-focal-lab/syncode
Key facts. Cited by 66 papers in the map (data through 7 Oct 2026). Builds on 29 of its 51 references that are in the map. First posted on arXiv 3 Mar 2024.
Builds on
29 of 51 references.
References · 29
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,615
- 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,120
- 2023WizardLM: Empowering large pre-trained language models to follow complex instructionscited by 1,116
- 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 975
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
17 more
- 2018Meta-Learning for Semi-Supervised Few-Shot Classificationcited by 456
- 2023LeanDojo: Theorem Proving with Retrieval-Augmented Language Modelscited by 414
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
- 2023Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoningcited by 379
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
- 2022Autoformalization with Large Language Modelscited by 252
- 2022Neural Networks and the Chomsky Hierarchycited by 214
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 186
- 2023LINC: A Neurosymbolic Approach for Logical Reasoning by Combining Language Models with First-Order Logic Proverscited by 161
- 2022Multi-lingual Evaluation of Code Generation Modelscited by 158
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 99
- 2023Copiloting the Copilots: Fusing Large Language Models with Completion Engines for Automated Program Repaircited by 55
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2023Masked Hard-Attention Transformers Recognize Exactly the Star-Free Languagescited by 47
- 2023Guiding Language Models of Code with Global Context using Monitorscited by 20
- 2023Pushdown Layers: Encoding Recursive Structure in Transformer Language Modelscited by 18
- 2024Constrained Decoding for Fill-in-the-Middle Code Language Models via Efficient Left and Right Quotienting of Context-Sensitive Grammarscited by 8
Built on by
Citing papers per year: 2024: 5; 2025: 18; 2026: 43.
66 papers.
Sort:
By area:
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2024CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Rerankingcited by 37
- 2025Type-Constrained Code Generation with Language Modelscited by 32
- 2025ProofBridge: Auto-Formalization of Natural Language Proofs in Lean via Joint Embeddingscited by 16
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 15
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammarscited by 13
- 2025Pre3: Enabling Deterministic Pushdown Automata for Faster Structured LLM Generationcited by 11
- 2025On the Query Complexity of Verifier-Assisted Language Generationcited by 10
- 2025Towards Formal Verification of LLM-Generated Code from Natural Language Promptscited by 8
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2024Is The Watermarking Of LLM-Generated Code Robust?cited by 7
38 more
- 2024Automated User Story Generation with Test Case Specification Using Large Language Modelcited by 7
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decodingcited by 7
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 6
- 2026SEVerA: Verified Synthesis of Self-Evolving Agentscited by 6
- 2024Using a Feedback Loop for LLM-based Infrastructure as Code Generationcited by 5
- 2025RefineStat: Efficient Exploration for Probabilistic Program Synthesiscited by 5
- 2025Multi-Agent Code-Orchestrated Generation for Reliable Infrastructure-as-Codecited by 5
- 2026TerraFormer: Automated Infrastructure-as-Code with LLMs Fine-Tuned via Policy-Guided Verifier Feedbackcited by 4
- 2026On the Power of (Approximate) Reward Models for Inference-Time Scalingcited by 4
- 2025Syntactic Control of Language Models by Posterior Inferencecited by 3
- 2025UTF-8 Plumbing: Byte-level Tokenizers Unavoidably Enable LLMs to Generate Ill-formed UTF-8cited by 3
- 2026Semantic Layers for Reliable LLM-Powered Data Analytics: A Paired Benchmark of Accuracy and Hallucination Across Three Frontier Modelscited by 3
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 3
- 2025Opponent Shaping in LLM Agentscited by 2
- 2025TokDrift: When LLM Speaks in Subwords but Code Speaks in Grammarcited by 2
- 2026Cybersecurity is the True Frontier for Generative AI Success or Failurecited by 2
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Modelscited by 1
- 2026Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decodingcited by 1
- 2026Diagnosing CFG Interpretation in LLMscited by 1
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Modelscited by 1
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraintscited 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
- 2024From Words to Workflows: Automating Business Processescited by 0
- 2025Learning to Guarantee Type Correctness in Code Generation through Type-Guided Program Synthesiscited by 0
- 2025Toward Automated and Trustworthy Scientific Analysis and Visualization with LLM-Generated Codecited by 0
- 2026Suffix-Constrained Greedy Search Algorithms for Causal Language Modelscited by 0
- 2026LTLGuard: Formalizing LTL Specifications with Compact Language Models and Lightweight Symbolic Reasoningcited by 0
- 2026LLM-Powered Workflow Optimization for Multidisciplinary Software Development: An Automotive Industry Case Studycited by 0
- 2026Amalgam: Hybrid LLM-PGM Synthesis Algorithm for Accuracy and Realismcited by 0
- 2026Rethinking Token Prediction: Tree-Structured Diffusion Language Modelcited by 0
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinationscited by 0
- 2026Towards Human Motion World Models via Executable Behaviour Representationscited by 0
- 2026Task Abstention for Large Language Models in Code Generationcited by 0
- 2026Domain-Adaptable Reinforcement Learning for Code Generation with Dense Rewardscited by 0
- 2026Accelerating Constrained Decoding with Token Space Compressioncited by 0
- 2026Projectional Decoding: Towards Semantic-Aware LLM Generationcited by 0
- 2026Grammar-Constrained Decoding Can Jailbreak LLMs into Generating Malicious Codecited by 0
50 most cited of 66 All 66 (JSON)
- 2026GrammarRL: Effective Grammar-Constrained Decoding via Reinforcement Learning30 Sep 2026
- 2026Twist, Don't Tilt: Trajectory-Exact Constrained Decoding for Masked Diffusion Models28 Sep 2026
- 2026Semantic Prefix Oracles for LLM Decoding: Contracts and Differential Validation28 Sep 2026
- 2026CLAMP: Constrained Decoding for Vision-Language Embodied Planning8 Sep 2026
- 2026Control-Data Flow Separation: Stable Prompt Optimization in Multi-Agent LLMs1 Sep 2026
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliance28 Aug 2026
- 2026Neurosymbolic Embodied Agents17 Aug 2026
- 2026Trie Automata for Constrained Decoding over Large Finite Sets12 Aug 2026
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding10 Aug 2026
- 2026Stateful CARS: Exact Cross-History Reuse for Policy-Constrained LLM Agents8 Aug 2026
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Models30 Jul 2026
- 2026Decode-Time Grammars: Constrained LLM Generation over a Refinement Order of Grammar Fragments20 Jul 2026
38 more
- 2026Policy-Conditioned Constrained Decoding for Column-Level Access Control in Text-to-SQL14 Jul 2026
- 2026Imprompt: A Language Framework for Prompt Programming13 Jul 2026
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generation11 Jul 2026
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata8 Jul 2026
- 2026Cybersecurity is the True Frontier for Generative AI Success or Failure27 Jun 2026
- 2026Weave of Formal Thought24 Jun 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026Grammar-Constrained Decoding Can Jailbreak LLMs into Generating Malicious Code10 Jun 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Models30 May 2026
- 2026Projectional Decoding: Towards Semantic-Aware LLM Generation28 May 2026
- 2026Accelerating Constrained Decoding with Token Space Compression28 May 2026
- 2026Domain-Adaptable Reinforcement Learning for Code Generation with Dense Rewards20 May 2026
- 2026Task Abstention for Large Language Models in Code Generation16 May 2026
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints13 May 2026
- 2026When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models4 May 2026
- 2026Semantic Layers for Reliable LLM-Powered Data Analytics: A Paired Benchmark of Accuracy and Hallucination Across Three Frontier Models28 Apr 2026
- 2026Diagnosing CFG Interpretation in LLMs22 Apr 2026
- 2026Towards Human Motion World Models via Executable Behaviour Representations20 Apr 2026
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinations9 Apr 2026
- 2026Rethinking Token Prediction: Tree-Structured Diffusion Language Model4 Apr 2026
- 2026Amalgam: Hybrid LLM-PGM Synthesis Algorithm for Accuracy and Realism28 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
- 2026LTLGuard: Formalizing LTL Specifications with Compact Language Models and Lightweight Symbolic Reasoning5 Mar 2026
- 2026Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding4 Mar 2026
- 2026Suffix-Constrained Greedy Search Algorithms for Causal Language Models1 Mar 2026
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decoding8 Feb 2026
- 2026On the Power of (Approximate) Reward Models for Inference-Time Scaling1 Feb 2026
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars31 Jan 2026
- 2026TerraFormer: Automated Infrastructure-as-Code with LLMs Fine-Tuned via Policy-Guided Verifier Feedback13 Jan 2026
- 2025Bootstrapping Fuzzers for Compilers of Low-Resource Language Dialects Using Language Models5 Dec 2025
- 2025Toward Automated and Trustworthy Scientific Analysis and Visualization with LLM-Generated Code26 Nov 2025
- 2025UTF-8 Plumbing: Byte-level Tokenizers Unavoidably Enable LLMs to Generate Ill-formed UTF-85 Nov 2025
- 2025ProofBridge: Auto-Formalization of Natural Language Proofs in Lean via Joint Embeddings17 Oct 2025
- 2025TokDrift: When LLM Speaks in Subwords but Code Speaks in Grammar16 Oct 2025
- 2025Learning to Guarantee Type Correctness in Code Generation through Type-Guided Program Synthesis11 Oct 2025
- 2025Opponent Shaping in LLM Agents9 Oct 2025
50 newest of 66 All 66 (JSON)
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025On the Query Complexity of Verifier-Assisted Language Generationcited by 10
- 2026On the Power of (Approximate) Reward Models for Inference-Time Scalingcited by 4
- 2026LTLGuard: Formalizing LTL Specifications with Compact Language Models and Lightweight Symbolic Reasoningcited by 0
- 2026Rethinking Token Prediction: Tree-Structured Diffusion Language Modelcited by 0
- 2026Weave of Formal Thoughtcited by 0
- 2026Weave of Formal Thought24 Jun 2026
- 2026Rethinking Token Prediction: Tree-Structured Diffusion Language Model4 Apr 2026
- 2026LTLGuard: Formalizing LTL Specifications with Compact Language Models and Lightweight Symbolic Reasoning5 Mar 2026
- 2026On the Power of (Approximate) Reward Models for Inference-Time Scaling1 Feb 2026
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis29 Mar 2025
- 2025On the Query Complexity of Verifier-Assisted Language Generation17 Feb 2025
- 2025CRANE: Reasoning with constrained LLM generation13 Feb 2025
- 2026SEVerA: Verified Synthesis of Self-Evolving Agentscited by 6
- 2025Multi-Agent Code-Orchestrated Generation for Reliable Infrastructure-as-Codecited by 5
- 2025Opponent Shaping in LLM Agentscited by 2
- 2026Diagnosing CFG Interpretation in LLMscited by 1
- 2026Stateful CARS: Exact Cross-History Reuse for Policy-Constrained LLM Agentscited by 0
- 2026Control-Data Flow Separation: Stable Prompt Optimization in Multi-Agent LLMscited by 0
- 2026Control-Data Flow Separation: Stable Prompt Optimization in Multi-Agent LLMs1 Sep 2026
- 2026Stateful CARS: Exact Cross-History Reuse for Policy-Constrained LLM Agents8 Aug 2026
- 2026Diagnosing CFG Interpretation in LLMs22 Apr 2026
- 2026SEVerA: Verified Synthesis of Self-Evolving Agents26 Mar 2026
- 2025Opponent Shaping in LLM Agents9 Oct 2025
- 2025Multi-Agent Code-Orchestrated Generation for Reliable Infrastructure-as-Code4 Oct 2025
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 3
- 2026EPIC: Efficient and Parallel Inference under CFG Constraints for Diffusion Language Modelscited by 1
- 2026Twist, Don't Tilt: Trajectory-Exact Constrained Decoding for Masked Diffusion Modelscited by 0
- 2026Twist, Don't Tilt: Trajectory-Exact Constrained Decoding for Masked Diffusion Models28 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
- 2026Neurosymbolic Embodied Agentscited by 0
- 2026CLAMP: Constrained Decoding for Vision-Language Embodied Planningcited by 0
- 2026CLAMP: Constrained Decoding for Vision-Language Embodied Planning8 Sep 2026
- 2026Neurosymbolic Embodied Agents17 Aug 2026
- 2024CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Rerankingcited by 37
- 2025Type-Constrained Code Generation with Language Modelscited by 32
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 15
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammarscited by 13
- 2025Pre3: Enabling Deterministic Pushdown Automata for Faster Structured LLM Generationcited by 11
- 2025Towards Formal Verification of LLM-Generated Code from Natural Language Promptscited by 8
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2024Automated User Story Generation with Test Case Specification Using Large Language Modelcited by 7
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decodingcited by 7
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 6
- 2024Using a Feedback Loop for LLM-based Infrastructure as Code Generationcited by 5
- 2025RefineStat: Efficient Exploration for Probabilistic Program Synthesiscited by 5
12 most cited of 43 All 43 (JSON)
- 2026GrammarRL: Effective Grammar-Constrained Decoding via Reinforcement Learning30 Sep 2026
- 2026Semantic Prefix Oracles for LLM Decoding: Contracts and Differential Validation28 Sep 2026
- 2026Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliance28 Aug 2026
- 2026Trie Automata for Constrained Decoding over Large Finite Sets12 Aug 2026
- 2026The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding10 Aug 2026
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Models30 Jul 2026
- 2026Decode-Time Grammars: Constrained LLM Generation over a Refinement Order of Grammar Fragments20 Jul 2026
- 2026Policy-Conditioned Constrained Decoding for Column-Level Access Control in Text-to-SQL14 Jul 2026
- 2026Imprompt: A Language Framework for Prompt Programming13 Jul 2026
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generation11 Jul 2026
- 2026Cybersecurity is the True Frontier for Generative AI Success or Failure27 Jun 2026
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
12 newest of 43 All 43 (JSON)