A Recursive Semantic Parsing Framework for Text-To-SQL Task

A Recursive Semantic Parsing Framework for Text-To-SQL Task

Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence (IJCAI-20) RECPARSER: A Recursive Semantic Parsing Framework for Text-to-SQL Task Yu Zeng1∗ , Yan Gao2 , Jiaqi Guo3∗ , Bei Chen2 , Qian Liu4∗ , Jian-Guang Lou2 , Fei Tengy1 and Dongmei Zhang2 1Southwest Jiaotong University, Chengdu, China 2Microsoft Research Asia, Beijing, China 3Xi’an Jiaotong University, Xi’an, China 4Beihang University, Beijing, China [email protected], fyan.gao, beichen, jlou, [email protected], [email protected], [email protected], [email protected] list all song names by singers age above the Abstract Utterance: average singer age. Neural semantic parsers usually fail to parse SELECT song_name FROM singers SQL Query: long and complicated utterances into nested SQL WHERE age > (SELECT avg(age) FROM singers) queries, due to the large search space. In this pa- per, we propose a novel recursive semantic pars- Figure 1: An example of the component mapping relationship be- ing framework called RECPARSER to generate the tween the nested SQL query and its corresponding utterance. nested SQL query layer-by-layer. It decomposes the complicated nested SQL query generation prob- lem into several progressive non-nested SQL query In this paper, we focus on the problem of composing nested generation problems. Furthermore, we propose SQL queries in Text-to-SQL task. Firstly, as we know the a novel Question Decomposer module to explic- nested SQL query representation is formalized as a kind of itly encourage RECPARSER to focus on different recursive structure, thus a nested SQL query generation prob- components of an utterance when predicting SQL lem can be decomposed into several progressive non-nested queries of different layers. Experiments on the Spi- SQL query generation problems by nature. Furthermore, we der dataset show that our approach is more effec- found that there is a strong component mapping relation- tive compared to the previous works at predicting ship between the nested SQL query and its corresponding the nested SQL queries. In addition, we achieve an utterance. Figure 1 shows an example of the component overall accuracy that is comparable with state-of- mapping relationship between the nested SQL query and its the-art approaches. corresponding utterance. We see that, for this nested SQL query, the outside layer “SELECT song name FROM singers WHERE age >” and the inside layer “SELECT avg(age) 1 Introduction FROM singers” correspond to different utterance components “list all song names by singers age above” and “the average Text-to-SQL is one of the most important sub-tasks of se- singer age” respectively. mantic parsing in natural language processing (NLP). It maps natural language utterances to corresponding SQL queries. Inspired by these observations, we propose a recursive se- By helping non-experts to interact with ever increasing mantic parsing framework called RECPARSER to generate databases, the task has many important potential applica- the nested SQL query layer-by-layer from outside to inside. tions in real life, and thus receives a great deal of interest Furthermore, we propose a novel Question Decomposer mod- from both industry and academia [Li and Jagadish, 2016; ule to explicitly encourage RECPARSER to focus on different Zhong et al., 2017; Affolter et al., 2019]. parts of an utterance when predicting SQL queries in differ- Composing nested SQL queries is a challenging problem in ent layers. RECPARSER consists of four modules: Initial Text-to-SQL. Several works [Guo et al., 2019; Zhang et al., Encoder, Iterative Encoder, Question Decomposer and SQL 2019b; Bogin et al., 2019; Yu et al., 2018a] have attempted Generator. In the initialization stage, we encode the user to deal with this problem on the recently proposed dataset utterance and the database schema with the Initial Encoder. Spider [Yu et al., 2018b], which contains nested SQL queries Then, by recursively calling the Question Decomposer, the over different databases with multiple tables. However, due Iterative Encoder and the SQL Generator modules, we gener- to the large search space, existing neural semantic parsers do ate the nested SQL query layer-by-layer. Finally, we compose not perform well on composing nested SQL queries [Zhang SQL queries of different layers into the whole SQL query et al., 2019a; Affolter et al., 2019]. when encountering a recursive termination condition. Con- cretely, in each recursion round, the Question Decomposer ∗Work done during an internship at Microsoft Research. updates the utterance representation with a soft-attention- yCorresponding Author mask mechanism and a recursive-attention-divergency loss 3644 Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence (IJCAI-20) proposed by us for the next recursion; the Iterative Encoder Recursive Mechanism in Semantic Parsing. Recursive contextualizes the schema representation with the updated ut- mechanism has been successfully used in complicated se- terance representation; the SQL Generator takes the contextu- mantic parsing tasks [Andreas et al., 2016; Rabinovich et alized schema representation as input and generates the non- al., 2017]. Recently, several works [Yu et al., 2018a; nested SQL query of the current layer. Our SQL Generator is Lee, 2019] also employ the recursive mechanism to gener- a simple yet effective multi-task classification model. ate nested SQL queries in Text-to-SQL task. SyntaxSQL- We argue that RECPARSER has two advantages. Firstly, Net [Yu et al., 2018a] employs a SQL specific syntax tree- in this divide-and-conquer faction, we simplify the difficulty based decoder that calls a collection of recursive modules of the nested query generation problem. Our SQL Genera- for decoding. RCSQL [Lee, 2019] proposes a SQL clause- tor only learns to generate non-nested SQL queries instead of wise decoding architecture. It recursively calls different SQL the whole nested SQL query, thus largely reducing the search clause decoders to predict nested SQL queries. Compared space and alleviating training difficulties. Secondly, through with their approaches, we recursively call both encoder mod- updating the utterance representation recursively with the ule and SQL generator module for each recursion, while they soft-attention-mask mechanism and the recursive-attention- only call a set of SQL generator modules. In addition, we divergency loss, RECPARSER can focus on different parts of propose a novel Question Decomposer module to capture the an utterance when predicting different SQL query layers, thus mapping relationship between different SQL query layers and minimizing the interference of irrelevant parts. their corresponding components in utterance. On the Spider benchmark [Yu et al., 2018b], RECPARSER achieves a state-of-the-art 39.3% accuracy on the nested SQL Decomposing Complicated Question. Decomposing query and a comparable 54.3% accuracy on the overall SQL complicated question is widely used in many semantic query. When augmented with BERT [Devlin et al., 2018], parsing works [Iyyer et al., 2016; Talmor and Berant, 2018; RECPARSER reaches up to a state-of-the-art 46.8% accu- Zhang et al., 2019a]. They utilize the decompositionality racy on the nested SQL query and a state-of-the-art 63.1% of complicated questions to help question understanding. accuracy on the overall SQL query. Our contributions are Inspired by them, we use the soft-attention-mask mechanism summarized as follows. and the recursive-attention-divergency loss to model the de- • We propose a recursive semantic parsing framework composing process of the utterance and update the utterance called RECPARSER to decompose a complicated nested representation for next recursion round. In this way, we don’t SQL query generation problem into several progressive need to make hard decisions and it could be learned in an non-nested SQL query generation problems. end-to-end fashion without extra labeling work. • We propose a novel Question Decomposer module Multi-Task Learning in Text-to-SQL Task. In multi-task with a soft-attention-mask mechanism and a recursive- learning, the Text-to-SQL task is decomposed into several attention-divergency loss to explicitly encourage REC- sub-tasks, each predicting a part of the final SQL program. PARSER to focus on different parts of the utterance Compared with sequence-to-sequence-style models, multi- when predicting SQL queries in different layers. task learning does not require the SQL queries to be serial- • Our approach is more effective compared to previous ized and thus avoid the “ordering issue” [Xu et al., 2018]. works at predicting nested SQL queries. In addition, Existing state-of-the-art multi-task learning methods [Hwang we achieve an overall accuracy that is comparable with et al., 2019; He et al., 2019] have already surpassed human state-of-the-art approaches. performance on WikiSQL [Zhong et al., 2017] dataset. How- ever, existing methods are limited to the specific SQL sketch 2 Related Works of WikiSQL, which only supports very simple queries. In this Composing Nested SQL Query. The problem of compos- work, we propose a simple yet effective multi-task classifica- ing nested SQL queries has been studied for decades [An- tion model to generate arbitrary non-nested SQL query as the droutsopoulos et al., 1995]. Most of the early proposed sys- SQL Generator module in our framework. tems are rule-based [Popescu et al., 2003; Li and Jagadish, 2014]. Recently, with the development of advanced neural approaches and the release of the complex and cross-domain 3 Methodology Text-to-SQL dataset Spider [Yu et al., 2018b], several neu- ral semantic parsers [Guo et al., 2019; Zhang et al., 2019b; In this section, we will describe our RECPARSER framework Bogin et al., 2019; Lee, 2019] have attempted to generate in detail. As described in Figure 2, RECPARSER consists of the nested SQL queries with a complicated grammar-based four modules: Initial Encoder, Iterative Encoder, Question decoder. However, applying grammar-based decoders to gen- Decomposer and SQL Generator.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us