JsonTuning: Towards Generalizable, Robust, and Controllable Instruction Tuning

Chang Gao, Wenxuan Zhang, Guizhen Chen, Wai Lam

Abstract

Instruction tuning is vital for enhancing the performance of large language models (LLMs), but existing text-to-text methods, referred to as TextTuning, struggle with issues such as generalization, robustness, and controllability due to their lack of explicit task structures. We introduce JsonTuning, a structure-to-structure approach that uses JSON structures to represent tasks. This method improves generalization by clarifying task elements and their relations, boosts robustness by minimizing ambiguity, and enhances controllability by allowing precise control over outputs. We conduct an extensive comparative analysis between JsonTuning and TextTuning using various language models and benchmarks. Our findings reveal that JsonTuning consistently surpasses TextTuning in terms of performance, robustness, and controllability across different scenarios. By overcoming the limitations of TextTuning, JsonTuning demonstrates significant potential for developing more effective and reliable LLMs capable of handling diverse scenarios.

Introduction

Most current Large Language Models (LLMs) are fine-tuned using "TextTuning," a text-to-text approach where both instructions and responses are unstructured strings. While this aligns with pre-training objectives, it introduces three major hurdles: limited generalization due to the mixing of task data and instructions, low robustness to prompt variations, and poor controllability over specific output formats. This paper introduces JsonTuning, a structure-to-structure formulation designed to address these limitations by explicitly representing task inputs and outputs as structured JSON objects.

Methodology

JsonTuning moves beyond traditional unstructured strings by incorporating explicit task structures and JSON Schemas into the tuning process. In this framework, the model receives a JSON object containing three primary keys:

  • input: Contains the raw task elements (e.g., the text to be analyzed).
  • instruction: The natural language prompt describing the goal.
  • output control: A JSON Schema that precisely defines the expected output format, including data types and field descriptions.
Comparison of the traditional TextTuning workflow versus the proposed JsonTuning structure-to-structure approach.

By decoupling the task logic from the linguistic phrasing, the model can better learn the underlying "skeleton" of a task. The researchers utilized Parameter-Efficient Fine-Tuning (LoRA) to train models such as Falcon-7B, Mistral-7B, and the LLaMA series.

Experimental Setup

The study utilized a diverse range of datasets for training and evaluation. Training involved a subset of Flan 2022 for general instructions and InstructUIE for structured Information Extraction (IE) tasks. Evaluation spanned general benchmarks (MMLU, BBH), structured tasks (NER, Relation Extraction, Event Extraction), and code/logic tasks (Spider for NL2SQL).

Results and Discussion

JsonTuning consistently outperformed TextTuning across all tested models, with the average score across benchmarks rising from 26.78 to 30.88.

Generalization and Controllability

One of the most significant findings was the model's ability to generalize to unseen, complex structures. Models trained on simple JSON structures successfully generated complex, nested outputs for entirely new tasks. Furthermore, the rate of "invalid JSON" produced by Json-tuned models was near zero (typically <1%), demonstrating superior format adherence compared to natural language prompting.

Robustness to Prompt Engineering

LLMs are typically sensitive to minor changes in prompt wording. JsonTuning effectively mitigates this brittleness. By labeling task elements clearly within the JSON structure, the model becomes significantly less sensitive to how the instruction string is phrased.

Performance and robustness comparison across MMLU, NER, and NL2SQL benchmarks, showing reduced variance for JsonTuning.

As shown in the performance clusters, JsonTuning models (LLaMA-7B-Json and LLaMA2-7B-Json) exhibit much tighter groupings across different prompt variations compared to their TextTuning counterparts, indicating higher stability and reliability.

Conclusion

JsonTuning demonstrates that incorporating explicit structure into instruction tuning significantly enhances LLM performance, robustness, and controllability. By providing a clear blueprint via JSON Schemas, the method allows models to handle diverse and complex scenarios more effectively than traditional text-to-text approaches. Future work will explore the scaling of this method to larger models and the development of more user-friendly interfaces for structured input.

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