XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models
On the map: LLM agents and tool use → General LLM agent frameworks and benchmarks
Abstract (arXiv)
The applications of LLM Agents are becoming increasingly complex and diverse, leading to a high demand for structured outputs that can be parsed into code, structured function calls, and embodied agent commands. These developments bring significant demands for structured generation in LLM inference. Context-free grammar is a flexible approach to enable structured generation via constrained decoding. However, executing context-free grammar requires going through several stack states over all tokens in vocabulary during runtime, bringing non-negligible overhead for structured generation. In this paper, we propose XGrammar, a flexible and efficient structure generation engine for large language models. XGrammar accelerates context-free grammar execution by dividing the vocabulary into context-independent tokens that can be prechecked and context-dependent tokens that need to be interpreted during runtime. We further build transformations to expand the grammar context and reduce the number of context-independent tokens. Additionally, we build an efficient persistent stack to accelerate the context-dependent token checks. Finally, we co-design the grammar engine with LLM inference engine to overlap grammar computation with GPU executions. Evaluation results show that XGrammar can achieve up to 100x speedup over existing solutions. Combined with an LLM inference engine, it can generate near-zero overhead structure generation in end-to-end low-LLM serving.
Key facts. Cited by 75 papers in the map (data through 14 Oct 2026). Placed in General LLM agent frameworks and benchmarks, one of 16 directions in LLM agents and tool use. Builds on 17 of its 49 references that are in the map. First posted on arXiv 22 Nov 2024.
Builds on
17 of 49 references.
References · 17
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,211
- 2024Qwen2 Technical Reportcited by 2,120
- 2023SGLang: Efficient Execution of Structured Language Model Programscited by 1,141
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2023LLM+P: Empowering Large Language Models with Optimal Planning Proficiencycited by 501
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
- 2023SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verificationcited by 365
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2019Neural Machine Translation with Byte-Level Subwordscited by 115
5 more
- 2021Examining Zero-Shot Vulnerability Repair with Large Language Modelscited by 105
- 2022Reading Between the Lines: Modeling User Behavior and Costs in AI-Assisted Programmingcited by 91
- 2023Grammar Prompting for Domain-Specific Language Generation with Large Language Modelscited by 58
- 2024Automata-based constraints for language model decodingcited by 51
- 2022Validating Large Language Models with ReLMcited by 33
Built on by
Citing papers per year: 2024: 1; 2025: 23; 2026: 51.
75 papers.
Sort:
By area:
- 2025ReMA: Learning to Meta-think for LLMs with Multi-Agent Reinforcement Learningcited by 79
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 71
- 2025Enforcing Temporal Constraints for LLM Agentscited by 34
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2025PrefillOnly: An Inference Engine for Prefill-only Workloads in Large Language Model Applicationscited by 21
- 2025Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherencecited by 16
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 16
- 2025Social World Modelscited by 16
- 2024WebLLM: A High-Performance In-Browser LLM Inference Enginecited by 14
- 2026Quantifying the Utility of User Simulators for Building Collaborative LLM Assistantscited by 10
- 2025Surfer-H Meets Holo1: Cost-Efficient Web Agent Powered by Open Weightscited by 8
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
38 more
- 2025Correctness-Guaranteed Code Generation via Constrained Decodingcited by 7
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMscited by 7
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decodingcited by 7
- 2026In Agents We Trust, but Who Do Agents Trust? Latent Source Preferences Steer LLM Generationscited by 6
- 2025RefineStat: Efficient Exploration for Probabilistic Program Synthesiscited by 5
- 2025Orchestrating Dual-Boundaries: An Arithmetic Intensity Inspired Acceleration Framework for Diffusion Language Modelscited by 5
- 2026Thinking Before Constraining: A Unified Decoding Framework for Large Language Modelscited by 5
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 4
- 2025Metamodel-Guided Model Generation with Layered Constraintscited by 3
- 2026CaveAgent: Transforming LLMs into Stateful Runtime Operatorscited by 3
- 2026Token-Oriented Object Notation vs JSON: A Benchmark of Plain and Constrained Decoding Generationcited by 3
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklistcited by 3
- 2025WGRAMMAR: Leverage Prior Knowledge to Accelerate Structured Decodingcited by 2
- 2025Training-Free Multimodal Large Language Model Orchestrationcited by 2
- 2025DICE: Structured Reasoning in LLMs through SLM-Guided Chain-of-Thought Correctioncited by 2
- 2026NoReGeo: Non-Reasoning Geometry Benchmarkcited by 2
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decodingcited by 2
- 2026The Extrapolation Cliff in On-Policy Distillation of Near-Deterministic Structured Outputscited by 2
- 2026ProtoMedAgent: Multimodal Clinical Interpretability via Privacy-Aware Agentic Workflowscited by 2
- 2025Type-Compliant Adaptation Cascades: Adapting Programmatic LM Workflows to Datacited by 1
- 2025You May Speak Freely: Improving the Fine-Grained Visual Recognition Capabilities of Multimodal Large Language Models with Answer Extractioncited by 1
- 2026FMBench: Adaptive Large Language Model Output Formattingcited by 1
- 2026Designing RNAs with Language Modelscited by 1
- 2026Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decodingcited by 1
- 2026Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editingcited by 1
- 2026Transcoda: End-to-End Zero-Shot Optical Music Recognition via Data-Centric Synthetic Trainingcited by 1
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraintscited by 1
- 2026The Architecture of Errors: From Universal Impossibility to Patch-Local LLM Reliabilitycited by 1
- 2026Benchmarking System One decision models against trained classifiers and language models for automated decision gatescited by 1
- 2025Verbalized Algorithms: Classical Algorithms are All You Need (Mostly)cited by 0
- 2025Leveraging Large Language Models to Effectively Generate Visual Data for Canine Musculoskeletal Diagnosescited by 0
- 2025Play by the Type Rules: Inferring Constraints for LLM Functions in Declarative Programscited by 0
- 2025A Matter of Representation: Towards Graph-Based Abstract Code Generationcited by 0
- 2025CAPE: Capability Achievement via Policy Executioncited by 0
- 2026The New Compiler Stack: A Survey on the Synergy of LLMs and Compilerscited by 0
- 2026Adversarial Query Synthesis via Bayesian Optimizationcited by 0
- 2026Training-Free Semantic Multi-Object Tracking with Vision-Language Modelscited by 0
- 2026LLM StructCore: Schema-Guided Reasoning Condensation and Deterministic Compilationcited by 0
50 most cited of 75 All 75 (JSON)
- 2026When Should Enterprise Policy Decisions Be Learned, and When Should They Be Reasoned?13 Oct 2026
- 2026Breaking the Space Barrier and its Application to Language Model Inference6 Oct 2026
- 2026Grammar-Guided Code Watermarking with Green Temperature4 Oct 2026
- 2026Mingbird: A Local-First Agent Harness Enabling Small Open Models to Complete Real Tasks1 Oct 2026
- 2026Selection-Based Structured Reasoning: Toward Efficient Multimodal Search Agents1 Oct 2026
- 2026Benchmarking System One decision models against trained classifiers and language models for automated decision gates29 Sep 2026
- 2026ContractRL: Shielded Group-Relative Policy Optimization for Auditable Tool-Call Repair29 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
- 2026ActKV: Efficient LLM Agents through Action-Guided KV Cache Management25 Sep 2026
- 2026The Diagnosis a Reporter Leaves Unspoken: Surfacing Frozen Tumor Features for Brain-Tumor MRI Reporting2 Sep 2026
- 2026Monocultural Biases: Correlated biases in large language models lead to unequal systemic exclusion rates in hiring26 Aug 2026
38 more
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Models26 Aug 2026
- 2026Parason: Revealing Subtask and Trial Parallelism in LLM Reasoning25 Aug 2026
- 2026Meta-Ctrl: Guaranteed Plan Generation by Decoupling Syntactic and Semantic Constraints23 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
- 2026GRID: Grammar-Railed Decoding for Enterprise SQL Generation11 Jul 2026
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata8 Jul 2026
- 2026SHARC: SHAP-Based Interpretability in Machine Learning Risk Models for Regulatory Capital under ICAAP and CCAR6 Jul 2026
- 2026Weave of Formal Thought24 Jun 2026
- 2026The Hitchhiker's Guide to Agentic AI: From Foundations to Systems22 Jun 2026
- 2026No Accidental Software Agent First Canonical Code for Human Code Entropy Reduction and 30 to 500 times Lower Frontier Model Requirements12 Jun 2026
- 2026Grammar-Constrained Decoding Can Jailbreak LLMs into Generating Malicious Code10 Jun 2026
- 2026Tractable Hierarchical Control of Autoregressive Language Models1 Jun 2026
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposals1 Jun 2026
- 2026The Architecture of Errors: From Universal Impossibility to Patch-Local LLM Reliability28 May 2026
- 2026AutoFOAM: The Self-Refining Autonomous OpenFOAM Agent22 May 2026
- 2026Ethical Hyper-Velocity (EHV): A Hardware-Rooted Zero-Trust Runtime Enforcement Architecture for Agentic AI Systems18 May 2026
- 2026ProtoMedAgent: Multimodal Clinical Interpretability via Privacy-Aware Agentic Workflows13 May 2026
- 2026TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints13 May 2026
- 2026Transcoda: End-to-End Zero-Shot Optical Music Recognition via Data-Centric Synthetic Training11 May 2026
- 2026NCO: A Versatile Plug-in for Handling Negative Constraints in Decoding11 May 2026
- 2026Quantifying the Utility of User Simulators for Building Collaborative LLM Assistants10 May 2026
- 2026The Extrapolation Cliff in On-Policy Distillation of Near-Deterministic Structured Outputs9 May 2026
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decoding8 May 2026
- 2026LLM StructCore: Schema-Guided Reasoning Condensation and Deterministic Compilation22 Apr 2026
- 2026Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing20 Apr 2026
- 2026Training-Free Semantic Multi-Object Tracking with Vision-Language Models15 Apr 2026
- 2026Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding4 Mar 2026
- 2026Adversarial Query Synthesis via Bayesian Optimization2 Mar 2026
- 2026In Agents We Trust, but Who Do Agents Trust? Latent Source Preferences Steer LLM Generations17 Feb 2026
- 2026Designing RNAs with Language Models12 Feb 2026
- 2026Token-Oriented Object Notation vs JSON: A Benchmark of Plain and Constrained Decoding Generation8 Feb 2026
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decoding8 Feb 2026
- 2026FMBench: Adaptive Large Language Model Output Formatting6 Feb 2026
- 2026NoReGeo: Non-Reasoning Geometry Benchmark15 Jan 2026
- 2026Thinking Before Constraining: A Unified Decoding Framework for Large Language Models12 Jan 2026
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMs7 Jan 2026
- 2026The New Compiler Stack: A Survey on the Synergy of LLMs and Compilers5 Jan 2026
50 newest of 75 All 75 (JSON)
- 2025ReMA: Learning to Meta-think for LLMs with Multi-Agent Reinforcement Learningcited by 79
- 2025Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherencecited by 16
- 2026Thinking Before Constraining: A Unified Decoding Framework for Large Language Modelscited by 5
- 2025DICE: Structured Reasoning in LLMs through SLM-Guided Chain-of-Thought Correctioncited by 2
- 2026NoReGeo: Non-Reasoning Geometry Benchmarkcited by 2
- 2025Play by the Type Rules: Inferring Constraints for LLM Functions in Declarative Programscited by 0
- 2026LLM StructCore: Schema-Guided Reasoning Condensation and Deterministic Compilationcited by 0
- 2026The Hitchhiker's Guide to Agentic AI: From Foundations to Systemscited by 0
- 2026Weave of Formal Thoughtcited by 0
- 2026Parason: Revealing Subtask and Trial Parallelism in LLM Reasoningcited 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
- 2026Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Models26 Aug 2026
- 2026Parason: Revealing Subtask and Trial Parallelism in LLM Reasoning25 Aug 2026
- 2026Weave of Formal Thought24 Jun 2026
- 2026The Hitchhiker's Guide to Agentic AI: From Foundations to Systems22 Jun 2026
- 2026LLM StructCore: Schema-Guided Reasoning Condensation and Deterministic Compilation22 Apr 2026
- 2026NoReGeo: Non-Reasoning Geometry Benchmark15 Jan 2026
- 2026Thinking Before Constraining: A Unified Decoding Framework for Large Language Models12 Jan 2026
- 2025DICE: Structured Reasoning in LLMs through SLM-Guided Chain-of-Thought Correction10 Oct 2025
- 2025Play by the Type Rules: Inferring Constraints for LLM Functions in Declarative Programs24 Sep 2025
- 2025ReMA: Learning to Meta-think for LLMs with Multi-Agent Reinforcement Learning12 Mar 2025
- 2025Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherence18 Feb 2025
- 2025Enforcing Temporal Constraints for LLM Agentscited by 34
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMscited by 7
- 2026In Agents We Trust, but Who Do Agents Trust? Latent Source Preferences Steer LLM Generationscited by 6
- 2026CaveAgent: Transforming LLMs into Stateful Runtime Operatorscited by 3
- 2026ProtoMedAgent: Multimodal Clinical Interpretability via Privacy-Aware Agentic Workflowscited by 2
- 2026Ethical Hyper-Velocity (EHV): A Hardware-Rooted Zero-Trust Runtime Enforcement Architecture for Agentic AI Systemscited by 0
- 2026AutoFOAM: The Self-Refining Autonomous OpenFOAM Agentcited by 0
- 2026ActKV: Efficient LLM Agents through Action-Guided KV Cache Managementcited by 0
- 2026ActKV: Efficient LLM Agents through Action-Guided KV Cache Management25 Sep 2026
- 2026AutoFOAM: The Self-Refining Autonomous OpenFOAM Agent22 May 2026
- 2026Ethical Hyper-Velocity (EHV): A Hardware-Rooted Zero-Trust Runtime Enforcement Architecture for Agentic AI Systems18 May 2026
- 2026ProtoMedAgent: Multimodal Clinical Interpretability via Privacy-Aware Agentic Workflows13 May 2026
- 2026In Agents We Trust, but Who Do Agents Trust? Latent Source Preferences Steer LLM Generations17 Feb 2026
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMs7 Jan 2026
- 2026CaveAgent: Transforming LLMs into Stateful Runtime Operators4 Jan 2026
- 2025Enforcing Temporal Constraints for LLM Agents25 Dec 2025
- 2025PrefillOnly: An Inference Engine for Prefill-only Workloads in Large Language Model Applicationscited by 21
- 2024WebLLM: A High-Performance In-Browser LLM Inference Enginecited by 14
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decodingcited by 2
- 2026Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editingcited by 1
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decoding8 May 2026
- 2026Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing20 Apr 2026
- 2025PrefillOnly: An Inference Engine for Prefill-only Workloads in Large Language Model Applications12 May 2025
- 2024WebLLM: A High-Performance In-Browser LLM Inference Engine20 Dec 2024
- 2025Surfer-H Meets Holo1: Cost-Efficient Web Agent Powered by Open Weightscited by 8
- 2025Training-Free Multimodal Large Language Model Orchestrationcited by 2
- 2025You May Speak Freely: Improving the Fine-Grained Visual Recognition Capabilities of Multimodal Large Language Models with Answer Extractioncited by 1
- 2026Training-Free Semantic Multi-Object Tracking with Vision-Language Modelscited by 0
- 2026Training-Free Semantic Multi-Object Tracking with Vision-Language Models15 Apr 2026
- 2025You May Speak Freely: Improving the Fine-Grained Visual Recognition Capabilities of Multimodal Large Language Models with Answer Extraction16 Oct 2025
- 2025Training-Free Multimodal Large Language Model Orchestration6 Aug 2025
- 2025Surfer-H Meets Holo1: Cost-Efficient Web Agent Powered by Open Weights3 Jun 2025
- 2025Orchestrating Dual-Boundaries: An Arithmetic Intensity Inspired Acceleration Framework for Diffusion Language Modelscited by 5
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automatacited by 4
- 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
- 2025Orchestrating Dual-Boundaries: An Arithmetic Intensity Inspired Acceleration Framework for Diffusion Language Models24 Nov 2025
- 2025Social World Modelscited by 16
- 2025Social World Models30 Aug 2025
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 71
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2025DINGO: Constrained Inference for Diffusion LLMscited by 16
- 2026Quantifying the Utility of User Simulators for Building Collaborative LLM Assistantscited by 10
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2025Correctness-Guaranteed Code Generation via Constrained Decodingcited by 7
- 2026The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decodingcited by 7
- 2025RefineStat: Efficient Exploration for Probabilistic Program Synthesiscited by 5
- 2025Metamodel-Guided Model Generation with Layered Constraintscited by 3
- 2026Token-Oriented Object Notation vs JSON: A Benchmark of Plain and Constrained Decoding Generationcited by 3
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklistcited by 3
- 2025WGRAMMAR: Leverage Prior Knowledge to Accelerate Structured Decodingcited by 2
12 most cited of 42 All 42 (JSON)
- 2026When Should Enterprise Policy Decisions Be Learned, and When Should They Be Reasoned?13 Oct 2026
- 2026Breaking the Space Barrier and its Application to Language Model Inference6 Oct 2026
- 2026Grammar-Guided Code Watermarking with Green Temperature4 Oct 2026
- 2026Mingbird: A Local-First Agent Harness Enabling Small Open Models to Complete Real Tasks1 Oct 2026
- 2026Selection-Based Structured Reasoning: Toward Efficient Multimodal Search Agents1 Oct 2026
- 2026Benchmarking System One decision models against trained classifiers and language models for automated decision gates29 Sep 2026
- 2026ContractRL: Shielded Group-Relative Policy Optimization for Auditable Tool-Call Repair29 Sep 2026
- 2026Typed Decision Models: An Early Evidence Audit and Evaluation Checklist26 Sep 2026
- 2026The Diagnosis a Reporter Leaves Unspoken: Surfacing Frozen Tumor Features for Brain-Tumor MRI Reporting2 Sep 2026
- 2026Monocultural Biases: Correlated biases in large language models lead to unequal systemic exclusion rates in hiring26 Aug 2026
- 2026Meta-Ctrl: Guaranteed Plan Generation by Decoupling Syntactic and Semantic Constraints23 Aug 2026
- 2026Trie Automata for Constrained Decoding over Large Finite Sets12 Aug 2026
12 newest of 42 All 42 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2026Learning Context-Free Grammars for Grammar-Constrained Decoding via Declarative Agentic Programming with Guarantees
- 2023Splitwise: Efficient generative LLM inference using phase splitting
- 2025Scaling Instruction-Tuned LLMs to Million-Token Contexts via Hierarchical Synthetic Data Generation
- 2024Large Language Model Inference Acceleration: A Comprehensive Hardware Perspective
- 2024Minions: Accelerating Large Language Model Inference with Aggregated Speculative Execution
- 2024Adaptable Logical Control for Large Language Models
- 2026Write Once, Run Everywhere: The Axon DSL for Shape-Safe and Framework-Agnostic LLM Architectures
- 2024LLM Inference Unveiled: Survey and Roofline Model Insights