IterGen: Iterative Semantic-aware Structured LLM Generation with Backtracking
Shubham Ugare, Rohan Gumaste, Tarun Suresh, Gagandeep Singh, Sasa, Misailovic

TL;DR
IterGen is a novel library that enhances structured LLM generation by enabling iterative, backtracking-based corrections guided by grammar, leading to improved output accuracy and privacy safety.
Contribution
It introduces IterGen, a user-friendly framework that supports bidirectional, grammar-guided LLM generation with backtracking for correction and refinement.
Findings
Reduces privacy leakage in LLM outputs.
Improves accuracy of SQL and Vega-Lite queries.
Enables efficient, structured generation with backtracking.
Abstract
Large Language Models (LLMs) are widely used for tasks such as natural language and code generation, but their outputs often suffer from issues like hallucination, toxicity, and incorrect results. Current libraries for structured LLM generation rely on left-to-right decoding without support for backtracking, limiting the ability to correct or refine outputs mid-generation. To address this, we introduce IterGen, a user-friendly library for iterative, grammar-guided LLM generation that enables users to move both forward and backward within the generated output based on grammar symbols. By leveraging a symbol-to-position mapping and maintaining the key-value (KV) cache state, IterGen ensures efficient and structured generation while allowing for corrections during the process. We demonstrate IterGen's effectiveness in two important applications: reducing privacy leakage in LLM outputs…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNatural Language Processing Techniques · Mathematics, Computing, and Information Processing
MethodsLib
