Exploiting Rich Syntactic Information for Semantic Parsing with Graph-to-Sequence Model

Existing neural semantic parsers mainly utilize a sequence encoder, i.e., a sequential LSTM, to extract word order features while neglecting other valuable syntactic information such as dependency or constituent trees. In this paper, we first propose to use the syntactic graph to represent three types of syntactic information, i.e., word order, dependency and constituency features; then employ a graph-to-sequence model to encode the syntactic graph and decode a logical form. Experimental results on benchmark datasets show that our model is comparable to the state-of-the-art on Jobs640, ATIS, and Geo880. Experimental results on adversarial examples demonstrate the robustness of the model is also improved by encoding more syntactic information.


Introduction
The task of semantic parsing is to translate text to its formal meaning representations, such as logical forms or structured queries.Recent neural semantic parsers approach this problem by learning soft alignments between natural language and logical forms from (text, logic) pairs (Jia and Liang, 2016;Dong and Lapata, 2016;Krishnamurthy et al., 2017).All these parsers follow the conventional encoder-decoder architecture that first encodes the text into a distributional representation and then decodes it to a logical form.These parsers may differ in the choice of the decoders, such as sequence or tree decoders, but they utilize the same encoder which is essentially a sequential Long Short-Term Memory network (SeqLSTM).This encoder only extracts word order features while neglecting useful syntactic information, such as dependency parse and constituency parse.
However, the syntactic features capture important structural information of the natural language input, which complements the simple word sequence.For example, a dependency graph presents grammatical relations that hold among the words; and a constituent tree provides a phrase structure representation.Intuitively, by incorporating such additional information, the encoder could produce a more meaningful and robust sentence representation.The combination of these features (i.e., sequence + trees) forms a general graph structure (see Figure 1).This inspires us to apply a graph encoder to produce a representation of a graph-structured input.The graph encoder also has the advantages that it could simultaneously encode all types of syntactic contexts, and incorporate multiple types of syntactic structures in a unified way.
In this paper, we first introduce a structure, namely syntactic graph, to represent three types of syntactic information, i.e., word order, dependency and constituency features (see §2).We then employ a novel graph-to-sequence (Graph2Seq) model (Xu et al., 2018), which consists of a graph encoder and a sequence decoder, to learn the representation of the syntactic graph (see §3).Specifically, the graph encoder learns the representation of each node by aggregating information from its K-hop neighbors.Given the learned node embeddings, the graph encoder uses a pooling-based method to generate the graph embedding.On the decoder side, a Recurrent Neural Network (RNN) decoder takes the graph embedding as its initial hidden state to generate the logical form while employing an attention mechanism over the node embeddings.Experimental results show that our model achieves the competitive performance on Jobs640, ATIS and Geo880 datasets.
Different from existing works, we also investigate the robustness of our model by evaluating  the model on two types of adversarial examples (Belinkov and Bisk, 2017;Cheng et al., 2018).Experimental results show that the model coupling all syntactic features has the best robustness, achieving the best performance.Our code and data is available at https://github.com/IBM/Text-to-LogicForm.

Syntactic Graph
In our model, we represent three types of syntactic features, i.e., word order, dependency parse and constituency parse, in the syntactic graph (see Figure 1).
• Word Order Features.Previous neural semantic parsers mainly use these features by building a SeqLSTM that works on the word sequence.Our syntactic graph also incorporates this information by generating a node for each word and connecting them in the chain form.In order to capture the forward and backward contextual information, we link these nodes in two directions, that is, from left to right and from right to left.• Dependency Features.A dependency parse describes the grammatical relations that hold among words.Reddy et al. (2016Reddy et al. ( , 2017) ) have demonstrated that the dependency parse tree could be directly transformed to a logical form, which indicates that the dependency information (i.e., tree structure and dependency labels) is critical to the semantic parsing task.We incorporate this information into the syntactic graph by adding directed edges between the word nodes and assign them with dependency labels.
• Constituency Features.Similar to the dependency parse, the constituency parse represents the phrase structure, which is also important to the semantic parsing task.Take Figure 1 as an example: given the constituent tree that explicitly annotates "not related with AI" (node #1) is a proposition phrase, the model could learn a meaningful embedding for this phrase by encoding this structure into the model.Motivated by this observation, we add the non-terminal nodes of the constituent tree and the edges describing their parent-child relationships into the syntactic graph.

Graph-to-sequence Model for Semantic Parsing
After building the syntactic graph for the input text, we employ a novel graph-to-sequence model (Xu et al., 2018), which includes a graph encoder and a sequence decoder with attention mechanism, to map the syntactic graph to the logical form.Conceptually, the graph encoder generates node embeddings for each node by accumulating information from its K-hop neighbors, and then produces a graph embedding for the entire graph by abstracting all these node embeddings.Next, the sequence decoder takes the graph embedding as the initial hidden state, and calculates the attention over all node embeddings on the encoder side to generate logical forms.Note that this graph encoder does not explicitly encode the edge label information, therefore, for each labeled edge, we add a node whose text attribute is the edge's label.
Node Embedding.Given the syntactic graph G = (V, E), we take the embedding generation process for node v ∈ V as an example to explain the node embedding generation algorithm1 : (1) We first transform node v's text attribute to a feature vector, a v , by looking up the embedding matrix W e ; (2) The neighbors of v are categorized into forward neighbors N (v) and backward neighbors N (v) according to the edge direction.In particular, N (v) returns the nodes that v directs to and N (v) returns the nodes that direct to v; (3) We aggregate the forward representations of v's forward neighbors , where k∈{1, ..., K} is the iteration index.Specifically, this aggregator feeds each neighbor's vector to a fully-connected neural network and applies an element-wise max-pooling operation to capture different aspects of the neighbor set.Notice that, at iteration k, this aggregator only uses the representations generated at k − 1.The initial forward representation of each node is its feature vector calculated in step (1); (4) We concatenate v's current forward representation h k−1 v with the newly generated neighborhood vector h k N (v) .This concatenated vector is fed into a fully connected layer with nonlinear activation function σ, which updates the forward representation of v, h k v , to be used at the next iteration; (5) We update the backward representation of v, h k v using the similar procedure as introduced in step ( 3) and ( 4) except that operating on the backward representations; (6) We repeat steps (3)∼(5) K times, and the concatenation of the final forward and backward representation is used as the final representation of v. Since the neighbor information from different hops may have different impact on the node embedding, we learn a distinct aggregator at each iteration.Graph Embedding.We feed the obtained node embeddings into a fully-connected neural network, and apply the element-wise max-pooling operation on all node embeddings.We did not find substantial performance improvement using mean-pooling.Sequence Decoding.The decoder is an RNN which predicts the next token y i given all the previous words y <i = y 1 , ..., y i−1 , the RNN hidden state s i for time-step i and the context vector c i that captures the attention of the encoder side.In particular, the context vector c i depends on a set of node representations (h 1 ,...,h V ) to which the encoder maps the input graph.The context vector c i is dynamically computed using an attention mechanism over the node representations.The whole model is jointly trained to maximize the conditional log-probability of the correct description given a source graph.In the inference phase, we use the beam search algorithm to generate a description with beam size = 3.

Experiments
We evaluate our model on three datasets: Jobs640, a set of 640 queries to a database of job listings; Geo880, a set of 880 queries to a database of U.S. geography; and ATIS, a set of 5,410 queries to a flight booking system.We use the standard train/development/test split as previous works, and the logical form accuracy as our evaluation metric.The model is trained using the Adam optimizer (Kingma and Ba, 2014), with mini-batch size 30.Our hyper-parameters are cross-validated on the training set for Jobs640 and Geo880, and tuned on the development set for ATIS.The learning rate is set to 0.001.The decoder has 1 layer, and its hidden state size is 300.The dropout strategy (Srivastava et al., 2014) with the ratio of 0.5 is applied at the decoder layer to avoid overfitting.W e is initialized using GloVe word vectors from Pennington et al. ( 2014) and the dimension of word embedding is 300.For the graph encoder, the hop size K is set to 10, the non-linearity function σ is implemented as ReLU (Glorot et al., 2011), the parameters of the aggregators are randomly initialized.We use the Stanford CoreNLP tool (Manning et al., 2014) to generate the dependency and constituent trees.
Results and Discussion.Table 1 summarizes the results of our model and existing semantic parsers on three datasets.Our model achieves competitive performance on Jobs640, ATIS and Geo880.Our work is the first to use both multiple trees and the word sequence for semantic parsing, and it outperforms the Seq2Seq model reported in Dong and Lapata (2016), which only uses limited syntactic information.
Comparison with Baseline.To better demonstrate that our work is an effective way to utilize both multiple trees and the word sequence for semantic parsing, we compare with an additional straightforward baseline method (referred as BASELINE in Table 1).To deal with the graph input, the BASELINE decomposes the graph embedding to two steps and applies different types of encoders sequentially: (1) a SeqLSTM to extract word order features, which results in word embeddings, W seq ; (2) two TreeLSTMs (Tai et al., 2015) to extract the dependency tree and constituency features while taking W seq as initial word embeddings.The resulted word embeddings and nonterminal node embeddings (from TreeLSTMs) are then fed into a sequence decoder.
We can see that our model significantly outperforms the BASELINE.One possible reason is that our graph encoder jointly extracts these features in a unified model by propagating the dependency and constituency information to all nodes in the syntactic graph.However, BASELINE separately models these features using two distinct TreeL-STMs.As a result, the non-terminal tree nodes only retain only one type of syntactic information propagated from their descendants in the tree.
Ablation Study.In Table 1, we also report the results of three ablation variants of our model, i.e., without word order features/dependency features/constituency features.
We find that Graph2Seq is superior to Seq2Seq (Dong and Lapata, 2016) which is expected since Graph2Seq exploits more syntactic information.Among these features, the word order feature have more impact on the performance than other two syntactic features.By incorporating either the dependency or the constituency features, the model could gain further performance improvement, which underlines the importance of utilizing more aspects of syntactic information.A natural question here is on which type of queries our model could benefit from incorporating these parse features?By analyzing the queries and our predicted logical forms, we find that the parse features mainly improve the prediction accuracy for the queries with complex logical forms.Table 2 gives some running examples of complicated queries in three datasets.We find that the model that exploits three syntactic information could correctly predict these logical forms while the model that only uses word order features may fail.
Complicated Query & Predicted Logical Forms Jobs Q: what are the jobs for programmer that has salary 50000 that uses c++ and not related with AI Pred: answer(J,(job(J),-((area(J,R),const(R,'ai'))), language(J,L),const(L,'c++'), title(J,P), const(P,'Programmer'),salary greater than(J, 50000,year)))).Geo Q: which is the density of the state that the largest river in the united states run through Pred: answer(A,(density(B,A),state(B), longest(C,(river(C),loc(C,D),const(D,id(usa)))), traverse(C,B)))) ATIS Q: please find a flight round trip from los angeles to tacoma washington with a stopover in san francisco not exceeding the price of 300 dollars for june tenth 1993 Pred: (lambda $0 e (and (flight $0) (round trip $0) (from $0 los angeles) (to $0 tacoma washington) Table 2: Examples of complicated query and predicted logical forms.

Robustness Study.
Different from previous works, we evaluate the robustness of our model by creating adversarial examples with the hope to investigate the impact of introducing more syntactic information on robustness.Specifically, we create two types of adversarial examples and conduct experiments on the ATIS dataset.Following Belinkov and Bisk (2017), we first experiment with the synthetic noise, SWAP, which swaps two letters (e.g.noise→nosie).It is common to see such noisy information when typing quickly.
Given a text, we randomly perform swap on m ∈ {1, 2, 3, 4, 5} words that not correspond to the operators or arguments in logical forms, ensuring the meaning of the text is not changed.We train Graph2Seq on the training data and first evaluate it on the original development data, Dev ori .Then we use the same model but evaluate it on a variant of Dev ori , whose queries contain m swapped words.
Figure 2 summarizes the results of our model on the first type of adversarial examples, i.e., the ATIS development set with the SWAP noise.From Figure 2, we can see that (1) the performance of our model on all combinations of features degrade significantly when increasing the number of swapped words; (2) the model that uses three syntactic features (our default model) always achieves the best performance, and the performance gap compared to others increases when rising the number of swapped words; (3) word order features are the most sensitive to the word sequence while the dependency and constituency features seem more robust to such noisy information; (4) thanks to the robustness of the dependency and constituency features, the default model performs significantly better than the one that only uses word order features on the noisy sentences.These findings demonstrate that incorporating more aspects of syntactic information could enhance the robustness of the model.We also experiment with the paraphrase of the input text as the second type of adversarial examples.More specifically, we collect the paraphrase of a text by first translating it to the other language such as Chinese and then translating it back to English, using the Google Translate service.We use this method to collect a new variant of Dev ori whose queries are the paraphrases of the original ones.By manually reading these queries, we find 94% queries convey the same meaning as original ones.Similar to the first experiment, we still train the model on Dev ori and evaluate it on the newly created dataset.Table 3 shows the results of our model on the second type of adversarial examples, i.e., the paraphrased ATIS development set.We also report the result of our model on the original ATIS development set.We can see that (1) no matter which feature our model uses, the performance degrades at least 2.5% on the paraphrased dataset; (2) the model that only uses word order features achieves the worst robustness to the paraphrased queries while the dependency feature seems more robust than other two features.(3) simultaneously utilizing three syntactic features could greatly enhance the robustness of our model.These results again demonstrate that our model could benefit from incorporating more aspects of syntactic information.

Related Work
Existing works of generating text representation has evolved into two main streams.The first one is based on the word order, that is, either generating general purpose and domain independent embeddings of word sequences (Wu et al., 2018a;Arora et al., 2017), or building Bi-directional LSTMs over the text (Zhang et al., 2018).These methods neglect other syntactic information, which, however, has been proved to be useful in shallow semantic parsing, e.g., semantic role labeling.To address this, recent works attempt to incorporate these syntactic information into the text representation.For example, (Su and Yan, 2017;Gur et al., 2018) leverages additional information such as dialogue and paraphrasing for semantic parsing while (Xu et al., 2016) builds separated neural networks for different types of syntactic annotation.(Gormley et al., 2015;Wu et al., 2018b) decompose a graph to simpler sub-graphs and embed these sub-graphs independently.

Conclusions
Existing neural semantic parsers mainly leverage word order features while neglecting other valuable syntactic information.To address this, we propose to build a syntactic graph which represents three types of syntactic information, and further apply a novel graph-to-sequence model to map the syntactic graph to a logical form.Experimental results show that the robustness of our model is improved due to the incorporating more aspects of syntactic information, and our model outperforms previous semantic parsing systems.

Figure 1 :
Figure1: The syntactic graph for the Jobs640 question what are the jobs for programmer that has salary 50000 that uses c++ and not related with AI.Due to the space limitation, the constituent tree is partially shown here.

Figure 2 :
Figure 2: The logical form accuracy on the development set of ATIS with various swapped words number.

Table 3 :
Evaluation results on ATIS where Accori and Accpara denote the accuracy on the original and paraphrased development set of ATIS, respectively.