---
title: "Seq2SQL — paper by Zhong et al. (2017) — summary and ideas"
description: "To this end, they propose the Seq2SQL model. 42 references, cited by 493 papers here. Among them: 733."
authors: ["Victor Zhong", "Caiming Xiong", "Richard Socher"]
year: 2017
venue: "arXiv:1709.00103"
source: "https://arxiv.org/abs/1709.00103"
doi: "10.48550/arxiv.1709.00103"
arxiv: "1709.00103"
licence: "arXiv — non-exclusive licence to distribute"
licence_url: "http://arxiv.org/licenses/nonexclusive-distrib/1.0/"
summary_licence: "Elamur Cosmic License"
canonical: "https://research.elamur.ai/free/en/papers/zhong-2017-seq2sql-generating-structured-queries-natural/"
---
[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/zhong-2017-seq2sql-generating-structured-queries-natural/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2017](https://md.research.elamur.ai/free/en/papers/2017/) / Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning

# Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning

**Authors:** [Victor Zhong](https://md.research.elamur.ai/free/en/authors/victor-zhong/), [Caiming Xiong](https://md.research.elamur.ai/free/en/authors/caiming-xiong/) and [Richard Socher](https://md.research.elamur.ai/free/en/authors/richard-socher/) · **Year:** 2017 · **Venue:** arXiv:1709.00103 · **Licence:** [arXiv — non-exclusive licence to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

**Links:** [Publisher's page](https://arxiv.org/abs/1709.00103) · [PDF](https://arxiv.org/pdf/1709.00103) · [DOI 10.48550/arxiv.1709.00103](https://doi.org/10.48550/arxiv.1709.00103) · [arXiv 1709.00103](https://arxiv.org/abs/1709.00103) · [OpenAlex](https://openalex.org/W2751448157)

**Citations:** 733 citations (OpenAlex, 2026-10-14) · [493](https://md.research.elamur.ai/free/en/papers/zhong-2017-seq2sql-generating-structured-queries-natural/cited-by/) in our library, of the 149,439 papers whose bibliographies we read

## Summary
The paper addresses natural language interfaces to relational databases. The authors aim to let a person ask a question in ordinary language and obtain the corresponding SQL query without knowing the query language. To this end, they propose the Seq2SQL model. It relies on the typical structure of SQL and splits generation into three steps: selecting the aggregation operation, selecting the column for SELECT, and constructing the WHERE conditions. The first two steps are trained with cross entropy. The model learns the WHERE conditions using policy gradient: the generated query is executed against the database, and its result serves as the reward. As a result, the model is not penalized if it writes equivalent conditions in a different order. The second contribution is the WikiSQL corpus. It contains questions about tables from Wikipedia, paraphrased by people via crowdsourcing, together with the corresponding queries. Along with the corpus, the authors release an engine for executing these queries. On WikiSQL, Seq2SQL clearly outperforms the best semantic parser available at the time. The work is significant because it provided a large benchmark dataset for the text-to-SQL task. It also showed that reinforcement learning combined with the structural constraints of SQL yields better results.

## Key points
- **WikiSQL** contains 80,654 "question + SQL query" examples based on 24,241 tables from Wikipedia. This is roughly an order of magnitude more than previous semantic parsing datasets with logical forms. The tables are released in JSON format and as an SQL database.
- **How the data were collected.** For each selected table, 6 queries were generated automatically. The aggregation could be empty or COUNT, and for numeric columns also MIN or MAX. The conditions allow the `=` operator, and for numbers also `>` and `<`. The template questions were paraphrased by Amazon Mechanical Turk workers. Each paraphrase was verified by two more people. Only paraphrases whose character-level edit distance from the template question exceeds 10 were kept.
- **Results.** Seq2SQL achieves an execution accuracy of 59.4% versus 35.9% for the Seq2Seq parser of Dong & Lapata (2016). Logical form accuracy rises from 23.4% to 48.3%. The augmented pointer network, as an intermediate baseline, reaches 53.3% execution accuracy.
- **Architecture.** The encoder is a two-layer bidirectional LSTM. Its input consists of the column names, the SQL vocabulary, and the question itself, separated by special tokens. The aggregation is determined by a classifier, and the SELECT column is chosen by a pointer mechanism. The WHERE conditions are generated by a pointer decoder trained jointly with RL on a mixed objective function.

*Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.*

📚 Shelves (5): [🖥️ Computer Science](https://md.research.elamur.ai/free/en/shelves/computer-science/) · 16,667 works · [🤖 Artificial Intelligence](https://md.research.elamur.ai/free/en/shelves/computer-science/artificial-intelligence/) · 16,194 works · [🎭 Arts and Humanities](https://md.research.elamur.ai/free/en/shelves/arts-and-humanities/) · 16,039 works · [🗣️ Language and Linguistics](https://md.research.elamur.ai/free/en/shelves/arts-and-humanities/language-and-linguistics/) · 15,891 works · [🌐 Computer Networks and Communications](https://md.research.elamur.ai/free/en/shelves/computer-science/computer-networks-and-communications/) · 64 works

💡 Concepts (1): [💡 Machine learning](https://md.research.elamur.ai/free/en/concepts/machine-learning/) · 51 works

## Cite

Cite as: Victor Zhong, Caiming Xiong and Richard Socher. 2017. Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning. arXiv:1709.00103.

The paper itself, not this page. BibTeX from the library's record of the work.

```bibtex
@misc{zhong2017seq2sql,
  title = {{Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning}},
  author = {Victor Zhong, Caiming Xiong and Richard Socher},
  year = {2017},
  doi = {10.48550/arxiv.1709.00103},
  eprint = {1709.00103},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1709.00103}
}
```

- [← previous Knowledge Graph Refinement: A Survey of Approaches and Evaluation Methods](https://md.research.elamur.ai/free/en/papers/paulheim-2017-knowledge-graph-refinement-survey-approaches/)
- [next → DailyDialog: A Manually Labelled Multi-turn Dialogue Dataset](https://md.research.elamur.ai/free/en/papers/li-2017-dailydialog-manually-labelled-multi-turn/)
- [↑ back to papers of 2017](https://md.research.elamur.ai/free/en/papers/2017/)

## References

42 references, 16 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

1. I. Androutsopoulos, G.D. Ritchie, and P. Thanisch. Natural language interfaces to databases - an introduction. 1995. [find](https://scholar.google.com/scholar?q=I%2E+Androutsopoulos%2C+G%2ED%2E+Ritchie%2C+and+P%2E+Thanisch%2E+Natural+language+interfaces+to+databases+%2D+an+introduction%2E+1995%2E)
2. Yoav Artzi and Luke S. Zettlemoyer. Bootstrapping semantic parsers from conversations. In EMNLP, 2011. [find](https://scholar.google.com/scholar?q=Yoav+Artzi+and+Luke+S%2E+Zettlemoyer%2E+Bootstrapping+semantic+parsers+from+conversations%2E+In+EMNLP%2C+2011%2E)
3. Yoav Artzi and Luke S. Zettlemoyer. [Weakly supervised learning of semantic parsers for mapping instructions to actions](https://md.research.elamur.ai/free/en/papers/artzi-2013-weakly-supervised-learning-semantic-parsers/). TACL, 1:49–62, 2013.
4. Thorsten Beck, Asli Demirgüç-Kunt, and Ross Levine. A new database on the structure and development of the financial sector. The World Bank Economic Review, 14(3):597–605, 2000. [find](https://scholar.google.com/scholar?q=Thorsten+Beck%2C+Asli+Demirgu%CC%88c%CC%A7%2DKunt%2C+and+Ross+Levine%2E+A+new+database+on+the+structure+and+development+of+the+financial+sector%2E+The+World+Bank+Economic+Review%2C+14%283%29%3A597%E2%80%93605%2C+2000%2E)
5. Irwan Bello, Hieu Pham, Quoc V. Le, Mohammad Norouzi, and Samy Bengio. Neural combinatorial optimization with reinforcement learning. ICLR, 2017. [find](https://scholar.google.com/scholar?q=Irwan+Bello%2C+Hieu+Pham%2C+Quoc+V%2E+Le%2C+Mohammad+Norouzi%2C+and+Samy+Bengio%2E+Neural+combinatorial+optimization+with+reinforcement+learning%2E+ICLR%2C+2017%2E)
6. Jonathan Berant, Andrew Chou, Roy Frostig, and Percy Liang. [Semantic parsing on freebase from question-answer pairs](https://md.research.elamur.ai/free/en/papers/berant-2013-semantic-parsing-freebase-question-answer/). In EMNLP, 2013.
7. Chandra Bhagavatula, Thanapon Noraset, and Doug Downey. Methods for exploring and mining tables on wikipedia. In IDEA@KDD, 2013. [find](https://scholar.google.com/scholar?q=Chandra+Bhagavatula%2C+Thanapon+Noraset%2C+and+Doug+Downey%2E+Methods+for+exploring+and+mining+tables+on+wikipedia%2E+In+IDEA%40KDD%2C+2013%2E)
8. Qingqing Cai and Alexander Yates. Large-scale semantic parsing via schema matching and lexicon extension. In ACL, 2013. [find](https://scholar.google.com/scholar?q=Qingqing+Cai+and+Alexander+Yates%2E+Large%2Dscale+semantic+parsing+via+schema+matching+and+lexicon+extension%2E+In+ACL%2C+2013%2E)
9. Li Dong and Mirella Lapata. [Language to logical form with neural attention](https://md.research.elamur.ai/free/en/papers/dong-2016-language-logical-form-neural-attention/). ACL, 2016.
10. Alessandra Giordani and Alessandro Moschitti. Translating questions to SQL queries with generative parsers discriminatively reranked. In COLING, 2012. [find](https://scholar.google.com/scholar?q=Alessandra+Giordani+and+Alessandro+Moschitti%2E+Translating+questions+to+SQL+queries+with+generative+parsers+discriminatively+reranked%2E+In+COLING%2C+2012%2E)
11. Jiatao Gu, Zhengdong Lu, Hang Li, and Victor O. K. Li. [Incorporating copying mechanism in sequence-to-sequence learning](https://md.research.elamur.ai/free/en/papers/gu-2016-incorporating-copying-mechanism-sequence-sequence/). ACL, 2016.
12. Kelvin Guu, Panupong Pasupat, Evan Zheran Liu, and Percy Liang. [From language to programs: Bridging reinforcement learning and maximum marginal likelihood](https://md.research.elamur.ai/free/en/papers/guu-2017-language-programs-bridging-reinforcement-learning/). In ACL, 2017.
13. Kazuma Hashimoto, Caiming Xiong, Yoshimasa Tsuruoka, and Richard Socher. [A Joint Many-Task Model: Growing a Neural Network for Multiple NLP Tasks](https://md.research.elamur.ai/free/en/papers/hashimoto-2016-joint-many-task-model-growing/). arXiv, cs.CL 1611.01587, 2016.
14. Richard Hillestad, James Bigelow, Anthony Bower, Federico Girosi, Robin Meili, Richard Scoville, and Roger Taylor. Can electronic medical record systems transform health care? potential health benefits, savings, and costs. Health affairs, 24(5):1103–1117, 2005. [find](https://scholar.google.com/scholar?q=Richard+Hillestad%2C+James+Bigelow%2C+Anthony+Bower%2C+Federico+Girosi%2C+Robin+Meili%2C+Richard+Scoville%2C+and+Roger+Taylor%2E+Can+electronic+medical+record+systems+transform+health+care%3F+potential+health+benefit)
15. Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. Neural computation, 1997. [find](https://scholar.google.com/scholar?q=Sepp+Hochreiter+and+Jurgen+Schmidhuber%2E+Long+short%2Dterm+memory%2E+Neural+computation%2C+1997%2E)
16. Srinivasan Iyer, Ioannis Konstas, Alvin Cheung, Jayant Krishnamurthy, and Luke Zettlemoyer. Learning a neural semantic parser from user feedback. In ACL, 2017. [find](https://scholar.google.com/scholar?q=Srinivasan+Iyer%2C+Ioannis+Konstas%2C+Alvin+Cheung%2C+Jayant+Krishnamurthy%2C+and+Luke+Zettlemoyer%2E+Learning+a+neural+semantic+parser+from+user+feedback%2E+In+ACL%2C+2017%2E)
17. Diederik P. Kingma and Jimmy Ba. abs/1412.[6980, 2014](https://md.research.elamur.ai/free/en/papers/kingma-2014-adam-method-stochastic-optimization/).
18. Adam: A method for stochastic optimization. Chen Liang, Jonathan Berant, Quoc V. Le, Ken Forbus, and Ni Lao. Neural symbolic machines: Learning semantic parsers on freebase with weak supervision. In ACL, 2017. [find](https://scholar.google.com/scholar?q=Adam%3A+A+method+for+stochastic+optimization%2E+Chen+Liang%2C+Jonathan+Berant%2C+Quoc+V%2E+Le%2C+Ken+Forbus%2C+and+Ni+Lao%2E+Neural+symbolic+machines%3A+Learning+semantic+parsers+on+freebase+with+weak+supervision%2E+In+A)
19. Percy Liang, Michael I. Jordan, and Dan Klein. Learning dependency-based compositional semantics. Computational Linguistics, 39:389–446, 2011. [find](https://scholar.google.com/scholar?q=Percy+Liang%2C+Michael+I%2E+Jordan%2C+and+Dan+Klein%2E+Learning+dependency%2Dbased+compositional+semantics%2E+Computational+Linguistics%2C+39%3A389%E2%80%93446%2C+2011%2E)
20. Christopher D. Manning, Mihai Surdeanu, John Bauer, Jenny Finkel, Steven J. Bethard, and David McClosky. [The Stanford CoreNLP natural language processing toolkit](https://md.research.elamur.ai/free/en/papers/manning-2014-stanford-corenlp-natural-language-processing/). In Association for Computational Linguistics (ACL) System Demonstrations, pp. 55–60, 2014.
21. Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. [Pointer sentinel mixture models](https://md.research.elamur.ai/free/en/papers/merity-2016-pointer-sentinel-mixture-models/). ICLR, 2017. arXiv, Lili Mou, Zhengdong Lu, Hang Li, and Zhi Jin. Coupling distributed and symbolic execution for natural language queries. In ICML, 2017.
22. Arvind Neelakantan, Quoc V. Le, Martı́n Abadi, Andrew McCallum, and Dario Amodei. Learning a natural language interface with neural programmer. In ICLR, 2017. [find](https://scholar.google.com/scholar?q=Arvind+Neelakantan%2C+Quoc+V%2E+Le%2C+Mart%C4%B1%CC%81n+Abadi%2C+Andrew+McCallum%2C+and+Dario+Amodei%2E+Learning+a+natural+language+interface+with+neural+programmer%2E+In+ICLR%2C+2017%2E)
23. Eric WT Ngai, Li Xiu, and Dorothy CK Chau. Application of data mining techniques in customer relationship management: A literature review and classification. Expert systems with applications, 36(2):2592–2602, 2009. [find](https://scholar.google.com/scholar?q=Eric+WT+Ngai%2C+Li+Xiu%2C+and+Dorothy+CK+Chau%2E+Application+of+data+mining+techniques+in+customer+relationship+management%3A+A+literature+review+and+classification%2E+Expert+systems+with+applications%2C+36%282%29%3A25)
24. Panupong Pasupat and Percy Liang. [Compositional semantic parsing on semi-structured tables](https://md.research.elamur.ai/free/en/papers/pasupat-2015-compositional-semantic-parsing-semi-structured/). In ACL, 2015.
25. Jeffrey Pennington, Richard Socher, and Christopher D. Manning. [Glove: Global vectors for word representation](https://md.research.elamur.ai/free/en/papers/pennington-2014-glove-global-vectors-word-representation/). In EMNLP, 2014.
26. Ana-Maria Popescu, Oren Etzioni, and Henry Kautz. Towards a theory of natural language interfaces to databases. In Proceedings of the 8th International Conference on Intelligent User Interfaces, pp. 149–157. ACM, 2003. [find](https://scholar.google.com/scholar?q=Ana%2DMaria+Popescu%2C+Oren+Etzioni%2C+and+Henry+Kautz%2E+Towards+a+theory+of+natural+language+interfaces+to+databases%2E+In+Proceedings+of+the+8th+International+Conference+on+Intelligent+User+Interfaces%2C+pp%2E+1)
27. Patti J. Price. Evaluation of spoken language systems: The ATIS domain. 1990. [find](https://scholar.google.com/scholar?q=Patti+J%2E+Price%2E+Evaluation+of+spoken+language+systems%3A+The+ATIS+domain%2E+1990%2E)
28. Siva Reddy, Mirella Lapata, and Mark Steedman. Large-scale semantic parsing without question-answer pairs. TACL, 2:377–392, 2014. [find](https://scholar.google.com/scholar?q=Siva+Reddy%2C+Mirella+Lapata%2C+and+Mark+Steedman%2E+Large%2Dscale+semantic+parsing+without+question%2Danswer+pairs%2E+TACL%2C+2%3A377%E2%80%93392%2C+2014%2E)
29. John Schulman, Nicolas Heess, Theophane Weber, and Pieter Abbeel. Gradient estimation using stochastic computation graphs. In NIPS, 2015. [find](https://scholar.google.com/scholar?q=John+Schulman%2C+Nicolas+Heess%2C+Theophane+Weber%2C+and+Pieter+Abbeel%2E+Gradient+estimation+using+stochastic+computation+graphs%2E+In+NIPS%2C+2015%2E)
30. Min Joon Seo, Aniruddha Kembhavi, Ali Farhadi, and Hannaneh Hajishirzi. [Bidirectional attention flow for machine comprehension](https://md.research.elamur.ai/free/en/papers/seo-2016-bidirectional-attention-flow-machine-comprehension/). ICLR, 2017.
31. Nitish Srivastava, Geoffrey E. Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15:1929–1958, 2014. [find](https://scholar.google.com/scholar?q=Nitish+Srivastava%2C+Geoffrey+E%2E+Hinton%2C+Alex+Krizhevsky%2C+Ilya+Sutskever%2C+and+Ruslan+Salakhutdinov%2E+Dropout%3A+a+simple+way+to+prevent+neural+networks+from+overfitting%2E+Journal+of+Machine+Learning+Researc)
32. Janez Starc and Dunja Mladenic. Joint learning of ontology and semantic parser from text. Intelligent Data Analysis, 21:19–38, 2017. [find](https://scholar.google.com/scholar?q=Janez+Starc+and+Dunja+Mladenic%2E+Joint+learning+of+ontology+and+semantic+parser+from+text%2E+Intelligent+Data+Analysis%2C+21%3A19%E2%80%9338%2C+2017%2E)
33. Richard S Sutton, David A McAllester, Satinder P Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. In Advances in neural information processing systems, pp. 1057–1063, 2000. [find](https://scholar.google.com/scholar?q=Richard+S+Sutton%2C+David+A+McAllester%2C+Satinder+P+Singh%2C+and+Yishay+Mansour%2E+Policy+gradient+methods+for+reinforcement+learning+with+function+approximation%2E+In+Advances+in+neural+information+processing)
34. Lappoon R. Tang and Raymond J. Mooney. Using multiple clause constructors in inductive logic programming for semantic parsing. In ECML, 2001. [find](https://scholar.google.com/scholar?q=Lappoon+R%2E+Tang+and+Raymond+J%2E+Mooney%2E+Using+multiple+clause+constructors+in+inductive+logic+programming+for+semantic+parsing%2E+In+ECML%2C+2001%2E)
35. Oriol Vinyals, Meire Fortunato, and Navdeep Jaitly. Pointer networks. In NIPS, 2015. [find](https://scholar.google.com/scholar?q=Oriol+Vinyals%2C+Meire+Fortunato%2C+and+Navdeep+Jaitly%2E+Pointer+networks%2E+In+NIPS%2C+2015%2E)
36. Yushi Wang, Jonathan Berant, and Percy Liang. Building a semantic parser overnight. In ACL, 2015. [find](https://scholar.google.com/scholar?q=Yushi+Wang%2C+Jonathan+Berant%2C+and+Percy+Liang%2E+Building+a+semantic+parser+overnight%2E+In+ACL%2C+2015%2E)
37. Yuk Wah Wong and Raymond J. Mooney. [Learning synchronous grammars for semantic parsing with lambda calculus](https://md.research.elamur.ai/free/en/papers/wong-2007-learning-synchronous-grammars-semantic-parsing/). In ACL, 2007.
38. Caiming Xiong, Victor Zhong, and Richard Socher. [Dynamic coattention networks for question answering](https://md.research.elamur.ai/free/en/papers/xiong-2016-dynamic-coattention-networks-question-answering/). ICLR, 2017.
39. Pengcheng Yin, Zhengdong Lu, Hang Li, and Ben Kao. Neural enquirer: Learning to query tables. In ACL, 2016. [find](https://scholar.google.com/scholar?q=Pengcheng+Yin%2C+Zhengdong+Lu%2C+Hang+Li%2C+and+Ben+Kao%2E+Neural+enquirer%3A+Learning+to+query+tables%2E+In+ACL%2C+2016%2E)
40. John M. Zelle and Raymond J. Mooney. [Learning to parse database queries using inductive logic programming](https://md.research.elamur.ai/free/en/papers/zelle-1996-learning-parse-database-queries-using/). In AAAI/IAAI, Vol. 2, 1996.
41. Luke S. Zettlemoyer and Michael Collins. [Learning to map sentences to logical form: Structured classification with probabilistic categorial grammars](https://md.research.elamur.ai/free/en/papers/zettlemoyer-2012-learning-map-sentences-logical-form/). In Uncertainty in Artificial Intelligence, 2005.
42. Luke S. Zettlemoyer and Michael Collins. Online learning of relaxed ccg grammars for parsing to logical form. In EMNLP-CoNLL, 2007. [find](https://scholar.google.com/scholar?q=Luke+S%2E+Zettlemoyer+and+Michael+Collins%2E+Online+learning+of+relaxed+ccg+grammars+for+parsing+to+logical+form%2E+In+EMNLP%2DCoNLL%2C+2007%2E)

*Updated 29 October 2026*
