Make writing a habit together! This is the 15th day of my participation in the “Gold Digging Day New Plan · April More text Challenge”. Click here for more details.
The paper
- 81. Representing Schema Structure with Graph Neural Networks for text-to-SQL Parsing
- Conference: ACL 2019
- Link: arxiv.org/abs/1905.06…
Introduction:
Since most of the previous text-to-SQL data sets were trained and tested on the same schema (such as ATIS data set), or the schema structure of the database was simple (such as WikiSQL data set was single-table structure), most of the past models ignored the modeling of schema structure. This blog introduces an early paper that used GNN to model a schema structure.
Introduction to the
Spider data sets have complex schema structures. As shown in Figure 1, under different database schemas, similar problems can result in completely different FORMS of SQL statements.
The previous data sets such as ATIS and WikiSQL either do not involve cross-domain data or only have single table data, resulting in the neglect of the modeling of database schema structure for a long time. This paper presents a method of modeling database schema structure using graph neural network GNN. The performance of text-to-SQL tasks in complex schemas is improved by using GNN to encode schema structure information.
methods
In this paper, an Encoder-Decoder model is adopted, in which the graph neural network GNN is used to model and represent the structure of schema. SQL > query db schema encode as a graph. SQL > query db schema encode as a graph. Add the embedding and question to the BLSTM encoder. The decode phase, again LSTM, uses a grammar-based approach to generate the final query using graph’s rules.
Model the schema using GNN
First, convert the schema into a graph. Take the input on the left of the following figure as an example. The tables involved are Student, semester, student_semester, and program, and we use the table name and column name as each node in the graph.
Next, there are three edges in the whole graph:
- The node of the table joins all of its columns, for example program-> program_id;
- Student_id -> student_scholarship. student_id; student_scholarship. student_id; student_scholarship. student_id; student_scholarship. student_id; student_scholarship. student_id; student_scholarship. student_id; student_scholarship. student_id.
- The edge with the foreign key as the starting point is the third type of edge, for example, and student_scholarship. student_id->student.student_id.
The figure after the connection is completed is shown in the middle of the figure above, where the nodes with black edges represent table and the other nodes represent Column. There are three types of edges between them.
In practical application, not all nodes in the graph need to be used. Here, the model calculates the correlation between nodes in each schema graph and question token, denoted as slink(v,xi)s_{link}(V, X_I)slink(v,xi). Then, softmax is used to get the probability distribution plink(v,xi)p_{link}(v,x_i)plink(v,xi)
The encoder
Firstly, a correlation score is defined to indicate the degree to which nodes in the graph are related to the problem.
The model uses this score to identify which schema items are used in the final SQL statement. The dark nodes in the middle of Figure 3 are the Schema items that the model considers relevant.
This correlation score and initial embedding are used to get problem-based embedding
The final embedding of each node is obtained through LAYER L GNN
Encoder is bidirectional LSTM. Database schema-related embedding is added to the input
decoder
The structure of the decoder is shown in the figure above.
Representing Schema Structure with Graph Neural Networks for text-to-SQL Parsing
The experiment
The experimental results are shown in the figure below. It can be seen that the accuracy of multi-table query is greatly improved after the addition of GNN.
A set of experiments on GNN ORACLE REL. The experimental setup is that the model can accurately identify which schema items are used in the final SQL statement and which are not. Under this setting, the model performance can be further improved. This also suggests that we can continue to optimize the correlation score to help the model better identify which schema items are really useful.
conclusion
This blog introduces a method of introducing GNN into text-to-SQL tasks. In this paper, the author only uses GNN to model schemas to better represent the structural information between schemas. The next blog will introduce an extension of the GlobalGNN model based on this paper.