Rethinking Self-Attention: Towards Interpretability in Neural Parsing (2020)

Abstract: Attention mechanisms have improved the performance of NLP tasks while allowing models to remain explainable. Self-attention is currently widely used, however interpretability is difficult due to the numerous attention distributions. Recent work has shown that model representations can benefit from label-specific information, while facilitating interpretation of predictions. We introduce the Label Attention Layer: a new form of self-attention where attention heads represent labels. We test our novel layer by running constituency and dependency parsing experiments and show our new model obtains new state-of-the-art results for both tasks on both the Penn Treebank (PTB) and Chinese Treebank. Additionally, our model requires fewer self-attention layers compared to existing work. Finally, we find that the Label Attention heads learn relations between syntactic categories and show pathways to analyze errors.

## introduction attention mechanisms @xcite provide arguably explainable attention distributions that can help to interpret predictions. for example, for their machine translation predictions, @xcite show a heat map of attention weights from source language words to target language words. similarly, in transformer architectures @xcite , a selfattention head produces attention distributions from the input words to the same input words, as shown in the second row on the right side of figure 1 . however, self-attention mechanisms have multiple heads, making the combined outputs difficult to interpret. recent work in multi-label text classification @xcite and sequence labeling @xcite shows the efficiency and interpretability of label-specific representations. we introduce label attention head self-attention head q i w k x i w v x i a i repeated x select the person select the person matrix projection select the person from other heads w k x i w v x i a i select the person w q x i aggregating with output from other heads select the person matrix projection select the person select the person x select the person figure 1 : comparison of the attention head architectures of our proposed label attention layer and a self-attention layer @xcite . the matrix x represents the input sentence "select the person". the label attention layer: a modified version of self-attention, where each classification label corresponds to one or more attention heads. we project the output at the attention head level, rather than after aggregating all outputs, to preserve the source of head-specific information, thus allowing us to match labels to heads. to test our proposed label attention layer, we build upon the parser of @xcite and establish a new state of the art for both constituency and dependency parsing, in both english and chinese. we also release our pre-trained parsers, as well as our code to encourage experiments with the label attention layer foot_0 . ## label attention layer the self-attention mechanism of @xcite propagates information between the words of a sentence. each resulting word representation ## experiments we evaluate our model on the english penn treebank (ptb) @xcite and on the chinese treebank (ctb) @xcite . we use the stanford tagger @xcite to predict part-of-speech tags and follow standard data splits. following standard practice, we use the evalb algorithm @xcite for constituency parsing, and report results without punctuation for dependency parsing. ## related work since their introduction in machine translation, attention mechanisms @xcite have been extended to other tasks, such as text classification @xcite , natural language inference @xcite and language modeling @xcite . self-attention and transformer architectures @xcite are now the state of the art in language understanding @xcite , extractive summarization @xcite , semantic role labeling @xcite and machine translation for low-resource languages @xcite . while attention mechanisms can provide explanations for model predictions, @xcite challenge that assumption and find that attention weights only noisily predict overall importance with regard to the model. @xcite find that attention distributions rarely correlate with feature importance weights. however, @xcite show through alternative tests that prior work does not discredit the usefulness of attention for interpretability. @xcite introduce the label-specific attention network (lsan) for multi-label document classification. they use label descriptions to compute attention scores for words, and follow the self-attention of @xcite . @xcite introduce a label attention inference layer for sequence labeling, which uses the self-attention of @xcite . in this case, the key and value vectors are learned label embeddings, and the query vectors are hidden vectors obtained from a bi-lstm encoder. our work is unrelated to these two papers, as they were published towards the end of our project. ## conclusions in this paper, we introduce a new form of selfattention: the label attention layer. in our proposed architecture, attention heads represent labels. we incorporate our label attention layer into the hpsg parser @xcite and obtain new state-of-the-art results on the penn treebank and chinese treebank. in english, our results show 96.38 f1 for constituency parsing, and 97.42 uas and 96.26 las for dependency parsing. in chinese, our model achieves 92.64 f1, 94.56 uas and 89.28 las. we perform ablation studies that show the query vector learned by our label attention layer outperform the self-attention query matrix. since we have only one learned vector as query, rather than a matrix, we can significantly reduce the number of parameters per attention head. finally, our label attention heads learn the relations between the syntactic categories, as we show by computing contributions from each attention head to span vectors. we show how the heads also help to analyze prediction errors, and suggest methods to correct them.