Arxiv:1911.03561V4 [Cs.CL] 30 Oct 2020 Dings Are Input to Each Vector in the Set, but Recently a by the Previous Decisions

Arxiv:1911.03561V4 [Cs.CL] 30 Oct 2020 Dings Are Input to Each Vector in the Set, but Recently a by the Previous Decisions

Graph-to-Graph Transformer for Transition-based Dependency Parsing Alireza Mohammadshahi Idiap Research Institute and EPFL / Switzerland James Henderson Idiap Research Institute / Switzerland falireza.mohammadshahi, [email protected] Abstract Graph2Graph Transformer. This mechanism for conditioning on graphs differs from previous pro- We propose the Graph2Graph Transformer posals in that it inputs graph relations as continuous architecture for conditioning on and predicting arbitrary graphs, and apply it to the challenging embeddings, instead of discrete model structure (e.g. task of transition-based dependency parsing. (Henderson, 2003; Henderson et al., 2013; Dyer After proposing two novel Transformer models et al., 2015)) or predefined discrete attention of transition-based dependency parsing as heads (e.g. (Ji et al., 2019; Strubell et al., 2018)). strong baselines, we show that adding the An explicit representation of binary relations is sup- proposed mechanisms for conditioning on ported by inputting these relation embeddings to the and predicting graphs of Graph2Graph Trans- attention functions, which are applied to every pair former results in significant improvements, both with and without BERT pre-training. of tokens. In this way, each attention head can easily The novel baselines and their integration learn to attend only to tokens in a given relation, but with Graph2Graph Transformer significantly it can also learn other structures in combination with outperform the state-of-the-art in traditional other inputs. This gives a bias towards attention transition-based dependency parsing on weights which respect locality in the input graph but both English Penn Treebank, and 13 lan- does not hard-code any specific attention weights. guages of Universal Dependencies Treebanks. Graph2Graph Transformer can be integrated We focus our investigation on this novel graph with many previous structured prediction input method and therefore limit our investigation methods, making it easy to apply to a wide to models which predict the output graph one range of NLP tasks. edge at a time, in an auto-regressive fashion. In auto-regressive structured prediction, after each 1 Introduction edge of the graph has been predicted, the model In recent years, there has been a huge amount of must condition on the partially specified graph research on applying self-attention models to NLP to predict the next edge of the graph. Thus, our tasks. Transformer (Vaswani et al., 2017) is the most proposed Graph2Graph Transformer parser is common architecture, which can capture long-range a transition-based dependency parser. At each dependencies by using a self-attention mechanism step, the model predicts the next parsing decision, over a set of vectors. To encode the sequential struc- and thereby the next dependency relation, by ture of sentences, typically absolute position embed- conditioning on the partial parse structure specified arXiv:1911.03561v4 [cs.CL] 30 Oct 2020 dings are input to each vector in the set, but recently a by the previous decisions. It inputs embeddings mechanism has been proposed for inputting relative for the previously specified dependency relations positions (Shaw et al., 2018). For each pair of vec- into the Graph2Graph Transformer model via tors, an embedding for their relative position is input the self-attention mechanism. It predicts the next to the self-attention function. This mechanism can dependency relation using only the vectors for the be generalised to input arbitrary graphs of relations. tokens involved in that relation. We propose a version of the Transformer To evaluate this architecture, we also propose two architecture which combines this attention-based novel Transformer models of transition-based de- mechanism for conditioning on graphs with an pendency parsing, called Sentence Transformer, and attention-like mechanism for predicting graphs State Transformer. Sentence Transformer computes and demonstrate its effectiveness on syntactic contextualised embeddings for each token of the in- dependency parsing. We call this architecture put sentence and then uses the current parser state to identify which tokens could be involved in the next non-projective dependency trees, we allow the valid parse transition and uses their contextualised SWAP action proposed in Nivre(2009), which shifts embeddings to choose the best transition. For State the second-from-top element of the stack to the Transformer, we directly use the current parser state front of the buffer, resulting in the reordering of the as the input to the model, along with an encoding top two elements of the stack. of the partially constructed parse graph, and choose the best transition using the embeddings of the 3 Graph2Graph Transformer tokens involved in that transition. Both baseline We propose a version of the Transformer which models achieve competitive or better results than is designed for both conditioning on graphs and previous state-of-the-art traditional transition-based predicting graphs, which we call Graph2Graph models, but we still get substantial improvement by Transformer (G2GTr), and show how it can be integrating Graph2Graph Transformer with them. applied to transition-based dependency parsing. We also demonstrate that, despite the modified G2GTr supports arbitrary input graphs and arbitrary input mechanisms, this Graph2Graph Transformer edges in the output graph. But since the nodes of architecture can be effectively initialised with stan- both these graphs are the input tokens, the nodes dard pre-trained Transformer models. Initialising of the output graph are limited to the set of nodes the Graph2Graph Transformer parser with pre- in the input graph. trained BERT (Devlin et al., 2018) parameters leads Inspired by the relative position embeddings of to substantial improvements. The resulting model Shaw et al.(2018), we use the attention mechanism significantly improves over the state-of-the-art in of Transformer to input arbitrary graph relations. traditional transition-based dependency parsing. By inputting the embedding for a relation label into This success demonstrates the effectiveness of the attention functions for the related tokens, the Graph2Graph Transformers for conditioning on model can more easily learn to pass information and predicting graph relations. This architecture between graph-local tokens, which gives the model can be easily applied to other NLP tasks that have an appropriate linguistic bias, without imposing any graph as the input and need to predict a graph hard constraints. over the same set of nodes as output. Given that the attention function is being used In summary, our contributions are: to input graph relations, it is natural to assume • We propose Graph2Graph Transformer for that graph relations can also be predicted with an conditioning on and predicting graphs. attention-like function. We do not go so far as to • We propose two novel Transformer models of restrict the form of the prediction function, but we transition-based dependency parsing. do restrict the vectors used to predict graph relations • We successfully integrate pre-trained BERT to only the tokens involved in the relation. initialisation in Graph2Graph Transformer. • We improve state-of-the-art accuracies for tra- 3.1 Original Transformer ditional transition-based dependency parsing.1 Transformer (Vaswani et al., 2017) is an encoder- 2 Transition-based Dependency Parsing decoder model, of which we only use the encoder component. A Transformer encoder computes Our transition-based parser uses arc-standard an output embedding for each token in the input parsing sequences (Nivre, 2004), which makes sequence through stacked layers of multi-head parsing decisions in bottom-up order. The main self-attention. Each attention head takes its input data structures for representing the state of an vectors (x1;:::;xn) and computes its output attention m arc-standard parser are a buffer of words and a stack vectors (z1;:::;zn). Each zi 2R is a weighted sum m of partially constructed syntactic sub-trees. At each of transformed input vectors xj 2R : step, the parser chooses between adding a leftward X V or rightward labelled arc between the top two words zi = αij(xjW ) (1) on the stack (LEFT-ARC(l) or RIGHT-ARC(l), j where l is a dependency label) or shifting a word exp(eij ) with the attention weights αij = Pn exp(e ) and from the buffer onto the stack (SHIFT). To handle k=1 ik Q K 1Our implementation is available at: https: (xiW )(xjW ) eij = p (2) //github.com/alirezamshi/G2GTr d Prev. action Graph Input(G) Update State Graph Input(G) Prev. action Graph Output Mechanism Graph Output Mechanism S S B B CLS ... S3 S2 S1 SEP B1 B2 B3 ... SEP D1 D2 D3 ... ... 2 1 1 2 ... History Stack Buffer Model ht ... ... ... ... ... ... ... ht-1 CLS ROOT W1 W2 W3 ... SEP LSTM ct-1 ... ... ... ... ... CLS ... S3 S2 S1 SEP B1 B2 B3 ... SEP D1 D2 D3 ... CLS ROOT W1 W2 W3 ... SEP (Composition Model) Input Embeddings Input Embeddings Parser State Input Sentence:W1,W2,W3,... Update State (a) StateTr+G2GTr. (b) SentTr+G2GTr. Figure 1: The State Transformer and Sentence Transformer parsers with Graph-to-Graph Transformer integrated. where W V ; W Q; W K 2 Rm×d are the trained graph using the output embeddings of the tokens value, query and key matrices, m is the embedding that are connected by that edge. Because in this size, and d is the attention head size. work we are investigating auto-regressive models, this prediction is done one edge at a time. See 3.2 Graph

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 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