Skip to main content
QUICK REVIEW

[Paper Review] One-Shot Learning for Text-to-SQL Generation

Dongjun Lee, Jaesik Yoon|arXiv (Cornell University)|Apr 26, 2019
Topic ModelingComputer Science31 references12 citations
TL;DR

This paper proposes a one-shot learning approach for text-to-SQL generation that enables zero-shot adaptation to unseen SQL templates using a single example. It combines a Candidate Search Network to retrieve top-n relevant templates and a Matching Network for classification, followed by a Pointer Network for slot filling, achieving 52% relative performance gain on unseen templates without retraining.

ABSTRACT

Most deep learning approaches for text-to-SQL generation are limited to the WikiSQL dataset, which only supports very simple queries. Recently, template-based and sequence-to-sequence approaches were proposed to support complex queries, which contain join queries, nested queries, and other types. However, Finegan-Dollak et al. (2018) demonstrated that both the approaches lack the ability to generate SQL of unseen templates. In this paper, we propose a template-based one-shot learning model for the text-to-SQL generation so that the model can generate SQL of an untrained template based on a single example. First, we classify the SQL template using the Matching Network that is augmented by our novel architecture Candidate Search Network. Then, we fill the variable slots in the predicted template using the Pointer Network. We show that our model outperforms state-of-the-art approaches for various text-to-SQL datasets in two aspects: 1) the SQL generation accuracy for the trained templates, and 2) the adaptability to the unseen SQL templates based on a single example without any additional training.

Motivation & Objective

  • To address the limitation of existing text-to-SQL models in generalizing to unseen SQL templates.
  • To enable effective zero-shot adaptation to new SQL query structures using only one example.
  • To reduce the search space and ensure syntax correctness in generated SQL.
  • To improve generalization beyond WikiSQL-style simple queries to complex queries with joins, grouping, and nesting.
  • To develop a scalable, trainable model that supports new code generation templates without retraining.

Proposed method

  • A Candidate Search Network (CSN) is introduced to select the top-n most relevant SQL templates from a large candidate set, enabling efficient support set construction for few-shot learning.
  • The Matching Network is applied on the CSN-selected support set to classify the input question into the most appropriate SQL template.
  • A Pointer Network is used to fill variable slots in the predicted template by selecting tokens from the input question, ensuring syntactic correctness.
  • The model operates in two stages: (1) template classification using CSN + Matching Network, and (2) slot filling via Pointer Network.
  • The architecture is designed to be extensible to other code generation tasks by defining templates and variable slots.
  • The model is evaluated under both question-based and query-based splits to assess performance on seen and unseen templates.

Experimental results

Research questions

  • RQ1Can a text-to-SQL model generalize to unseen SQL templates using only a single example, without retraining?
  • RQ2How effective is the proposed Candidate Search Network in reducing the search space for template classification in large-scale template sets?
  • RQ3Does combining CSN with Matching Network outperform baseline few-shot learning methods on unseen SQL templates?
  • RQ4How does the model’s performance on template classification compare to slot filling in terms of accuracy degradation across seen and unseen templates?
  • RQ5To what extent does the model maintain syntax correctness and avoid erroneous SQL generation in complex queries?

Key findings

  • The proposed model outperforms state-of-the-art approaches by 3–9% on the question-based split, which evaluates generalization to trained templates.
  • In the query-based split, the model achieves a 52% relative performance gain on unseen templates in the one-shot setting without any additional training.
  • The ablation study shows that combining CSN with Matching Network yields a 19.0%–42.0% improvement over using Matching Network alone, demonstrating the critical role of CSN in scalability.
  • The Candidate Search Network achieves 94–100% accuracy in identifying the top-15 relevant templates in the question-based split, though performance drops by 6–19% in the query-based split.
  • Template classification is significantly more challenging than slot filling, with performance dropping by 9–35% from question-based to query-based split, indicating a key bottleneck in zero-shot generalization.
  • The Pointer Network achieves high slot-filling accuracy (91–98%) across all datasets, with minimal degradation (2–12%) from seen to unseen templates, showing robustness in variable slot prediction.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.