A Transfer-Learnable Natural Language Interface for Databases

Wenlu Wang, Yingtao Tian, Hongyu Xiong, Haixun Wang, Wei-Shinn KuarXiv 2018

Relational Database Management Systems (RDBMS) serve as the foundation for modern data storage, yet accessing this data typically requires proficiency in SQL—a significant barrier for non-technical users. While Natural Language Interfaces for Databases (NLIDBs) aim to bridge this gap, they are traditionally "brittle," often overfitting to specific database schemas and failing to generalize across different domains. This paper introduces a novel framework designed for high transferability, enabling a single model to understand the latent semantic structure of natural language queries regardless of the underlying data schema.

The Proposed Framework

The core of the proposed system is a three-stage pipeline that decouples specific database identifiers from the logical structure of the query. This decoupling allows the model to learn the universal "grammar" of how users ask questions about data, rather than memorizing specific column names or values.

Examples of the automatic annotation process across different database domains.

As illustrated above, the framework operates through the following stages:

  1. Automatic Annotation: The raw natural language question ($q$) is transformed into an annotated form ($q_a$). Specific entities are replaced with placeholders: $c_i$ for columns and $v_i$ for values. For instance, a query about a film director is abstracted into a structure identical to a query about a geographic location.
  2. Sequence-to-Sequence (Seq2Seq) Translation: A neural encoder-decoder model translates the annotated question into an Annotated SQL statement ($s_a$).
  3. Deterministic Conversion: The annotated SQL (e.g., SELECT c1 WHERE c2 = v2) is mapped back to the actual database schema to produce a valid, executable SQL query.

Neural Architecture and Methods

The translation stage utilizes a sophisticated neural architecture to handle the mapping between natural language and SQL logic. The model employs Bi-directional Gated Recurrent Units (Bi-GRUs) and an attention mechanism to capture the dependencies between the annotated question and the target SQL structure.

The three-stage neural architecture for translating annotated questions to SQL.

Key Innovations

  • Mention Resolution: To link natural language tokens to database columns, the system uses a combination of edit distance, word embeddings, and a "Lowest Common Ancestor" (LCA) approach on the question's syntax tree. This ensures that values like "Mayo" are correctly paired with columns like "County."
  • Column Stacking: Rather than simple symbol substitution, the authors use "Column Stacking" (e.g., $c_2$ [directed by]). By appending the symbol to the original text, the model retains the rich semantic meaning of the user's phrasing while benefiting from the abstraction of the placeholder.
  • Table Header Encoding: To assist the model in inferring columns not explicitly named in the query, the entire list of table headers is appended to the input question, providing necessary schema context to the neural network.

Experimental Results

The model was evaluated on the WikiSQL dataset, a massive benchmark containing over 80,000 question-SQL pairs. It achieved an execution accuracy of 82.2%, significantly outperforming contemporary state-of-the-art models such as SQLNet (68.0%) and TypeSQL (73.5%).

Crucially, the authors tested the model's zero-shot transferability using the OVERNIGHT dataset. Without any additional training on these new domains (e.g., Basketball, Calendar), the model achieved an average accuracy of 66.88%. This result confirms that the model successfully learns generalizable patterns of natural language interaction rather than domain-specific vocabulary.

Conclusion and Future Work

By abstracting database schemas through automatic annotation and column stacking, this research demonstrates that a transfer-learnable NLIDB is not only possible but highly effective. While the system's performance is currently dependent on the accuracy of the initial mention detection stage, it provides a robust foundation for future interfaces. Subsequent iterations may leverage advanced pre-trained language models like BERT to further refine mention resolution and handle more complex SQL operations, such as multi-table joins and nested subqueries.

Summary updated

BibTeX
@misc{wang2018transfer,
  author = {Wenlu Wang and Yingtao Tian and Hongyu Xiong and Haixun Wang and Wei-Shinn Ku},
  title = {{A Transfer-Learnable Natural Language Interface for Databases}},
  year = {2018},
  eprint = {1809.02649},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1809.02649},
}
Figure