Abstract
Translating natural language questions into executable SQL queries is a fundamental challenge in semantic parsing. This paper introduces STAMP (Syntax- and Table-Aware seMantic Parser), a generative model that leverages the structural constraints of SQL and the content of the underlying database. By employing a multi-channel architecture that switches between SQL keywords, column names, and table cells, STAMP addresses the "semantic gap" between user queries and database schemas. On the WikiSQL benchmark, STAMP achieves a state-of-the-art execution accuracy of 74.4%, significantly outperforming previous sequence-to-sequence approaches.
Introduction
The task of mapping natural language to SQL is complicated by the discrepancy between how users describe data and how that data is structured in a database. For instance, a user might ask about "schools" while the corresponding database column is labeled "College." Traditional sequence-to-sequence models often fail to bridge this semantic gap, frequently producing syntactically invalid SQL or hallucinating column names. This paper proposes STAMP, which treats SQL generation as a structured process informed by both the syntax of the language and the specific content of the target table.
Methodology
The core of STAMP is a multi-channel neural parser built upon Pointer Networks. Unlike standard decoders that predict from a single vocabulary, STAMP utilizes a switching gate to select from three specialized channels at each generation step.
The Three-Channel Architecture
- SQL Channel: Predicts SQL keywords and operators (e.g.,
SELECT,WHERE,COUNT,=). - Column Channel: Selects from the available column names in the table schema.
- Value Channel: Extracts specific cell values from the table content.
Table-Aware Features
A key innovation in STAMP is the Column-Cell Relation. To resolve ambiguous column references, the model inspects the values within columns. If a question contains a term found in a specific table cell, the model uses this link to prioritize the corresponding column. Additionally, a Global Memory mechanism ensures executability by restricting the Value Channel to cells belonging to the previously predicted column.
Experimental Evaluation
The model was primarily evaluated on the WikiSQL dataset, which contains over 80,000 question-SQL pairs across 24,000 tables. Performance was measured using Logical Form Accuracy ($Acc_{lf}$) and Execution Accuracy ($Acc_{ex}$).
Results
STAMP achieved a new state-of-the-art on WikiSQL, reaching an execution accuracy of 74.4%. This represents a substantial improvement over previous models like SQLNet (68.0%) and the approach by Guo and Gao (69.0%).
Ablation studies revealed that the column-cell relation is critical; removing it resulted in a 4% drop in accuracy. Furthermore, the use of Reinforcement Learning (STAMP+RL) provided a marginal but consistent boost in performance by optimizing for the correct execution result rather than just string matching.
Discussion and Conclusion
STAMP demonstrates that incorporating database content and SQL syntax as structural priors significantly enhances the performance of semantic parsers. By "linking" natural language tokens to table cells, the model effectively navigates the semantic gap. While STAMP excels at the relatively simple queries found in WikiSQL, future work is needed to extend this approach to complex multi-table joins and nested subqueries, as well as improving cross-domain generalization.
Summary updated