NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Generating Structured Outputs from Language Models: Benchmark and Studies

Saibo Geng, Hudson Cooper, Michal Moskal, Samuel Jenkins, Julian Berman, Nathan Ranchin, Robert West, Eric Horvitz, Harsha NoriarXiv 2025 · DOI

Abstract

As Large Language Models (LLMs) transition from conversational interfaces to autonomous agents, the ability to generate structured, machine-readable data (e.g., JSON) becomes paramount. This paper introduces JSONSchemaBench, a rigorous benchmark comprising 10,000 real-world schemas. The evaluation reveals that constrained decoding frameworks do not merely ensure format adherence but can significantly enhance generation efficiency—improving speeds by up to 50%—and boost reasoning accuracy by approximately 4%.

Introduction

The reliability of LLM-based agents depends on their ability to interact with external APIs and databases via structured formats. To prevent syntax errors and hallucinations, developers employ constrained decoding, which restricts the model's output space to valid tokens defined by a schema. Despite the proliferation of frameworks like Guidance, Outlines, and XGrammar, a systematic evaluation of their performance overhead, schema coverage, and impact on model reasoning has been lacking until now.

The JSONSchemaBench Framework

To address this gap, the authors developed JSONSchemaBench. This dataset curates 9,558 schemas from diverse sources, including GitHub, Kubernetes, and GlaiveAI, representing a wide spectrum of complexity and real-world utility.

Composition of the JSONSchemaBench dataset, featuring nearly 10,000 real-world schemas across various categories.

The benchmark evaluates frameworks across three primary axes:

  1. Efficiency: Measuring Grammar Compilation Time (GCT), Time to First Token (TTFT), and Time per Output Token (TPOT).
  2. Coverage: Assessing the breadth of JSON Schema features supported (e.g., anyOf, pattern, minItems).
  3. Quality: Determining if structural constraints interfere with the model's underlying semantic logic.

Results and Key Insights

The study yields several counter-intuitive findings regarding the perceived "tax" of constrained decoding.

Efficiency and Acceleration

Contrary to the assumption that masking invalid tokens adds overhead, advanced frameworks like Guidance actually accelerate generation. By utilizing "token-healing" and "fast-forwarding," these engines skip the model's forward pass for static structural elements (like JSON keys and brackets). This results in throughput improvements of up to 50%, with some frameworks reaching ~6-9ms per token compared to ~15-16ms for standard unconstrained models.

The Reasoning Boost

A significant finding is that forcing a model to follow a JSON structure can actually improve performance on logic-heavy tasks. On the GSM8K math benchmark, accuracy rose from 80.1% to 83.8%. The constraints act as "guardrails," preventing the model from drifting into out-of-distribution token sequences that often lead to errors.

Comprehensive evaluation of constrained decoding frameworks across (A) Efficiency, (B) Coverage, and (C) Quality.

The Coverage Gap

There is a notable disparity in framework maturity. Open-source libraries like Guidance often exhibit higher empirical coverage than proprietary solutions from OpenAI or Gemini, which support a more conservative subset of the JSON Schema specification. Furthermore, the paper identifies two failure modes: "over-constraining" (rejecting valid JSON) and "under-constraining" (allowing invalid JSON).

Conclusion

JSONSchemaBench provides a necessary foundation for evaluating structured output generation. While constrained decoding offers clear benefits in speed and accuracy, framework choice is critical due to varying compilation overheads—such as the higher latency seen in Outlines—and feature support. Future research will focus on expanding coverage for complex optional features and exploring the impact on multi-modal model architectures.

Summary updated

BibTeX
@misc{geng2025generating,
  author = {Saibo Geng and Hudson Cooper and Michal Moskal and Samuel Jenkins and Julian Berman and Nathan Ranchin and Robert West and Eric Horvitz and Harsha Nori},
  title = {{Generating Structured Outputs from Language Models: Benchmark and Studies}},
  year = {2025},
  eprint = {2501.10868},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.10868},
}
Figure