Guiding Large Language Models to Generate Computer-Parsable Content
Not on the map. Why?
Abstract (arXiv)
We propose a method to guide Large Language Models (LLMs) in generating structured content adhering to specific conventions without fine-tuning. By utilizing coroutine-based content generation constraints through a pre-agreed context-free grammar (CFG), LLMs are directed during decoding to produce formal language compliant outputs. This enhances stability and consistency in generating target data structures, types, or instructions, reducing application development complexities. Experimentally, error rates of GPT-2 and Gemma exceed 95% for DSLs longer than 36 and 282 tokens, respectively. We introduce YieldLang, a coroutine-based DSL generation framework, and evaluate it with LLMs on various tasks including JSON and Mermaid flowchart generation. Compared to benchmarks, our approach improves accuracy by 1.09 to 11.6 times, with LLMs requiring only about 16.5% of the samples to generate JSON effectively. This enhances usability of LLM-generated content for computer programs.
Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 11 of its 48 references that are in the map. First posted on arXiv 8 Apr 2024.
Builds on
11 of 48 references.
References · 11
- 2017Attention Is All You Needcited by 59,932
- 2023GPT-4 Technical Reportcited by 18,132
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
- 2024Gemma: Open Models Based on Gemini Research and Technologycited by 889
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 186
- 2023Mitigating the Alignment Tax of RLHFcited by 181
- 2023Grammar Prompting for Domain-Specific Language Generation with Large Language Modelscited by 58
- 2023Cost-Effective Hyperparameter Optimization for Large Language Model Generation Inferencecited by 40
- 2022Q# as a Quantum Algorithmic Languagecited by 1
Built on by
Citing papers per year: 2024: 2; 2025: 0; 2026: 2.
4 papers.
- 2024StructuredRAG: JSON Response Formatting with Large Language Modelscited by 22
- 2024Large Language Models for Constructing and Optimizing Machine Learning Workflows: A Surveycited by 19
- 2026GenAI-DrawIO-Creator: A Framework for Automated Diagram Generationcited by 1
- 2026Leveraging LLMs for Multi-File DSL Code Generation: An Industrial Case Studycited by 0
- 2026Leveraging LLMs for Multi-File DSL Code Generation: An Industrial Case Study27 Apr 2026
- 2026GenAI-DrawIO-Creator: A Framework for Automated Diagram Generation8 Jan 2026
- 2024Large Language Models for Constructing and Optimizing Machine Learning Workflows: A Survey11 Nov 2024
- 2024StructuredRAG: JSON Response Formatting with Large Language Models7 Aug 2024