JsonTuning: Towards Generalizable, Robust, and Controllable Instruction Tuning

Chang Gao, Wenxuan Zhang, Guizhen Chen, Wai Lam · OpenReview

Abstract

Instruction tuning is a cornerstone of modern Large Language Model (LLM) development, yet traditional text-to-text approaches (TextTuning) often lack the explicit structure needed for high-level generalization and robustness. We present JsonTuning, a structure-to-structure paradigm that utilizes JSON objects to define task inputs, instructions, and output constraints. By explicitly separating data from logic and providing a schema-based blueprint for responses, JsonTuning significantly enhances model performance across diverse benchmarks, improves robustness to prompt variations, and ensures strict adherence to complex output formats.

Introduction

The current standard for fine-tuning Large Language Models (LLMs) is "TextTuning," where instructions and data are concatenated into a single natural language string. While intuitive, this approach introduces several critical limitations. First, the lack of explicit task structure leads to ambiguity, hindering the model's ability to generalize to novel, complex tasks. Second, models become brittle, showing extreme sensitivity to minor phrasing changes or label swaps (e.g., changing multiple-choice options from A/B to X/Y). Finally, TextTuning offers poor controllability, making it difficult to guarantee that a model will consistently produce valid structured data like JSON or SQL.

Methodology: The JsonTuning Framework

JsonTuning reformulates instruction tuning as a structure-to-structure generation task. Instead of an unstructured paragraph, the model is presented with a structured JSON object containing three primary components:

  1. Input: The raw data for the task (e.g., a source sentence or a question).
  2. Instruction: A clear description of the task to be performed.
  3. Output Control: A JSON Schema that explicitly defines the expected output format, including data types and field descriptions.
The JsonTuning workflow compared to traditional TextTuning.

This structured approach acts as a "blueprint" for the model. By training on these structured pairs, the model learns to use JSON keys as anchors, effectively decoupling the task logic from the raw data. This separation reduces cognitive load and allows the model to focus on the relationship between the input data and the constraints defined in the schema.

Experimental Setup

The effectiveness of JsonTuning was evaluated across seven open-source models, including Falcon-7B, Mistral-7B, and various iterations of the LLaMA series (LLaMA-7B/13B, LLaMA2-7B/13B, and LLaMA3-8B). The benchmarks spanned several domains:

  • General Knowledge & Reasoning: MMLU and BBH.
  • Information Extraction: NER (Named Entity Recognition), RE (Relation Extraction), and EE (Event Extraction).
  • Structured Logic: NL2SQL (Spider dataset).
  • Open-Ended Instruction Following: Alpaca and AlpacaEval.

Key Results and Insights

JsonTuning consistently outperformed TextTuning across nearly all models and tasks. As shown in the comprehensive results table below, the average performance across benchmarks improved from 26.78% to 30.88%.

Comprehensive performance comparison between TextTuning and JsonTuning across various models and benchmarks.

Enhanced Generalization and Robustness

One of the most significant findings was the model's ability to generalize to unseen, complex structures. Models tuned with JsonTuning on simple tasks (like NER) were able to successfully perform zero-shot Event Extraction (EE), a task with much more intricate output requirements. In contrast, TextTuning models often failed to produce any valid structure for these complex tasks.

Furthermore, JsonTuning provides a "robustness shield." In tests where multiple-choice labels were replaced with unseen symbols, JsonTuning models maintained their performance, whereas TextTuning models saw significant degradation. This suggests that the structured format helps the model focus on the underlying task logic rather than superficial text patterns.

Controllability and Reliability

The use of JSON Schema allows for precise "programming" of the LLM's output. The occurrence of syntax errors in the generated JSON was remarkably low (often under 1%), demonstrating that models can be trained to be highly disciplined. In open-ended scenarios evaluated via AlpacaEval, GPT-4 showed a strong preference for JsonTuning outputs, citing better structure and clarity.

Conclusion and Future Directions

JsonTuning represents a significant step toward more reliable and controllable LLMs. By moving from text-to-text to structure-to-structure, we can overcome the inherent ambiguities of natural language instructions. While currently focused on mid-sized models, future research will explore the scalability of this approach to larger models (70B+) and the integration of more advanced schema features to provide even more granular control over model behavior. While JSON may be less "natural" for human users, its benefits for developers and automated systems are clear, potentially leading to a new standard for API-driven LLM interactions.

Summary updated

BibTeX
@inproceedings{gao2025jsontuning,
  author = {Chang Gao and Wenxuan Zhang and Guizhen Chen and Wai Lam},
  title = {{JsonTuning: Towards Generalizable, Robust, and Controllable Instruction Tuning}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=phpKLHbiPJ},
}
Figure