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

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

TL;DR

This paper tackles the problem of low-quality synthetic data hindering text-to-SQL model performance. They introduce a novel synthesis framework that generates more logical and less complex SQL queries by incorporating schema relationships, strong typing, and schema-distance-weighted column sampling. This improved synthetic data significantly boosts the performance of state-of-the-art text-to-SQL parsers, achieving new state-of-the-art results on the Spider benchmark.

What Problem Does This Paper Address?

Text-to-SQL parsing, the task of converting natural language questions into executable SQL queries, is crucial for enabling users to query large relational databases without needing expert SQL knowledge. While the demand for such systems is high, creating large, high-quality labeled datasets for training these models is expensive and time-consuming due to the need for human annotators with SQL expertise. To address this data scarcity, researchers have turned to synthesizing data. However, this paper identifies a critical issue: existing synthetic data generation methods produce "noisy" SQL queries that are often illogical, contain arbitrary multi-table joins, or have a poor language gap with their natural language counterparts. Consequently, training state-of-the-art text-to-SQL models on these synthetic datasets doesn't yield the expected performance improvements, and in some cases, can even degrade performance. This paper aims to bridge this gap by proposing a framework for generating high-quality synthetic data that effectively improves downstream text-to-SQL performance.

Methods

The authors propose a novel synthesis framework that operates in two stages: SQL synthesis and NLQ synthesis.

SQL Synthesis: * Template-based approach: They build upon existing template-based methods but introduce key improvements. * Strong Typing: Templates are enriched with data type information (e.g., text, number, date) and key identity (primary key vs. foreign key) to ensure more logical SQL generation. * Template Key Relationship Preservation: This crucial addition enforces constraints between foreign keys and primary keys, preventing the generation of invalid SQL queries, especially in multi-table join scenarios. * Schema-distance-weighted Column Sampling: To combat arbitrary and overly complex multi-table joins, they employ a weighted sampling strategy. This strategy biases column selection towards tables that are closer in terms of join distance within the database schema, leading to more realistic and less complex queries.

NLQ Synthesis: * Intermediate Representation (IR): They adopt an intermediate representation (IR) for the SQL-to-text task. This IR aims to simplify the SQL query by removing redundant information (e.g., unnecessary tables, GROUP BY clauses) and specifying intents more clearly, thereby bridging the gap between SQL and natural language questions more effectively.

Datasets

  • Spider: This is the primary dataset used for evaluation. It's a large-scale, cross-domain text-to-SQL dataset known for its challenging and realistic evaluation setting.
  • Previous Synthetic Datasets: The paper evaluates their approach against synthetic datasets generated by Wang et al. (2021) and Wu et al. (2021).
  • New Synthetic Data: The authors generate their own high-quality synthetic data using their proposed framework, referred to as IR2NLQ and SQL2NLQ.

Key Insights and Ideas

  • Synthetic Data Quality Matters: The paper strongly emphasizes that simply generating more synthetic data isn't enough; the quality of the synthetic data is paramount for improving text-to-SQL models. Poorly synthesized data can be detrimental.
  • Illogical Joins and Type Mismatches are Major Issues: The manual inspection of existing synthetic datasets revealed that illogical SQL queries stemming from independent column sampling and arbitrary table joins are significant sources of noise.
  • Schema Relationships are Key: Incorporating knowledge of foreign key and primary key relationships is critical for generating valid and realistic SQL queries, especially for complex multi-table operations.
  • Intermediate Representation for SQL-to-Text: Using an IR for the SQL-to-text generation stage significantly improves the quality of the generated natural language questions, making them more aligned with the underlying SQL.
  • Data Augmentation Benefits: Pre-finetuning powerful text-to-SQL models on their high-quality synthetic data leads to substantial accuracy improvements, demonstrating the effectiveness of their approach as a data augmentation strategy.

Key Results

  • Significant Accuracy Boosts: When state-of-the-art parsers (like T5-3B and PICARD) are pre-finetuned on their synthesized data, they achieve significant accuracy improvements on the Spider benchmark.
  • New State-of-the-Art Performance: The paper reports achieving new state-of-the-art performance on the Spider benchmark with their T5-3B + PICARD model trained with their synthetic data.
  • Improved EM and EX Scores: For instance, their approach leads to a 4.4-point EM improvement on top of the T5-3B model, and T5-3B + PICARD with their synthetic data achieves 76.1% EM and 81.4% EX on the Spider dev set.
  • Reduced Complexity in Synthetic SQL: Their schema-distance-weighted column sampling effectively reduces the number of tables in synthetic SQL queries, making them more comparable to real-world queries.
  • Few-Shot Learning Effectiveness: The synthetic data proves particularly valuable in few-shot learning scenarios, where it significantly boosts performance even with very limited real training data.

Limitations and Future Work

  • Computational Cost: While not explicitly detailed as a limitation, the framework involves multiple stages and complex sampling, suggesting potential computational costs.
  • Generalization to Other Tasks: The paper mentions that their success with T5-3B on knowledge grounding tasks suggests potential generalization, but this is an area for further exploration.
  • Single-Table Performance: While their method is compatible with single-table scenarios, the foreign key preservation is ineffective, leading to less significant gains compared to multi-table scenarios. Future work could explore optimizations for single-table parsing.
  • Targeting Database Schemas: A pilot study suggests that synthesizing data with targeting database schemas can further improve downstream performance, indicating a promising direction for future research.

Summary updated

BibTeX
@misc{zhao2022importance,
  author = {Yiyun Zhao and Jiarong Jiang and Yiqun Hu 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 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}},
  year = {2022},
  eprint = {2212.08785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.08785},
}
Figure