DialSQL: Dialogue Based Structured Query Generation

Izzeddin Gur, Semih Yavuz, Yu Su, Xifeng YanACL 2018

Abstract

Natural Language Interfaces to Databases (NLIDB) aim to democratize data access by allowing users to query databases using natural language. However, state-of-the-art semantic parsers often fail due to a lack of domain context or common sense. We present DialSQL, a dialogue-based framework that improves Natural Language to SQL (NL2SQL) performance by interacting with users. DialSQL identifies potential errors in generated queries and presents simple multiple-choice questions to the user. By leveraging human-in-the-loop feedback, DialSQL improves the accuracy of base models like SQLNet and Seq2SQL on the WikiSQL benchmark, demonstrating that minimal human intervention can significantly bridge the gap in semantic parsing.

Introduction

The "holy grail" of data science is a system that allows non-technical users to query complex databases without knowledge of SQL. While deep learning has advanced semantic parsing, models often hit a performance ceiling. Existing human-in-the-loop systems frequently assume the user is a "power user" capable of manually correcting SQL code. DialSQL addresses this by providing a system that communicates in plain language, allowing non-experts to guide the AI toward the correct query through simple choices.

The DialSQL Framework

DialSQL utilizes a hierarchical encoder-decoder architecture to manage the dialogue process. The framework operates in a three-step pipeline to refine an initial, potentially incorrect, SQL query.

The DialSQL hierarchical encoder-decoder architecture for dialogue-based query refinement.
  1. Predicting Error Category: The model first classifies the likely type of error in the generated SQL, such as an incorrect SELECT clause, a mismatch in aggregation operators (e.g., SUM vs COUNT), or issues within the WHERE clause.
  2. Decoding Error Span: Using a pointer mechanism, the system identifies the specific segment of the SQL query that requires correction.
  3. Decoding Candidate Choices: The model generates a list of alternative options (e.g., different column names or operators) and presents them to the user as a multiple-choice question.

To overcome the lack of large-scale human-correction datasets, the authors developed a Dialogue Simulator. This simulator "breaks" ground-truth queries in controlled ways to generate synthetic training data, allowing the model to learn how to facilitate corrective conversations.

Experimental Evaluation

The framework was evaluated using the WikiSQL benchmark, which contains over 80,000 natural language questions. DialSQL was tested as a wrapper around two base models: SQLNet and Seq2SQL.

Query-match accuracy improvement as the number of candidate choices presented to the user increases.

The results indicate a significant performance boost. When paired with SQLNet, DialSQL improved query-match accuracy from 61.3% to 69.0% on the WikiSQL test set. For Seq2SQL, the improvement was even more pronounced, rising from 51.6% to 61.0%. On average, the system required only 2.4 questions per session to resolve ambiguities. Human evaluations confirmed these findings, showing that users generally found the correct answer within the top suggested choices, achieving a Mean Reciprocal Rank (MRR) of 0.69.

Conclusion

DialSQL demonstrates that a simple, goal-oriented dialogue can effectively resolve the semantic limitations of current NL2SQL models. By transforming model uncertainty into user-friendly choices, the system enables non-experts to produce accurate SQL queries. Future work will focus on improving candidate choice generation to handle cases where the correct answer is missing from the initial list and scaling the framework to handle more complex SQL structures like joins and subqueries.

Summary updated

BibTeX
@inproceedings{gur2018dialsql,
  author = {Izzeddin Gur and Semih Yavuz and Yu Su and Xifeng Yan},
  title = {{DialSQL: Dialogue Based Structured Query Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2018},
  url = {https://openreview.net/forum?id=rkbRL3xuWH},
}
Figure