Publication | Open Access
Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning
784
Citations
31
References
2017
Year
Artificial IntelligenceGenerated QueriesEngineeringSemantic WebStructured QueriesLarge Language ModelText MiningNatural Language ProcessingInformation RetrievalData ScienceComputational LinguisticsLanguage ModelsMachine TranslationQuestion AnsweringNatural Language InterfaceSql QueriesComputer ScienceSemantic ParsingDeep Neural NetworkRetrieval Augmented GenerationAutomated ReasoningLanguage Generation
A significant amount of the world's knowledge is stored in relational databases, yet users struggle to retrieve facts because of limited understanding of query languages such as SQL. The study proposes Seq2SQL, a deep neural network that translates natural language questions into SQL queries. The model reduces the output space by exploiting SQL structure, learns a policy via rewards from in‑the‑loop query execution, and is trained on the WikiSQL dataset, which is an order of magnitude larger than comparable datasets. Seq2SQL outperforms attentional sequence‑to‑sequence models, raising execution accuracy from 35.9 % to 59.4 % and logical‑form accuracy from 23.4 % to 48.3 %.
A significant amount of the world's knowledge is stored in relational databases. However, the ability for users to retrieve facts from a database is limited due to a lack of understanding of query languages such as SQL. We propose Seq2SQL, a deep neural network for translating natural language questions to corresponding SQL queries. Our model leverages the structure of SQL queries to significantly reduce the output space of generated queries. Moreover, we use rewards from in-the-loop query execution over the database to learn a policy to generate unordered parts of the query, which we show are less suitable for optimization via cross entropy loss. In addition, we will publish WikiSQL, a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia. This dataset is required to train our model and is an order of magnitude larger than comparable datasets. By applying policy-based reinforcement learning with a query execution environment to WikiSQL, our model Seq2SQL outperforms attentional sequence to sequence models, improving execution accuracy from 35.9% to 59.4% and logical form accuracy from 23.4% to 48.3%.
| Year | Citations | |
|---|---|---|
Page 1
Page 1