Zero-Shot Text-to-SQL Learning with Auxiliary Task

Shuaichen Chang, Pengfei Liu, Yun Tang, Jing Huang, Xiaodong He, Bowen Zhou

Introduction

Neural Text-to-SQL models have demonstrated impressive performance on standard benchmarks. However, their ability to generalize to unseen database schemas—a "zero-shot" scenario—remains a significant challenge. This paper, presented at AAAI 2020, introduces a multi-task learning framework designed to bridge this generalization gap by explicitly teaching models to map natural language entities to table columns.

The Generalization Gap in Text-to-SQL

The primary goal of Text-to-SQL is to translate natural language queries into executable SQL code (e.g., converting "Which city hosted the 2012 Olympics?" into SELECT city FROM games WHERE year = 2012). While existing models perform well when the test database schemas overlap with training data, their performance often plummets when encountering entirely new schemas.

The authors identified that in the popular WikiSQL dataset, approximately 70% of test cases utilize schemas already present in the training set. This "schema leakage" masks the models' inability to handle truly novel data. Diagnostic testing revealed that the WHERE clause is particularly sensitive to unseen data; if a model has not encountered a specific column name, it struggles to correctly associate question entities with that column.

Accuracy across test sets with varying schema overlap (W-6 to W-0).

As shown in the figure above, accuracy for the WHERE clause (blue line) drops significantly as the overlap between training and test schemas decreases, reaching its lowest point at W-0 (zero-shot).

Methodology: Multi-Task Learning with Auxiliary Mapping

To address this, the researchers propose a framework that combines a standard generation model with a novel auxiliary mapping task.

1. The Generation Model

The core architecture is a "coarse-to-fine" encoder-decoder. Key enhancements include:

  • Bi-attention Layer: Enables the question and table schema to mutually attend to each other during encoding.
  • Attentive Pooling Layer: Captures specific question segments relevant to SQL operations.

2. The Auxiliary Mapping Task

This task forces the model to explicitly learn the relationship between natural language words and table columns through two steps:

  • Condition Value Detection: Employs BIO (Beginning, Inside, Outside) tagging to identify "values" within the question (e.g., "Peter Berwick").
  • Value-Column Mapping: Predicts the specific table column to which an identified value belongs (e.g., mapping "Peter Berwick" to the "Rider" column).
Model architecture (a) and auxiliary mapping task example (b).

By training on both tasks simultaneously, the auxiliary task acts as a regularizer, ensuring the shared encoder learns robust representations that prioritize the structural relationship between language and data.

Key Results and Evaluation

The model was evaluated on a custom "Zero-Shot Testbed" derived from WikiSQL, specifically isolating the W-0 subset where schemas were completely absent from training.

  • Zero-Shot Performance: The "Full-model" achieved a 5% absolute gain in accuracy over the baseline on the W-0 subset.
  • Overall Accuracy: Improved by over 3% absolute on the full WikiSQL dataset.
  • Execution Accuracy: Reached a competitive 81.7%.

Qualitative analysis confirmed that the auxiliary task effectively reduced errors where the model previously selected incorrect columns for conditions, demonstrating improved resilience to unseen schemas.

Conclusion

This work highlights the importance of explicit schema mapping in Text-to-SQL tasks. By moving from implicit learning to an explicit auxiliary mapping task, the proposed model significantly improves generalization in zero-shot scenarios. Future research will focus on extending this approach to more complex datasets like Spider, which involve multi-table joins and more intricate reasoning.

Summary updated

BibTeX
@inproceedings{chang2020zero,
  author = {Shuaichen Chang and Pengfei Liu and Yun Tang and Jing Huang and Xiaodong He and Bowen Zhou},
  title = {{Zero-Shot Text-to-SQL Learning with Auxiliary Task}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.1609/aaai.v34i05.6246},
}
Figure