IGSQL : Database Schema Interaction Graph Based Neural Model for Context-Dependent Text-to- SQL Generation (2020)

Abstract: Context-dependent text-to-SQL task has drawn much attention in recent years. Previous models on context-dependent text-to-SQL task only concentrate on utilizing historic user inputs. In this work, in addition to using encoders to capture historic information of user inputs, we propose a database schema interaction graph encoder to utilize historic information of database schema items. In decoding phase, we introduce a gate mechanism to weigh the importance of different vocabularies and then make the prediction of SQL tokens. We evaluate our model on the benchmark SParC and CoSQL datasets, which are two large complex context-dependent cross-domain text-to-SQL datasets. Our model outperforms previous state-of-the-art model by a large margin and achieves new state-of-the-art results on the two datasets. The comparison and ablation results demonstrate the efficacy of our model and the usefulness of the database schema interaction graph encoder.

## introduction the text-to-sql task aims to translate natural language texts into sql queries. users who do not understand sql grammars can benefit from this task and acquire information from databases by just inputting natural language texts. previous works @xcite @xcite @xcite focus on context-independent text-to-sql generation. however, in practice, users usually interact with systems for several turns to acquire information, which extends the text-to-sql task to the context-dependent text-to-sql task in a conversational scenario. throughout the interaction, user inputs may omit some information that appeared before. this phenomenon brings difficulty for context-dependent text-to-sql task. recently, context-dependent text-to-sql task has attracted more attention. @xcite conduct experiments on atis dataset @xcite . besides, two cross-domain contextdependent datasets sparc @xcite and cosql @xcite are released. crossdomain means databases in test set differ from that in training set, which is more challenging. editsql @xcite is the previous state-of-the-art model on sparc and cosql datasets and it focuses on taking advantages of previous utterance texts and previously predicted query to predict the query for current turn. according to @xcite and @xcite , to maintain thematic relations, users may change constraints, ask for different attributes for the same topic when they ask the next questions. thus, database schema items (i.e., table.column) in current turn should have relation with items in previous turn. for example, in in particular, we first construct a graph based on corresponding database, where graph nodes are database schema items and graph edges are primary-foreign keys and column affiliation. short our main contributions are summarized as follows: ## related work many studies have focused on context-independent text-to-sql task. zhong et al. (2017) split the vocabulary and use reinforcement learning. xu et al. (2017) propose a sketched-based model, which decomposes the token prediction process into select-clause prediction and where-clause prediction, aiming at taking previous predictions into consideration. yu et al. (2018a) further employ a tree-based sql decoder so as to decode sql queries with the help of sql grammar. in order to encode database schemas, schemas are regarded as graphs and graph neural networks have been applied (bogin et al., 2019a,b). guo et al. (2019) design an intermediate representation to bridge the gap between natural language texts and sql queries. choi et al. (2020) utilize a sketch-based slot filling approach to synthesize sql queries. wang et al. (2019) attempt to align the database columns and their mentions in user inputs by using a relation-aware self attention. recently, context-dependent text-to-sql task has drawn people's attention. in-domain contextdependent benchmarks atis @xcite have been proposed. for atis, @xcite utilize a sequence to sequence framework. besides, they introduce an interaction-level encoder for incorporating historical user inputs and a segment copy mechanism to reduce the length of generation. later, two large and complex cross-domain context-dependent dataset sparc @xcite and cosql @xcite are proposed. in order to tackle cross-domain context-dependent text-to-sql task, @xcite propose the editsql model in order to capture features from historical user inputs, variant database schemas and previously predicted sql query. editsql achieves the state-of-the-art performance on the two crossdomain datasets. compared to editsql, our work further explore a new way to employ historical information of database schemas. ## problem setup we define x as a series of natural language utterances of an interaction (i.e., user inputs), y as corresponding ground-truth sql queries, s as the set of database schema items (table.column) and r as the set of relations between schema items (primary-foreign keys and column affiliation). let @xmath0, x foot_1 , ..., x |x| }, where |x| is the number of utterances. ## igsql model our model adopts an encoder-decoder framework with attention mechanism. figure 1 shows the architecture of our model. the model have four main components: (1) a database schema interaction graph encoder, which consists of crossturn schema interaction graph layers and intra-turn schema graph layers, (2) a text encoder that captures historical information of user inputs, (3) a co-attention module that updates outputs of text encoder and database schema interaction graph encoder, and (4) a decoder with a gated mechanism to weight the importance of different vocabularies. in addition, the model also uses bert embedding. we will first introduce the bert embedding in section 4.1, and then introduce our database schema interaction graph encoder in section 4.2, text encoder and co-attention module in section 4.3 and decoder in section 4.4. ## conclusion and future work in this paper, we focus on context-dependent crossdomain sql generation task. we find that previous state-of-the-art model only takes historical user inputs and previously predicted query into consideration, but ignores the historical information of database schema items. thus we propose a model named igsql to model database schema items in a conversational scenario. empirical results demonstrate the efficacy of our model. we also conduct ablation experiments to reveal the significance of our database schema interaction graph encoder. for future work, we will explore methods attempting to solve hard and extra hard questions.