Extracting Syntactic Trees from Transformer Encoder Self-Attentions

34199

Authors

nan

Abstract

AbstractThis is a work in progress about extracting the sentence tree structures from the encoder’s self-attention weights, when translating into another language using the Transformer neural network architecture. We visualize the structures and discuss their characteristics with respect to the existing syntactic theories and annotations.

Keywords

nan

Full Content

Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 347–349 Brussels, Belgium, November 1, 2018. c⃝2018 Association for Computational Linguistics 347 Extracting Syntactic Trees from Transformer Encoder Self-Attentions David Mareˇcek and Rudolf Rosa Institute of Formal and Applied Linguistics Faculty of Mathematics and Physics Charles University, Prague, Czechia {marecek,rosa}@ufal.mff.cuni.cz 1 Introduction Interpreting neural networks is a popular topic, and there are many works focusing on analyz- ing networks with respect to learning syntax (Shi et al., 2016; Linzen et al., 2016; Blevins et al., 2018). In particular, Vaswani et al. (2017) showed that the self-attentions in their Transformer architec- ture may be directly interpreted as syntactic de- pendencies between tokens. However, there is a potential problem in the fact that the atten- tion mechanism on deeper layers operates on the previous-layer neurons, which already comprise mixed information from multiple source tokens. Our goal is to infer source sentence tree struc- tures form the encoder’s self-attention energies used in the Transfomer neural machine translation (NMT) system. We would like to visualize how the self-attention mechanism connects individual words (or wordpieces) of the sentence, to cre- ate various tree structures (e.g. constituency trees, undirected trees, dependency trees), and to discuss their characteristics with respect to the existing syntactic theories and annotations. We would also like to discuss results across various languages and natural language processing (NLP) tasks. In this abstract, we present our preliminary re- sults, analyzing the encoder in English-to-German NMT within the NeuralMonkey toolkit (Helcl and Libovick´y, 2017). We introduce aggregation of self-attention through layers to get a distribution over the input tokens for each encoder position and layer (Section 2). We then propose algorithms for constructing two types of syntactic trees (Sec- tions 3 and 4), apply them to 42 sentences sampled from PennTB (Marcus et al., 1993), and compare the resulting structures to established syntax anno- tation styles, such as that of PennTB, UD (Nivre et al., 2016), or PDT (B¨ohmov´a et al., 2003). as_ a_ result_ ,_ the_ link_ between_ the_ futur es_ and_ stock_ markets_ rip ped_ apart_ ._ as_ a_ result_ ,_ the_ link_ between_ the_ futur es_ and_ stock_ markets_ rip ped_ apart_ ._ Figure 1: Aggregated encoder’s self-attentions after the 6th layer. Each column contains a distribution over the source wordpieces for one encoder position. 2 Aggregated self-attention visualization We use the default setting: encoder is composed of 6 layers, each consisting of a 16-head self- attention mechanism and a fully connected feed- forward network, both bridged by residual connec- tions. Each position in one layer can attend to all positions in the previous layer; the attention to the same position is boosted by the residual connec- tion. When translating a single sentence by Trans- former, we would like to capture how much each input token affects each particular position on each layer in the encoder. This is done by aggregating the attention distributions through the layers. For each layer, we collect the self-attention distribu- tion to …

Content truncated to 500 words

Labeled Text

AbstractThis is a work in progress about extracting the sentence tree structures from the encoder’s self-attention weights, when translating into another language using the Transformer neural network architecture. We visualize the structures and discuss their characteristics with respect to the existing syntactic theories and annotations.

Publication Details

Paper ID:
34199
Year:
2018
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan