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

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

TL;DR

Data scarcity is a major bottleneck for training text-to-SQL parsers, but existing automatic data synthesis methods generate noisy, unrealistic queries that fail to improve state-of-the-art models. This paper introduces a high-quality synthesis framework featuring strong typing, schema-weighted sampling, and an intermediate representation to bridge the SQL-to-text gap. The resulting data yields significant accuracy boosts, setting a new state-of-the-art on the Spider benchmark and dramatically improving performance in few-shot scenarios.

What Problem Does This Paper Address?

Building reliable text-to-SQL systems—which translate natural language questions into executable SQL queries—requires large parallel datasets. However, hiring human experts to annotate these pairs is expensive and difficult to scale.

While researchers have turned to automatic data synthesis to alleviate this bottleneck, the authors discover a surprising catch: current synthetic datasets provide negligible benefits when training powerful, state-of-the-art parsers like PICARD. They trace this failure to three main sources of noise:

  1. Illogical SQL queries: Grammars often generate nonsensical operations, such as applying a SUM aggregator to a text column.
  2. Overly complex queries: Random column and table sampling leads to arbitrary, sprawling multi-table joins that do not reflect real-world user intents.
  3. The Language Gap: Directly translating raw, complex SQL back into natural language questions creates awkward, error-prone text.

Methods

The authors propose a refined two-stage synthesis pipeline that first generates high-quality SQL templates and then translates them into natural language questions.

Figure 3: Our NLQ-SQL synthesis framework. Novel components include strong-typing, key relations, schema- distance-weighted column sampler, and SQL →IR con- verter.

1. High-Quality SQL Synthesis

Instead of relying on unconstrained context-free grammars, the framework extracts templates from real data and injects three key constraints:

  • Strong Typing: Templates explicitly preserve data types (e.g., textkey vs. numberkey) to ensure that operators match column types.
  • Key Relationship Preservation: The system tracks primary and foreign key relationships across clauses (like INTERSECT or UNION) to guarantee logical consistency.
  • Schema-Distance-Weighted Column Sampling: To prevent absurdly complex multi-table joins, the database schema is modeled as an undirected graph. Column sampling is biased toward tables that are close to each other in the graph, mimicking realistic human queries.

2. Intermediate Representation (IR) for Text Generation

To fix the language gap, the authors introduce a specialized IR that simplifies raw SQL before it is fed into a T5 question generator. The IR strips out redundant FROM and JOIN clauses, replaces generic count(*) expressions with explicit context, and explicitly rewrites intents like ORDER BY ... LIMIT 1 into clear "most/least" representations.

Datasets

  • Spider: The primary benchmark used for evaluation. It is a large-scale, complex, cross-database text-to-SQL dataset containing 10,181 questions across 200 distinct databases.
  • SQUALL: A challenging single-table text-to-SQL dataset used to test how well the framework generalizes outside of multi-table environments.

Key Insights and Ideas

  • Quality Over Quantity: State-of-the-art parsers are highly sensitive to synthetic noise. Eliminating illogical joins and invalid operations is far more critical for downstream performance gains than simply generating a massive volume of data.
  • IR Lowers the Compute Bar: Introducing the intermediate representation makes the question generation task robust enough that a smaller model (T5-Base) performs nearly as well as a larger one (T5-Large), significantly reducing computational overhead.
  • A Lifesaver for Few-Shot Learning: The value of high-quality synthetic data scales inversely with the amount of available real data. It acts as an incredible booster when human labels are extremely scarce.

Key Results

  • New SOTA on Spider: Pre-finetuning a T5-3B model with PICARD constraint decoding on the new synthetic data achieved a state-of-the-art exact match (EM) score of 76.9% and an execution accuracy of 81.4%.
  • Massive Few-Shot Gains: In a 128-shot setting (using only 128 real training examples), augmenting the training with synthetic data boosted exact match performance from 19.1% to 46.3%—a massive 27.2-point jump.
  • Realistic Join Distribution: As shown in Figure 4, the schema-distance-weighted sampling successfully matched the distribution of table joins found in real-world human data, avoiding the over-complex queries generated by random sampling.
Figure 4: Histogram of the average table count (i.e. umber of joins) for three types of datasets with γ = 5. Our schema- distance-weighted column sampling reduces the table num- ber of synthetic SQLs and better matches the training distri- bution.

Limitations and Future Work

While highly effective for complex, multi-table databases, the framework provides minimal improvement on single-table datasets like SQUALL (yielding only a minor +0.5% execution accuracy boost). This is because its core strengths—such as foreign key preservation and schema-distance weighting—are inherently designed to solve multi-table complexities.

For future work, the authors suggest expanding the framework to leverage broader public database schemas (e.g., WikiTables or GitTables) to implicitly cover unseen evaluation domains and further boost cross-database generalization.

Summary updated

BibTeX
@misc{zhao2022importance,
  author = {Yiyun Zhao and Jiarong Jiang and Yiqun Hu and Wuwei Lan and Henry Zhu and Anuj Chauhan and Alexander Hanbo Li and Lin Pan and Jun Wang and Chung-Wei Hang and Sheng Zhang and Marvin Dong and Joe 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}},
  year = {2022},
  eprint = {2212.08785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.08785},
}
Figure