TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints
Not on the map. Why?
Abstract (arXiv)
The LLM-based generation of machine-readable outputs such as JSON has attracted significant attention for integration with external systems. However, existing approaches cannot strictly enforce the maximum number of tokens to be generated, leading to infinite generation or truncated outputs that cause a system malfunction. To address this limitation, we propose TruncProof, a novel grammar-constrained generation method that enables LLMs to produce grammatically valid JSONs while adhering to a predefined token limit. By leveraging the properties of LL(1) parsers, TruncProof efficiently approximates the minimum number of tokens required to complete a grammatically valid output at each decoding step. Experiments on the Text-to-JSON instruction tasks demonstrate that TruncProof successfully generates syntactically correct outputs even under strict token constraints. Furthermore, we show that TruncProof can be effectively combined with advanced decoding strategies, resulting in outputs that are not only grammatically valid but also semantically accurate. The source code is public at https://github.com/Yosshi999/TruncProof
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Builds on 17 of its 31 references that are in the map. First posted on arXiv 13 May 2026.
Builds on
17 of 31 references.
References · 17
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022Visual Programming: Compositional visual reasoning without trainingcited by 507
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
- 2023Efficient Guided Generation for Large Language Modelscited by 192
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 186
- 2023MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoningcited by 155
- 2022Prompting Is Programming: A Query Language for Large Language Modelscited by 110
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 99
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 73
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
- 2021Machine Translation Decoding beyond Beam Searchcited by 55
- 2024Grammar-Aligned Decodingcited by 54
5 more
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlocited by 45
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 42
- 2021PPL-MCTS: Constrained Textual Generation Through Discriminator-Guided MCTS Decodingcited by 32
- 2024IterGen: Iterative Semantic-aware Structured LLM Generation with Backtrackingcited by 28
- 2025Correctness-Guaranteed Code Generation via Constrained Decodingcited by 7
Built on by
Citing papers per year: 2026: 1.
1 paper.