AI RESEARCH
TruncProof: A Guardrail for LLM-based JSON Generation under Token-Length Constraints
arXiv CS.CL
•
ArXi:2605.13076v1 Announce Type: new 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.