Towards Generalizable and Robust Text-to-SQL Parsing

Chang Gao, Bowen Li, Wenxuan Zhang, Wai Lam, Binhua Li, Fei Huang, Luo Si, Yongbin Li

Abstract

Text-to-SQL parsing is a critical task for enabling natural language interfaces to databases. However, current models struggle with generalization to unseen schemas and robustness against linguistic variations. We present TKK, a three-stage framework that decomposes the parsing task into clause-level subtasks, acquires specialized knowledge through multi-task learning, and composes this knowledge for final query generation. TKK achieves state-of-the-art performance on benchmarks like Spider and CoSQL while demonstrating significantly improved robustness and data efficiency.

Introduction

Translating natural language questions into executable SQL queries—Text-to-SQL parsing—is essential for democratizing data access. Despite recent progress, two significant hurdles remain:

  1. Generalization Gaps: Models often fail when encountering zero-shot database schemas or novel compositional structures.
  2. Fragility: High-performing models are frequently sensitive to minor input perturbations, such as the use of synonyms for column names.

The authors posit that standard end-to-end training encourages models to rely on spurious correlations rather than deep logical understanding. To address this, they propose the TKK framework, a "divide-and-conquer" approach inspired by human learning patterns.

The TKK Framework

The TKK framework (Task decomposition, Knowledge acquisition, and Knowledge composition) structures the learning process into three distinct phases to improve the model's grasp of SQL logic.

Overview of the TKK framework, illustrating the three stages: Task Decomposition, Knowledge Acquisition, and Knowledge Composition.

1. Task Decomposition

Rather than generating a complex query in a single pass, the task is partitioned into five clause-based subtasks: SELECT, FROM, WHERE, GHOL (Group By, Having, Order By, Limit), and SQL (set operators like Intersect or Union).

2. Knowledge Acquisition

Using a T5 backbone, the model is trained via multi-task learning. Specific prompts guide the model to generate individual clauses for a given question and schema. This phase forces the model to learn precise alignments between natural language intent and specific SQL structures.

3. Knowledge Composition

In the final stage, the model is fine-tuned on the main task of generating the full query. This allows the model to integrate the specialized knowledge acquired in the previous stage, learning the interdependencies between different SQL clauses.

Experimental Setup

TKK was evaluated on a diverse set of benchmarks to test various facets of performance:

  • Cross-Domain/Zero-Shot: Spider, SParC, and CoSQL.
  • Compositional Generalization: Specialized Spider splits (Template, Length, and TMCD).
  • Robustness: Spider-Syn (synonym substitution) and Spider-Realistic.
  • I.I.D. Generalization: Standard splits of major datasets.

Key Insights

  • Curriculum-Style Learning: By breaking down complex queries, TKK helps neural networks avoid memorizing dataset-specific patterns, mimicking how humans learn to write SQL incrementally.
  • The Importance of the FROM Clause: Ablation studies identified the FROM subtask as the most impactful. Mapping natural language to specific database tables remains the most challenging alignment problem in Text-to-SQL.
  • Structural Robustness: While larger models (e.g., T5-3B) are inherently more robust, TKK provides a consistent performance boost across all model scales, indicating that the learning methodology is as critical as model capacity.

Results and Analysis

TKK established new state-of-the-art benchmarks across multiple categories. On the Spider leaderboard, TKK-3B combined with PICARD reached 75.6% Exact Match (EM) and 80.3% Execution Accuracy (EX).

Robustness and Compositionality

On Spider-Syn, TKK-3B achieved 63.0% EM, significantly outperforming the vanilla T5-3B (59.4%). It also showed superior performance on the Spider-TMCD split (71.8% EM), demonstrating enhanced compositional generalization.

Data Efficiency

TKK exhibits remarkable efficiency in low-resource settings. Even with only a small fraction of the training data, the framework allows models to outperform standard baselines.

Performance of TKK across varying training data sizes on Spider (EM) and CoSQL (QM) benchmarks.

Conclusion and Future Work

The TKK framework demonstrates that structured task decomposition significantly enhances the generalization and robustness of Text-to-SQL models. A current limitation is the manual nature of the task decomposition. Future research aims to automate this process, potentially extending the TKK philosophy to other complex semantic parsing tasks like Abstract Meaning Representation (AMR).

Summary updated

BibTeX
@inproceedings{gao2022towards,
  author = {Chang Gao and Bowen Li and Wenxuan Zhang and Wai Lam and Binhua Li and Fei Huang and Luo Si and Yongbin Li},
  title = {{Towards Generalizable and Robust Text-to-SQL Parsing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  url = {https://openreview.net/forum?id=gPbpO6jqqkf},
}
Figure