Skip to main content

SQL Generation from Natural Language Using Supervised Learning and Recurrent Neural Networks

  • Conference paper
  • First Online:
Artificial Intelligence and Industrial Applications (A2IA 2020)

Abstract

Databases store a vast amount of today’s data and information, and to access that data users are required to have command over SQL or equivalent interface language. Hence, using a system that can convert a natural language to equivalent SQL query would make the data more accessible. In this sense, building natural language interfaces to relational databases is an important and challenging problem in natural language processing (NLP) and a widely studied field, and found recently momentum again due to the introduction of large-scale Datasets. In this paper, we present our approach based on word embedding and Recurrent Neural Networks (RNN), precisely on Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRU) cells. We present also the DataSet used for training and testing our models, based on WikiSQL, and finally we show where we arrived in terms of accuracy.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 219.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 279.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Hillestad, R., Bigelow, J., Bower, A., Girosi, F., Meili, R., Scoville, R., Taylor, R.: Can electronic medical record systems transform health care? potential health benefits, savings, and costs. Health Aff. 24(5), 1103–1117 (2005)

    Article  Google Scholar 

  2. Beck, T., Demirgüç-Kunt, A., Levine, R.: A new database on the structure and development of the financial sector. World Bank Econ. Rev. 14(3), 597–605 (2000)

    Article  Google Scholar 

  3. Ngai, E.W.T., Xiu, L., Chau, D.C.K.: Application of data mining techniques in customer relationship management: a literature review and classification. Expert Syst. Appl. 36(2), 2592–2602 (2009)

    Article  Google Scholar 

  4. Androutsopoulos, I., Ritchie, G.D., Thanisch, P.: Natural language interfaces to databases–an introduction. Nat. Lang. Eng.(1995)

    Google Scholar 

  5. Popescu, A.-M., Etzioni, O., Kautz, H.: Towards a theory of natural language interfaces to databases. In: Proceedings of the 8th International Conference on Intelligent User Interfaces, pp. 149–157 (2003)

    Google Scholar 

  6. Bakliwal, A., Arora, P., Patil, A., et al.: Towards enhanced opinion classification using NLP techniques. In: Proceedings of the Workshop on Sentiment Analysis where AI Meets Psychology (SAAIP 2011), pp. 101–107 (2011)

    Google Scholar 

  7. Mikolov, T., Karafiát, M., Burget, L., et al.: Recurrent neural network based language model. In: Eleventh Annual Conference of the International Speech Communication Association (2010)

    Google Scholar 

  8. Sundermeyer, M., Schlüter, R., Ney, H.: LSTM neural networks for language modeling. In: Thirteenth Annual Conference of the International Speech Communication Association (2012)

    Google Scholar 

  9. Dey, R., Salemt, F.M.: Gate-variants of gated recurrent unit (GRU) neural networks. In: 2017 IEEE 60th International Midwest Symposium on Circuits and Systems (MWSCAS), pp. 1597–1600. IEEE (2017)

    Google Scholar 

  10. Xu, X., Liu, C., Song, D.: SQLNET: generating structured queries from natural language without reinforcement learning. arXiv preprint arXiv:1711.04436 (2017)

  11. Alur, R., Bodik, R., Juniwal, G., et al.: Syntax-guided synthesis. In: 2013 Formal Methods in Computer-Aided Design, pp. 1–8. IEEE (2013)

    Google Scholar 

  12. Solar-Lezama, A., Tancau, L., Bodik, R., et al.: Combinatorial sketching for finite programs. ACM Sigplan Not. 41(11), 404–415 (2006)

    Article  Google Scholar 

  13. Zelle, J.M., Mooney, R.J.: Learning to parse database queries using inductive logic programming. In: AAAI/IAAI, Portland, OR, pp. 1050–1055. AAAI Press/MIT Press (1996)

    Google Scholar 

  14. Zettlemoyer, L.S., Collins, M.: Learning to map sentences to logical form: structured classification with probabilistic categorial grammars. UAI (2005)

    Google Scholar 

  15. Wong, Y.W., Mooney, R.J.: Learning synchronous grammars for semantic parsing with lambda calculus. In: Proceedings of the 45th Annual Meeting of the Association for Computational Linguistics (ACL-2007), Prague, Czech Republic (2007)

    Google Scholar 

  16. Das, D., Schneider, N., Chen, D., Smith, N.A.: Probabilistic frame-semantic parsing. In: NAACL (2010)

    Google Scholar 

  17. Liang, P., Jordan, M.I., Klein, D.: Learning dependency-based compositional semantics. In: Association for Computational Linguistics (ACL), pp. 590–599 (2011)

    Google Scholar 

  18. Banarescu, L., Bonial, C., Cai, S., et al.: Abstract meaning representation for sembanking. In: Proceedings of the 7th Linguistic Annotation Workshop and Interoperability with Discourse, pp. 178–186 (2013)

    Google Scholar 

  19. Asian Federation of Natural Language Processing, Volume 1: Long Papers, Beijing, China, 26–31 July 2015, pp. 1470–1480. ACL (2015)

    Google Scholar 

  20. Herzig, J., Berant, J.: Decoupling structure and lexicon for zero-shot semantic parsing. EMNLP (2018)

    Google Scholar 

  21. Warren, D.H.D., Pereira, F.C.N.: An efficient easily adaptable system for interpreting natural language queries. Comput. Linguist. 8(3–4), 110–122 (1982)

    Google Scholar 

  22. Li, Y., Yang, H., Jagadish, H.V.: Constructing a generic natural language interface for an xml database. In: EDBT, vol. 3896, pp. 737–754. Springer (2006)

    Google Scholar 

  23. Giordani, A., Moschitti, A.: Translating questions to SQL queries with generative parsers discriminatively reranked. In: COLING (Posters), pp. 401–410 (2012)

    Google Scholar 

  24. Wang, C., Cheung, A., Bodik, R.: Synthesizing highly expressive SQL queries from input-output examples. In: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 452–466 (2017)

    Google Scholar 

  25. Li, F., Jagadish, H.V.: Constructing an interactive natural language interface for relational databases. In: VLDB (2014)

    Google Scholar 

  26. Yaghmazadeh, N., Wang, Y., Dillig, I., Dillig, T.: SQLizer: query synthesis from natural language. In: Proceedings of the ACM Programming Languages, 1(OOPSLA), pp. 63:1–63:26 (2017)

    Google Scholar 

  27. Popescu, A.-M., Etzioni, O., Kautz, H.: 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)

    Google Scholar 

  28. Giordani, A., Moschitti, A.: Translating questions to SQL queries with generative parsers discriminatively reranked. In: COLING (2012)

    Google Scholar 

  29. Iyer, S., Konstas, I., Cheung, A., Krishnamurthy, J., Zettlemoyer, L.: Learning a neural semantic parser from user feedback. In: ACL (2017)

    Google Scholar 

  30. Zhong, V., Xiong, C., Socher, R.: Seq2SQL: generating structured queries from natural language using reinforcement learning. CoRR, abs/1709.00103 (2017)

    Google Scholar 

  31. Cai, R., Xu, B., Yang, X., et al.: An encoder-decoder framework translating natural language to database queries. arXiv preprint arXiv:1711.06061 (2017)

  32. Castano, A., Casacuberta, F.: A connectionist approach to machine translation. In: Fifth European Conference on Speech Communication and Technology (1997)

    Google Scholar 

  33. Suhr, A., Iyer, S., Artzi, Y.: Learning to map context-dependent sentences to executable formal queries. In: Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 2238–2249. Association for Computational Linguistics (2018)

    Google Scholar 

  34. Gur, I., Yavuz, S., Su, Y., Yan, X.: DialSQL: dialogue based structured query generation. In: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1339–1349. Association for Computational Linguistics (2018)

    Google Scholar 

  35. Dong, L., Lapata, M.: Language to logical form with neural attention. In: Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, ACL 2016, Volume 1: Long Papers, Berlin, Germany, 7–12 August 2016 (2016)

    Google Scholar 

  36. Yin, P., Neubig, G.: A syntactic neural model for general-purpose code generation. In: ACL (1), pp. 440–450. Association for Computational Linguistics (2017)

    Google Scholar 

  37. Zhong, V., Xiong, C., Socher, R.: Seq2SQL: generating structured queries from natural language using reinforcement learning. arXiv preprint arXiv:1709.00103 (2017)

  38. Pennington, J., Socher, R., Manning, C.D.: GloVe: Global vectors for word representation. In: EMNLP, pp. 1532–1543. ACL (2014)

    Google Scholar 

  39. Kingma, D.P., Ba, J.: Adam: a method for stochastic optimization. In: The 3rd International Conference for Learning Representations, San Diego (2015)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Youssef Mellah .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Mellah, Y., Ettifouri, E.H., Rhouati, A., Dahhane, W., Bouchentouf, T., Belkasmi, M.G. (2021). SQL Generation from Natural Language Using Supervised Learning and Recurrent Neural Networks. In: Masrour, T., El Hassani, I., Cherrafi, A. (eds) Artificial Intelligence and Industrial Applications. A2IA 2020. Lecture Notes in Networks and Systems, vol 144. Springer, Cham. https://doi.org/10.1007/978-3-030-53970-2_17

Download citation

Publish with us

Policies and ethics