arXiv(opens in a new tab)Computer ScienceFeb 2019Cited by 6 papers on PaperVantage

Manuscript Offprint

arXiv:1902.10186

Attention is not Explanation

Sarthak Jain, Byron C. Wallace

Abstract

Attention mechanisms have seen wide adoption in neural NLP models. In addition to improving predictive performance, these are often touted as affording transparency: models equipped with attention provide a distribution over attended-to input units, and this is often presented (at least implicitly) as communicating the relative importance of inputs. However, it is unclear what relationship exists between attention weights and model outputs. In this work we perform extensive experiments across a variety of NLP tasks that aim to assess the degree to which attention weights provide meaningful “explanations" for predictions. We find that they largely do not. For example, learned attention weights are frequently uncorrelated with gradient-based measures of feature importance, and one can identify very different attention distributions that nonetheless yield equivalent predictions. Our findings show that standard attention modules do not provide meaningful explanations and should not be treated as though they do. Code to reproduce all experiments is available at https://github.com/successar/AttentionExplanation.

1 Introduction and Motivation

Attention mechanisms bahdanau2014neural induce conditional distributions over input units to compose a weighted context vector for downstream modules. These are now a near-ubiquitous component of neural NLP architectures. Attention weights are often claimed (implicitly or explicitly) to afford insights into the “inner-workings” of models: for a given output one can inspect the inputs to which the model assigned large attention weights. Li et al. li2016understanding summarized this commonly held view in NLP: “Attention provides an important way to explain the workings of neural models". Indeed, claims that attention provides interpretability are common in the literature, e.g., xu2015show; choi2016retain; lei2017interpretable; martins2016softmax; xie2017interpretable; mullenbach2018explainable.

Figure

Figure 1: Heatmap of attention weights induced over a negative movie review. We show observed model attention (left) and an adversarially constructed set of attention weights (right). Despite being quite dissimilar, these both yield effectively the same prediction (0.01).

Implicit in this is the assumption that the inputs (e.g., words) accorded high attention weights are responsible for model outputs. But as far as we are aware, this assumption has not been formally evaluated. Here we empirically investigate the relationship between attention weights, inputs, and outputs.

Assuming attention provides a faithful explanation for model predictions, we might expect the following properties to hold. (i) Attention weights should correlate with feature importance measures (e.g., gradient-based measures); (ii) Alternative (or counterfactual) attention weight configurations ought to yield corresponding changes in prediction (and if they do not then are equally plausible as explanations). We report that neither property is consistently observed by a BiLSTM with a standard attention mechanism in the context of text classification, question answering (QA), and Natural Language Inference (NLI) tasks.

Consider Figure 1. The left panel shows the original attention distribution α\alpha over the words of a particular movie review using a standard attentive BiLSTM architecture for sentiment analysis. It is tempting to conclude from this that the token waste is largely responsible for the model coming to its disposition of ‘negative’ (y^=0.01\hat{y}=0.01). But one can construct an alternative attention distribution α~\tilde{\alpha} (right panel) that attends to entirely different tokens yet yields an essentially identical prediction (holding all other parameters of ff, θ\theta, constant).

Such counterfactual distributions imply that explaining the original prediction by highlighting attended-to tokens is misleading. One may, e.g., now conclude from the right panel that model output was due primarily to was; but both waste and was cannot simultaneously be responsible. Further, the attention weights in this case correlate only weakly with gradient-based measures of feature importance (τg=0.29\tau_{g}=0.29). And arbitrarily permuting the entries in α\alpha yields a median output difference of 0.006 with the original prediction.

These and similar findings call into question the view that attention provides meaningful insight into model predictions, at least for RNN-based models. We thus caution against using attention weights to highlight input tokens “responsible for” model outputs and constructing just-so stories on this basis.

Research questions and contributions. We examine the extent to which the (often implicit) narrative that attention provides model transparency lipton2016mythos. We are specifically interested in whether attention weights indicate why a model made the prediction that it did. This is sometimes called faithful explanation ross2017right. We investigate whether this holds across tasks by exploring the following empirical questions.

  1. To what extent do induced attention weights correlate with measures of feature importance – specifically, those resulting from gradients and leave-one-out (LOO) methods?
  2. Would alternative attention weights (and hence distinct heatmaps/“explanations”) necessarily yield different predictions?

Our findings for attention weights in recurrent (BiLSTM) encoders with respect to these questions are summarized as follows: (1) Only weakly and inconsistently, and, (2) No; it is very often possible to construct adversarial attention distributions that yield effectively equivalent predictions as when using the originally induced attention weights, despite attending to entirely different input features. Even more strikingly, randomly permuting attention weights often induces only minimal changes in output. By contrast, attention weights in simple, feedforward (weighted average) encoders enjoy better behaviors with respect to these criteria.