Learning to Generate Structured Output with Schema Reinforcement Learning

Yaxi Lu, Haolun Li, Xin Cong, Zhong Zhang, Yesai Wu +4 more
2/26/2025
cs.CL

No official code found. Best implementation: thunlp/SchemaReinforcementLearning (26 stars, Apache-2.0, last commit 2025-03-02).

Abstract

This study investigates the structured generation capabilities of large language models (LLMs), focusing on producing valid JSON outputs against a given schema. Despite the widespread use of JSON in integrating language models with programs, there is a lack of comprehensive analysis and benchmarking of these capabilities. We explore various aspects of JSON generation, such as structure understanding, escaping, and natural language description, to determine how to assess and enable LLMs to generate valid responses. Building upon this, we propose SchemaBench features around 40K different JSON schemas to obtain and assess models' abilities in generating valid JSON. We find that the latest LLMs are still struggling to generate a valid JSON string. Moreover, we demonstrate that incorporating reinforcement learning with a Fine-grained Schema Validator can further enhance models' understanding of JSON schema, leading to improved performance. Our models demonstrate significant improvement in both generating JSON outputs and downstream tasks.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Learning to Generate STRUCTURED Output with Schema Reinforcement Learning

266Shell, PythonFeb 26, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{lu2025learning,
  title  = {Learning to Generate Structured Output with Schema Reinforcement Learning},
  author = {Yaxi Lu and Haolun Li and Xin Cong and Zhong Zhang and Yesai Wu and Yankai Lin and Zhiyuan Liu and Fangming Liu and Maosong Sun},
  year   = {2025},
  eprint = {2502.18878},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.18878v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.18878.svg)](https://codeofpaper.com/paper/2502.18878)

Discussion