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

Importance of Synthesizing High-quality Data for Text-to-SQL Parsing

Yiqun Hu, Yiyun Zhao, Jiarong Jiang, Wuwei Lan, Henghui Zhu, Anuj Chauhan, Alexander Hanbo Li, Lin Pan, Jun Wang, Chung-Wei Hang, Sheng Zhang, Jiang Guo, Mingwen Dong, Joseph Lilien, Patrick Ng, Zhiguo Wang, Vittorio Castelli, Bing Xiang

Introduction

Training high-performing Text-to-SQL parsers typically requires massive amounts of expensive, human-annotated data. While synthetic data has been explored as a solution to this scarcity, previous attempts often produced "illogical" queries—such as calculating the sum of a text field or joining unrelated tables. These low-quality examples fail to improve modern models like T5. This paper introduces a novel framework to synthesize high-quality, logical data by enforcing strong typing, preserving schema relationships, and utilizing an intermediate representation (IR) to bridge the gap between code and natural language.

Methodology: Quality-First Synthesis

The authors propose a two-stage pipeline designed to prioritize data quality over sheer volume, ensuring that synthetic examples reflect real-world logic.

1. Logical SQL Synthesis

To prevent the generation of nonsensical queries, the framework introduces three key constraints:

  • Strong Typing: Operators are restricted to compatible column types (e.g., preventing mathematical operations on categorical text).
  • Key Relationship Preservation: Complex operations like INTERSECT or nested subqueries are only performed on columns sharing a verified foreign key relationship.
  • Schema-Distance-Weighted Sampling: By treating the database schema as a graph, the system favors picking tables that are "close" to each other. This mimics realistic human query patterns and avoids illogical "spaghetti joins" between unrelated data entities.

2. NLQ Synthesis via Intermediate Representation

Directly converting SQL to natural language is challenging due to the technical nature of SQL syntax. The authors introduce an Intermediate Representation (IR) that strips away redundant technical details (like explicit JOIN clauses) and enriches the logic with heuristics. The pipeline follows a SQL → IR → Natural Language Question flow, making the final translation to English much more accurate.

Overview of the two-stage synthesis pipeline, covering SQL Synthesis with schema constraints and NLQ Synthesis using an Intermediate Representation.

Key Insights

The research demonstrates that logic is the primary bottleneck in synthetic data. When data violates schema common sense, models learn noise rather than useful patterns. By enforcing "closeness" through schema-distance weighting, the synthetic data becomes significantly more representative of real-world use cases. Furthermore, the IR acts as a "pidgin" language, retaining SQL logic while adopting a sentence-like structure that facilitates better model learning.

Experimental Results

The framework was evaluated primarily on the Spider benchmark, a large-scale cross-domain Text-to-SQL task.

  • State-of-the-Art Performance: Augmenting a T5-3B + PICARD model with this synthetic data achieved a new SOTA Exact Match (EM) score of 76.9% on the Spider dev set.
  • Few-Shot Scenarios: The impact is most pronounced when real data is scarce. In a few-shot setting with only 128 real examples, the addition of synthetic data boosted accuracy from 19.1% to 46.3%—a massive 27.2-point jump.
  • Ablation Success: Removing constraints like strong typing or key preservation led to significant performance drops, confirming that logical consistency is the primary driver of the model's success.
Performance comparison on the Spider dev set across two training stages. Stage 1 shows pre-training on synthetic data, while Stage 2 shows fine-tuning on real data, where the IR2NLQ method significantly outperforms baselines.

Conclusion and Future Work

While highly effective, the current method relies on templates extracted from real data. Future work could involve more flexible grammars to increase query diversity. Additionally, while the "key property" techniques are SQL-specific, the underlying philosophy of logical consistency could be adapted to other structured data domains like SPARQL or Python code generation.

Summary updated

BibTeX
@inproceedings{hu2023importance,
  author = {Yiqun Hu and Yiyun Zhao and Jiarong Jiang and Wuwei Lan and Henghui Zhu and Anuj Chauhan and Alexander Hanbo Li and Lin Pan and Jun Wang and Chung-Wei Hang and Sheng Zhang and Jiang Guo and Mingwen Dong and Joseph Lilien and Patrick Ng and Zhiguo Wang and Vittorio Castelli and Bing Xiang},
  title = {{Importance of Synthesizing High-quality Data for Text-to-SQL Parsing}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.86},
}
Figure