Automatic Generation and Reranking of SQL-Derived Answers to NL Questions

  • Alessandra Giordani
  • Alessandro Moschitti
Conference paper
Part of the Communications in Computer and Information Science book series (CCIS, volume 379)


In this paper, given a relational database, we automatically translate a natural language question into an SQL query retrieving the correct answer. We exploit the structure of the DB to generate a set of candidate SQL queries, which we rerank with a SVM-ranker based on tree kernels. In particular we use linguistic dependencies in the natural language question and the DB metadata to build a set of plausible SELECT, WHERE and FROM clauses enriched with meaningful joins. Then, we combine all the clauses to get the set of all possible SQL queries, producing candidate queries to answer the question. This approach can be recursively applied to deal with complex questions, requiring nested queries. We sort the candidates in terms of scores of correctness using a weighting scheme applied to the query generation rules. Then, we use a SVM ranker trained with structural kernels to reorder the list of question and query pairs, where both members are represented as syntactic trees. The f-measure of our model on standard benchmarks is in line with the best models (85% on the first question), which use external and expensive hand-crafted resources such as the semantic interpretation. Moreover, we can provide a set of candidate answers with a Recall of the answer of about 92% and 96% on the first 2 and 5 candidates, respectively.


Relative Clause Automatic Generation Relational Algebra Question Answering Inductive Logic Programming 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Charniak, E.: A maximum-entropy-inspired parser. In: Proceedings of NAACL 2000 (2000)Google Scholar
  2. 2.
    Collins, M., Duffy, N.: New ranking algorithms for parsing and tagging: Kernels over discrete structures, and the voted perceptron. In: Proceedings of ACL 2002 (2002)Google Scholar
  3. 3.
    Garcia-Molina, H., Ullman, J.D., Widom, J.: Database Systems: The Complete Book, 2nd edn. Prentice Hall Press, Upper Saddle River (2008)Google Scholar
  4. 4.
    Giordani, A., Moschitti, A.: Corpora for automatically learning to map natural language questions into sql queries. In: Proceedings of LREC 2010, Valletta, Malta. European Language Resources Association (ELRA) (May 2010)Google Scholar
  5. 5.
    Granberg, J., Minock, M.: A natural language interface over the musicbrainz database. In: Proceedings of the 1st Workshop on Question Answering over Linked Data (QALD-1): Co-located with the 8th Extended Semantic Web Conference, pp. 38–43 (2011), QC 20120413Google Scholar
  6. 6.
    Joachims, T.: Making large-scale SVM learning practical. In: Schölkopf, B., Burges, C., Smola, A. (eds.) Advances in Kernel Methods (1999)Google Scholar
  7. 7.
    Kate, R.J., Mooney, R.J.: Using string-kernels for learning semantic parsers. In: Proceedings of the 21st ICCL and 44th Annual Meeting of the ACL, Sydney, Australia, pp. 913–920. Association for Computational Linguistics (July 2006)Google Scholar
  8. 8.
    MacCartney, B., de Marneffe, M.-C., Manning, C.D.: Generating typed dependency parses from phrase structure parses. In: Proceedings LREC 2006 (2006)Google Scholar
  9. 9.
    Minock, M., Olofsson, P., Näslund, A.: Towards building robust natural language interfaces to databases. In: Kapetanios, E., Sugumaran, V., Spiliopoulou, M. (eds.) NLDB 2008. LNCS, vol. 5039, pp. 187–198. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  10. 10.
    Popescu, A.-M., Etzioni, O.A., Kautz, H.A.: Towards a theory of natural language interfaces to databases. In: Proceedings of the 2003 International Conference on Intelligent User Interfaces, Miami. Association for Computational Linguistics (2003)Google Scholar
  11. 11.
    Ruwanpura, S.: Sq-hal: Natural language to sql translatorGoogle Scholar
  12. 12.
    Salton, G.: Recent trends in automatic information retrieval. In: Proceedings of the 9th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR 1986, Pisa, Italy, September 8-10, pp. 1–10. ACM (1986)Google Scholar
  13. 13.
    Shen, L., Joshi, A.K.: An SVM-based voting algorithm with application to parse reranking. In: Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pp. 9–16 (2003)Google Scholar
  14. 14.
    Tang, L.R., Mooney, R.J.: Using multiple clause constructors in inductive logic programming for semantic parsing. In: Flach, P.A., De Raedt, L. (eds.) ECML 2001. LNCS (LNAI), vol. 2167, pp. 466–477. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  15. 15.
    Zettlemoyer, L.S., Collins, M.: Learning to map sentences to logical form: Structured classification with probabilistic categorial grammars. In: UAI, pp. 658–666 (2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Alessandra Giordani
    • 1
  • Alessandro Moschitti
    • 1
  1. 1.Department of Computer Science and EngineeringUniversity of TrentoItaly

Personalised recommendations