Mention Extraction and Linking for SQL Query Generation

Jianqiang Ma, Zeyu Yan, Shuai Pang, Yang Zhang, Jianping ShenEMNLP 2020

Introduction

Traditional text-to-SQL systems often rely on complex, multi-module "sketches." These architectures use independent components to predict different parts of a SQL query, such as the SELECT column, WHERE clause values, and operators. However, this modularity introduces significant architectural complexity and fails to capture the inter-dependencies between different query components. For instance, a value in a natural language question is typically located near the column name it references—a linguistic proximity that modular systems often overlook.

The Extraction-Linking Framework

To address these limitations, this work proposes a unified two-stage Extraction-Linking framework that treats text-to-SQL as a sequence labeling task. By extracting "mentions" of SQL components directly from the natural language question and linking them to the database schema, the system achieves high accuracy with a simpler architecture.

1. Mention Extraction

The system utilizes a BERT-based model paired with a Conditional Random Field (CRF) layer to perform sequence labeling on the input question. It identifies mentions of SQL components by assigning two types of labels:

  • Role Labels: Categorize tokens as columns (C), values (V), operators (OP), or aggregation functions (AGG).
  • Span Labels: Group these roles into functional units, such as SELECT or FILTER spans.
Alignment and label generation for mention extraction.

2. Schema Linking

Because natural language often uses informal terms (e.g., "50m splits") instead of canonical database headers (e.g., SPLIT (50M)), a second BERT-based module is employed. This "Linker" matches extracted mentions to actual table headers using a text-matching score. This approach even handles implicit mentions; if a value is found, the linker scans the schema to identify the most likely corresponding column.

3. Training and Enhancement

To train the model, the authors developed an automated alignment tool to generate "silver" training labels from existing Question-SQL pairs in the WikiSQL dataset. Additionally, they addressed performance bottlenecks in aggregation function prediction by applying Brill’s transformation-based learning, which uses simple rules to correct common neural model errors.

Key Results

The proposed method achieved state-of-the-art results on the WikiSQL benchmark, the largest human-annotated dataset of its kind, consisting of over 80,000 pairs across thousands of tables.

Performance comparison on the WikiSQL benchmark.

As shown in the results table, the model reached a Logical Form (LF) accuracy of 87.8% and an Execution (EX) accuracy of 92.5% when using Execution Guidance (EG). It outperformed established models like SQLova, X-SQL, and HydraNet, demonstrating that a simpler, more unified architecture can be more effective than heavy, modular systems.

Discussion and Future Work

The success of this approach highlights that SQL structure is often mirrored in the linear order of natural language. By treating semantic parsing as a tagging task, the model naturally captures dependencies between query components. Furthermore, the effectiveness of the automatic annotation suggests that expensive, manual token-level labeling may not be necessary for high-performance extraction.

However, limitations remain. The sequence labeling approach is currently optimized for "flat" queries and may struggle with nested structures. Future work will focus on extending this framework to multi-table datasets like Spider, which require complex joins and more sophisticated schema linking.

Summary updated

BibTeX
@inproceedings{ma2020mention,
  author = {Jianqiang Ma and Zeyu Yan and Shuai Pang and Yang Zhang and Jianping Shen},
  title = {{Mention Extraction and Linking for SQL Query Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.563},
}
Figure