Papers › Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning

Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning

31 Aug 2017ICLR 2018 1arXiv:1709.00103archive 2025-07-28

Victor Zhong, Caiming Xiong, Richard Socher

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%.

PaperPDFConference PDFCode

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

Code

15 repositories listed; official and paper-mentioned ones first.

salesforce/WikiSQL officialmentioned in papermentioned on GitHubBSD-3-Clause report
Baidi96/text2sql mentioned on GitHubpytorchBSD-3-Clause report
CX000/sqlnet_inference_py36 mentioned on GitHubpytorchBSD-3-Clause report
PriyankaDatar/NLP_Project_Modfications mentioned on GitHubpytorchBSD-3-Clause report
PriyankaDatar/NLP_SQL_Project mentioned on GitHubpytorchBSD-3-Clause report
abhishekchugh17/sql12 mentioned on GitHubpytorchBSD-3-Clause report
ist-daslab/rosa mentioned on GitHubpytorchApache-2.0 report
kasnerz/tabgenie mentioned on GitHubMIT report
kh-mo/QA_wikisql mentioned on GitHub report
llSourcell/SQL_Database_Optimization mentioned on GitHubpytorchBSD-3-Clause report
openbotai/nl2sql mentioned on GitHubnot reachable when probed 2026-09-17 — repositories for recent papers often appear after camera-ready report
racheljose21/chatbot mentioned on GitHubpytorchBSD-3-Clause report
tiwarikajal/Seq2SQL- mentioned on GitHubpytorch report
wronnyhuang/SQLNet_inference mentioned on GitHubpytorchBSD-3-Clause report
xiaojunxu/SQLNet mentioned on GitHubpytorchBSD-3-Clause report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

Not run by Syntology. Nothing on this page verifies that the listed code works.

Tasks

Reinforcement LearningReinforcement Learning (RL)Text-To-SQLreinforcement-learning

Datasets

Introduced by this paper, per the archive.

WikiSQL

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Code Generation WikiSQL Seq2SQL (Zhong et al., 2017) Exact Match Accuracy 48.3 #9 of 10 Archive leaderboard report
Code Generation WikiSQL Seq2SQL (Zhong et al., 2017) Execution Accuracy 59.4 #9 of 10 Archive leaderboard report
Code Generation WikiSQL Seq2Seq (Zhong et al., 2017) Exact Match Accuracy 23.4 #10 of 10 Archive leaderboard report
Code Generation WikiSQL Seq2Seq (Zhong et al., 2017) Execution Accuracy 35.9 #10 of 10 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections