Grammar Prompting for Domain-Specific Language Generation with Large Language Models
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) can learn to perform a wide range of natural language tasks from just a handful of in-context examples. However, for generating strings from highly structured languages (e.g., semantic parsing to complex domain-specific languages), it is challenging for the LLM to generalize from just a few exemplars. We propose grammar prompting, a simple approach to enable LLMs to use external knowledge and domain-specific constraints, expressed through a grammar in Backus--Naur Form (BNF), during in-context learning. Grammar prompting augments each demonstration example with a specialized grammar that is minimally sufficient for generating the particular output example, where the specialized grammar is a subset of the full DSL grammar. For inference, the LLM first predicts a BNF grammar given a test input, and then generates the output according to the rules of the grammar. Experiments demonstrate that grammar prompting can enable LLMs to perform competitively on a diverse set of DSL generation tasks, including semantic parsing (SMCalFlow, Overnight, GeoQuery), PDDL planning, and SMILES-based molecule generation.
Key facts. Cited by 58 papers in the map (data through 14 Oct 2026). Builds on 75 of its 100 references that are in the map. First posted on arXiv 30 May 2023.
Builds on
75 of 100 references.
References · 75
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,182
- 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,780
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,211
- 2022Do As I Can, Not As I Say: Grounding Language in Robotic Affordancescited by 2,348
- 2023Voyager: An Open-Ended Embodied Agent with Large Language Modelscited by 2,191
- 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
38 more
- 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,470
- 2023PaLM 2 Technical Reportcited by 1,162
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,076
- 2022Language Models as Zero-Shot Planners: Extracting Actionable Knowledge for Embodied Agentscited by 1,035
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 886
- 2023Visual ChatGPT: Talking, Drawing and Editing with Visual Foundation Modelscited by 668
- 2018Junction Tree Variational Autoencoder for Molecular Graph Generationcited by 652
- 2023ViperGPT: Visual Inference via Python Execution for Reasoningcited by 603
- 2023MM-REACT: Prompting ChatGPT for Multimodal Reasoning and Actioncited by 517
- 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
- 2023Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoningcited by 391
- 2022PlanBench: An Extensible Benchmark for Evaluating Large Language Models on Planning and Reasoning about Changecited by 382
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2023Tool Learning with Foundation Modelscited by 302
- 2023Faithful Chain-of-Thought Reasoningcited by 288
- 2017Grammar Variational Autoencodercited by 285
- 2023ART: Automatic multi-step reasoning and tool-use for large language modelscited by 197
- 2023TaskMatrix.AI: Completing Tasks by Connecting Foundation Models with Millions of APIscited by 184
- 2022Translation between Molecules and Natural Languagecited by 177
- 2021Constrained Language Models Yield Few-Shot Semantic Parserscited by 163
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2018PDDLStream: Integrating Symbolic Planners and Blackbox Samplers via Optimistic Adaptive Planningcited by 150
- 2020Compositional Generalization and Natural Language Variation: Can a Semantic Parsing Approach Handle Both?cited by 147
- 2023Compositional Exemplars for In-context Learningcited by 144
- 2022Diverse Demonstrations Improve In-context Compositional Generalizationcited by 139
- 2022ChemBERTa-2: Towards Chemical Foundation Modelscited by 127
- 2023Solving Math Word Problems by Combining Language Models With Symbolic Solverscited by 124
- 2020Task-Oriented Dialogue as Dataflow Synthesiscited by 122
- 2016Recurrent Neural Network Grammarscited by 109
- 2022Language Model Cascadescited by 107
- 2018Syntax-Directed Variational Autoencoder for Structured Datacited by 103
- 2023SatLM: Satisfiability-Aided Language Models Using Declarative Promptingcited by 102
- 2021Skill Induction and Planning with Latent Languagecited by 99
- 2020Span-based Semantic Parsing for Compositional Generalizationcited by 77
- 2019Compound Probabilistic Context-Free Grammars for Grammar Inductioncited by 76
- 2020Retro*: Learning Retrosynthetic Planning with Neural Guided A* Searchcited by 76
- 2018A Survey on Semantic Parsingcited by 62
50 most cited of 75 All 75 (JSON)
Built on by
Citing papers per year: 2023: 2; 2024: 24; 2025: 17; 2026: 15.
58 papers.
Sort:
By area:
- 2023Efficient Guided Generation for Large Language Modelscited by 200
- 2024Large Language Model (LLM) for Telecommunications: A Comprehensive Survey on Principles, Key Techniques, and Opportunitiescited by 83
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 75
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 71
- 2024A Survey on LLM-based Code Generation for Low-Resource and Domain-Specific Programming Languagescited by 66
- 2025QuestBench: Can LLMs ask the right question to acquire information in reasoning tasks?cited by 63
- 2024DeAL: Decoding-time Alignment for Large Language Modelscited by 55
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlocited by 46
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 43
- 2024Learning Agent-based Modeling with LLM Companions: Experiences of Novices and Experts Using ChatGPT & NetLogo Chatcited by 23
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2024Large Language Models for Constructing and Optimizing Machine Learning Workflows: A Surveycited by 19
38 more
- 2024SymbolicAI: A framework for logic-based approaches combining generative models and solverscited by 16
- 2024Generating consistent PDDL domains with Large Language Modelscited by 15
- 2024Synthesizing Programmatic Reinforcement Learning Policies with Large Language Model Guided Searchcited by 13
- 2025A Survey on Inference Engines for Large Language Models: Perspectives on Optimization and Efficiencycited by 12
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
- 2024RoboMorph: Evolving Robot Morphology using Large Language Modelscited by 8
- 2024DataLab: A Unified Platform for LLM-Powered Business Intelligencecited by 8
- 2024Grammar-based Game Description Generation using Large Language Modelscited by 7
- 2024VeriGraph: Scene Graphs for Execution Verifiable Robot Planningcited by 7
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMscited by 7
- 2024Synthetic Programming Elicitation for Text-to-Code in Very Low-Resource Programming and Formal Languagescited by 6
- 2025MoE2: Optimizing Collaborative Inference for Edge Large Language Modelscited by 6
- 2025Hierarchically Encapsulated Representation for Protocol Design in Self-Driving Labscited by 6
- 2024Guiding Large Language Models to Generate Computer-Parsable Contentcited by 4
- 2025LogiCase: Effective Test Case Generation from Logical Description in Competitive Programmingcited by 4
- 2025Robot Operation of Home Appliances by Reading User Manualscited by 4
- 2025How to Auto-optimize Prompts for Domain Tasks? Adaptive Prompting and Reasoning through Evolutionary Domain Knowledge Adaptationcited by 4
- 2023Evaluating In-Context Learning of Libraries for Code Generationcited by 3
- 2024Autoware.Flex: Human-Instructed Dynamically Reconfigurable Autonomous Driving Systemscited by 3
- 2025Constrained Adaptive Rejection Samplingcited by 3
- 2024TriplePlay: Enhancing Federated Learning with CLIP for Non-IID Data and Resource Efficiencycited by 2
- 2025Investigating Language Model Capabilities to Represent and Process Formal Knowledge: A Preliminary Study to Assist Ontology Engineeringcited by 2
- 2026HAVEN: Hybrid Automated Verification ENgine for UVM Testbench Synthesis with LLMscited by 2
- 2026Sequential Planning via Anchored Robotic Keypointscited by 2
- 2024Semantic Parsing with Candidate Expressions for Knowledge Base Question Answeringcited by 1
- 2024G2T-LLM: Graph-to-Tree Text Encoding for Molecule Generation with Fine-Tuned Large Language Modelscited by 1
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learningcited by 1
- 2025Using (Not-so) Large Language Models to Generate Simulation Models in a Formal DSL: A Study on Reaction Networkscited by 1
- 2025Diverse Prompts: Illuminating the Prompt Space of Large Language Models with MAP-Elitescited by 1
- 2026Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loopcited by 1
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expandingcited by 1
- 2024GPTA: Generative Prompt Tuning Assistant for Synergistic Downstream Neural Network Enhancement with LLMscited by 0
- 2024Prose-to-P4: Leveraging High Level Languagescited by 0
- 2024NSP: A Neuro-Symbolic Natural Language Navigational Plannercited by 0
- 2024PALLM: Evaluating and Enhancing PALLiative Care Conversations with Large Language Modelscited by 0
- 2025textttSEM-CTRL: Semantically Controlled Decodingcited by 0
- 2026Cluster Workload Allocation: Semantic Soft Affinity Using Natural Language Processingcited by 0
- 2026How Creative Are Large Language Models in Generating Molecules?cited by 0
50 most cited of 58 All 58 (JSON)
- 2026Where LLMs Fail with Visualization DSLs1 Oct 2026
- 2026MatLoom: Layered Text-to-Material Generation in a Compact Program Space30 Sep 2026
- 2026ISA-Bench: A Benchmark for Computational Reasoning Across Instruction Set Architectures19 Sep 2026
- 2026Agent Gym: A Framework for Continuous Evaluation and Evolution of LLM Agents Through Human-in-the-Loop Feedback16 Aug 2026
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Models30 Jul 2026
- 2026Knowledge-Conditioned, Single-Pass LLM Synthesis of Executable Unity Game Scenes: A Compiler Error Census across 26 Goal Playable Concepts11 Jul 2026
- 2026Sequential Planning via Anchored Robotic Keypoints29 Jun 2026
- 2026Repository-Level Solidity Code Generation with Large Language Models: From Prompting to Fine-Tuning18 Jun 2026
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
- 2026HAVEN: Hybrid Automated Verification ENgine for UVM Testbench Synthesis with LLMs30 Apr 2026
- 2026How Creative Are Large Language Models in Generating Molecules?20 Apr 2026
- 2026RedParrot: Accelerating NL-to-DSL for Business Analytics via Query Semantic Caching7 Mar 2026
38 more
- 2026Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop25 Jan 2026
- 2026Cluster Workload Allocation: Semantic Soft Affinity Using Natural Language Processing14 Jan 2026
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMs7 Jan 2026
- 2025How to Auto-optimize Prompts for Domain Tasks? Adaptive Prompting and Reasoning through Evolutionary Domain Knowledge Adaptation24 Oct 2025
- 2025Constrained Adaptive Rejection Sampling2 Oct 2025
- 2025Investigating Language Model Capabilities to Represent and Process Formal Knowledge: A Preliminary Study to Assist Ontology Engineering12 Sep 2025
- 2025Robot Operation of Home Appliances by Reading User Manuals26 May 2025
- 2025LogiCase: Effective Test Case Generation from Logical Description in Competitive Programming21 May 2025
- 2025A Survey on Inference Engines for Large Language Models: Perspectives on Optimization and Efficiency3 May 2025
- 2025Diverse Prompts: Illuminating the Prompt Space of Large Language Models with MAP-Elites19 Apr 2025
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlo17 Apr 2025
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Sampling7 Apr 2025
- 2025Hierarchically Encapsulated Representation for Protocol Design in Self-Driving Labs4 Apr 2025
- 2025QuestBench: Can LLMs ask the right question to acquire information in reasoning tasks?28 Mar 2025
- 2025textttSEM-CTRL: Semantically Controlled Decoding3 Mar 2025
- 2025Using (Not-so) Large Language Models to Generate Simulation Models in a Formal DSL: A Study on Reaction Networks3 Mar 2025
- 2025Flexible and Efficient Grammar-Constrained Decoding7 Feb 2025
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Models18 Jan 2025
- 2025MoE2: Optimizing Collaborative Inference for Edge Large Language Models16 Jan 2025
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learning6 Jan 2025
- 2024Autoware.Flex: Human-Instructed Dynamically Reconfigurable Autonomous Driving Systems20 Dec 2024
- 2024DataLab: A Unified Platform for LLM-Powered Business Intelligence3 Dec 2024
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models22 Nov 2024
- 2024VeriGraph: Scene Graphs for Execution Verifiable Robot Planning15 Nov 2024
- 2024Large Language Models for Constructing and Optimizing Machine Learning Workflows: A Survey11 Nov 2024
- 2024Controllable Generation via Locally Constrained Resampling17 Oct 2024
- 2024A Survey on LLM-based Code Generation for Low-Resource and Domain-Specific Programming Languages4 Oct 2024
- 2024G2T-LLM: Graph-to-Tree Text Encoding for Molecule Generation with Fine-Tuned Large Language Models3 Oct 2024
- 2024Semantic Parsing with Candidate Expressions for Knowledge Base Question Answering1 Oct 2024
- 2024PALLM: Evaluating and Enhancing PALLiative Care Conversations with Large Language Models23 Sep 2024
- 2024NSP: A Neuro-Symbolic Natural Language Navigational Planner10 Sep 2024
- 2024TriplePlay: Enhancing Federated Learning with CLIP for Non-IID Data and Resource Efficiency9 Sep 2024
- 2024Grammar-based Game Description Generation using Large Language Models24 Jul 2024
- 2024RoboMorph: Evolving Robot Morphology using Large Language Models11 Jul 2024
- 2024Prose-to-P4: Leveraging High Level Languages19 Jun 2024
- 2024Synthetic Programming Elicitation for Text-to-Code in Very Low-Resource Programming and Formal Languages5 Jun 2024
- 2024Synthesizing Programmatic Reinforcement Learning Policies with Large Language Model Guided Search26 May 2024
- 2024Large Language Model (LLM) for Telecommunications: A Comprehensive Survey on Principles, Key Techniques, and Opportunities17 May 2024
50 newest of 58 All 58 (JSON)
- 2024Large Language Model (LLM) for Telecommunications: A Comprehensive Survey on Principles, Key Techniques, and Opportunitiescited by 83
- 2025QuestBench: Can LLMs ask the right question to acquire information in reasoning tasks?cited by 63
- 2025How to Auto-optimize Prompts for Domain Tasks? Adaptive Prompting and Reasoning through Evolutionary Domain Knowledge Adaptationcited by 4
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learningcited by 1
- 2026ISA-Bench: A Benchmark for Computational Reasoning Across Instruction Set Architecturescited by 0
- 2026ISA-Bench: A Benchmark for Computational Reasoning Across Instruction Set Architectures19 Sep 2026
- 2025How to Auto-optimize Prompts for Domain Tasks? Adaptive Prompting and Reasoning through Evolutionary Domain Knowledge Adaptation24 Oct 2025
- 2025QuestBench: Can LLMs ask the right question to acquire information in reasoning tasks?28 Mar 2025
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learning6 Jan 2025
- 2024Large Language Model (LLM) for Telecommunications: A Comprehensive Survey on Principles, Key Techniques, and Opportunities17 May 2024
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 75
- 2024Learning Agent-based Modeling with LLM Companions: Experiences of Novices and Experts Using ChatGPT & NetLogo Chatcited by 23
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMscited by 7
- 2026Agent Gym: A Framework for Continuous Evaluation and Evolution of LLM Agents Through Human-in-the-Loop Feedbackcited by 0
- 2026Agent Gym: A Framework for Continuous Evaluation and Evolution of LLM Agents Through Human-in-the-Loop Feedback16 Aug 2026
- 2026XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMs7 Jan 2026
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models22 Nov 2024
- 2024Learning Agent-based Modeling with LLM Companions: Experiences of Novices and Experts Using ChatGPT & NetLogo Chat30 Jan 2024
- 2024DeAL: Decoding-time Alignment for Large Language Modelscited by 55
- 2024DeAL: Decoding-time Alignment for Large Language Models5 Feb 2024
- 2026Sequential Planning via Anchored Robotic Keypointscited by 2
- 2026Sequential Planning via Anchored Robotic Keypoints29 Jun 2026
- 2023Efficient Guided Generation for Large Language Modelscited by 200
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 71
- 2024A Survey on LLM-based Code Generation for Low-Resource and Domain-Specific Programming Languagescited by 66
- 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
- 2024Large Language Models for Constructing and Optimizing Machine Learning Workflows: A Surveycited by 19
- 2024SymbolicAI: A framework for logic-based approaches combining generative models and solverscited by 16
- 2024Generating consistent PDDL domains with Large Language Modelscited by 15
- 2024Synthesizing Programmatic Reinforcement Learning Policies with Large Language Model Guided Searchcited by 13
- 2025A Survey on Inference Engines for Large Language Models: Perspectives on Optimization and Efficiencycited by 12
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
12 most cited of 42 All 42 (JSON)
- 2026Where LLMs Fail with Visualization DSLs1 Oct 2026
- 2026MatLoom: Layered Text-to-Material Generation in a Compact Program Space30 Sep 2026
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Models30 Jul 2026
- 2026Knowledge-Conditioned, Single-Pass LLM Synthesis of Executable Unity Game Scenes: A Compiler Error Census across 26 Goal Playable Concepts11 Jul 2026
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
- 2026HAVEN: Hybrid Automated Verification ENgine for UVM Testbench Synthesis with LLMs30 Apr 2026
- 2026How Creative Are Large Language Models in Generating Molecules?20 Apr 2026
- 2026RedParrot: Accelerating NL-to-DSL for Business Analytics via Query Semantic Caching7 Mar 2026
- 2026Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop25 Jan 2026
- 2026Cluster Workload Allocation: Semantic Soft Affinity Using Natural Language Processing14 Jan 2026
- 2025Constrained Adaptive Rejection Sampling2 Oct 2025
- 2025Investigating Language Model Capabilities to Represent and Process Formal Knowledge: A Preliminary Study to Assist Ontology Engineering12 Sep 2025
12 newest of 42 All 42 (JSON)