Abstract: Converting natural language questions into executable SQL queries remains a significant challenge in making data accessible to non-technical users. Current approaches often struggle with compositional generalization, ambiguous entity linking, and brittle, manually-defined grammars. This paper presents a modular framework developed by researchers at Amazon AWS AI Labs that addresses these issues through "fine-grained query understanding." By decoupling the tasks of entity identification, database linking, and SQL generation, the proposed model achieves a new state-of-the-art execution accuracy of 56.8% on the WikiTableQuestions (WTQ) benchmark.
Introduction
The goal of Text-to-SQL parsing is to bridge the gap between human language and structured data. While progress has been made, existing systems often fail when faced with complex, multi-part queries or when user phrasing deviates from the canonical names stored in a database. This research introduces a pipeline that treats query understanding as a first-class citizen, using specialized neural modules to provide the parser with explicit semantic hints.
Challenges in Text-to-SQL Parsing
The researchers identify three primary hurdles in the current landscape:
- Compositional Generalization: Models frequently fail on complex, "compound" queries (e.g., "Where is the cyclist who has the most points?") even if they understand the individual components.
- The Entity Linking Problem: Users rarely use exact database keys. Mapping a colloquialism like "LBJ" to the canonical "LeBron James" requires sophisticated linking beyond simple string matching.
- Brittle Grammars: Many parsers rely on rigid, manually designed grammars that lack the flexibility to generalize across diverse database schemas.
Methodology: A Modular Pipeline
The core of the proposed framework is a three-stage neural pipeline designed to separate "understanding" from "synthesis."
Named Entity Recognizer (NER)
Unlike traditional NER, which identifies generic categories like people or places, this module is SQL-aware. It uses a BERT-based model to identify specific spans in the query and tags them with labels such as WHERE_COLUMN or GROUPBY_COLUMN. This provides the subsequent parser with a strong prior regarding the role each word plays in the final SQL structure.
Neural Entity Linker (NEL)
To bridge the gap between user phrasing and database content, the NEL uses a neural ranking model. It evaluates candidates from the database based on the context of the question, effectively mapping informal mentions to their canonical counterparts.
Neural Semantic Parser (NSP)
The final stage is a BART-based encoder-decoder that acts as the system's reasoning engine. Rather than relying on manual rules, this parser dynamically generates a context-free grammar from the training data. A "soft copy" mechanism allows it to pull tables, columns, and linked values directly into a structured Abstract Syntax Tree (AST), ensuring syntactic correctness.
Experimental Setup
The model was evaluated using two primary datasets:
- SQUALL: Used to provide manual alignments between natural language questions and SQL logical forms for training the NER and NEL modules.
- WikiTableQuestions (WTQ): A complex benchmark for question answering over semi-structured HTML tables, used to measure final execution accuracy.
Results and Analysis
The framework demonstrated significant improvements over existing baselines, particularly in its ability to handle complex logic.
As shown in the results table, the framework achieved 56.8% execution accuracy on the WTQ test set, outperforming the previous state-of-the-art model (ALIGN) by 2.7%.
Ablation studies further highlighted the importance of fine-grained features. For instance, adding "column type features" (indicating whether a column contains strings or integers) boosted logical form accuracy by nearly 7%. Furthermore, on a subset of "nested queries"—the most difficult types of questions—the model outperformed the baseline by 4.5%, suggesting that fine-grained understanding is crucial for compositional generalization.
Conclusion
By decoupling query understanding from SQL synthesis, this framework provides a more explainable and accurate approach to Text-to-SQL parsing. The use of SQL-aware NER and neural entity linking allows the system to handle the nuances of human language more effectively than previous rule-based or end-to-end models. Future work will focus on reducing the reliance on expensive fine-grained annotations and exploring further constraints to optimize the parser's search space.
Summary updated