Attention Interpretability Across NLP Tasks

Shikhar Vashishth, Shyam Upadhyay, Gaurav Singh Tomar, Manaal FaruquiarXiv 2019

Abstract

The attention layer in a neural network model provides insights into the model's reasoning behind its prediction, which are usually criticized for being opaque. Recently, seemingly contradictory viewpoints have emerged about the interpretability of attention weights (Jain & Wallace, 2019; Vig & Belinkov, 2019). Amid such confusion arises the need to understand attention mechanism more systematically. In this work, we attempt to fill this gap by giving a comprehensive explanation which justifies both kinds of observations (i.e., when is attention interpretable and when it is not). Through a series of experiments on diverse NLP tasks, we validate our observations and reinforce our claim of interpretability of attention through manual evaluation.

Introduction

In Natural Language Processing (NLP), the "Attention" mechanism has become ubiquitous for enhancing model performance. Historically, it was also viewed as a "window" into the neural network's decision-making process. However, recent research has challenged this, suggesting that attention weights can be manipulated without affecting model output, leading to the "Attention is not Explanation" debate. This paper reconciles these conflicting views by demonstrating that attention interpretability is fundamentally task-dependent.

The Problem: Conflicting Views on Interpretability

The research community was divided. One camp argued that attention weights are often arbitrary, as they can be replaced by random or uniform weights with minimal impact on performance in tasks like sentiment analysis. Conversely, another group found that attention captures sophisticated linguistic structures in tasks like machine translation.

The authors identify that these groups were studying different task categories: Single Sequence tasks (e.g., classification) versus Pair Sequence or Generation tasks (e.g., translation and inference). This work provides a unified theory explaining why attention serves different functional roles across these domains.

Methodology

To investigate the functional role of attention, the authors utilized:

  1. Performance Ablation: Comparing standard attention against Uniform, Random, or Permuted attention weights.
  2. Mathematical Analysis: Proposing that in single-sequence tasks, attention reduces to a simple "gating unit" that scales pre-existing signals in the hidden states.
  3. Feature Importance Correlation: Using Jensen-Shannon (JS) divergence to quantify how much output changes when high-attention words are removed.
  4. Human Evaluation: Auditing whether attended words align with human reasoning.

The study spanned multiple benchmarks, including SST and IMDB for classification, SNLI for inference, and Multi30k for translation.

Key Insights: Gating vs. Bridging

The study reveals a critical distinction in how attention functions:

  • The Gating Role: In simple classification, the RNN encoder hidden states already encapsulate the necessary sentiment or topic information. Attention merely acts as a filter or "gate" to pass this signal through. Consequently, replacing learned attention with a uniform average has negligible impact.
  • The Bridging Role: In complex tasks like Neural Machine Translation (NMT) or Natural Language Inference (NLI), the model must align two distinct sequences. Here, attention acts as a dynamic bridge. Scrambling this bridge destroys the model's ability to relate words across sequences, leading to catastrophic performance failure.
Comparison of attention necessity across Text Classification (a), NLI (b), and NMT (c). While uniform attention suffices for classification, it fails for relational tasks.

Results

The empirical results strongly support the task-dependency hypothesis. In text classification, switching to uniform attention resulted in a negligible relative performance decrease (approx. 0.1%). In stark contrast, the same change in NLI and NMT tasks caused massive performance drops of 49.5% and 51.2%, respectively.

Furthermore, while attention weights in classification often point to intuitive words, they are not functionally necessary for the model's success. In pairwise tasks, however, the attention-driven "reasoning" is both human-interpretable and essential for correct predictions.

Conclusion

This work clarifies the debate over attention as an explanation. Attention is not a monolithic mechanism; its interpretability and necessity are tied to the complexity of the task. While it may be a mere gating unit in simple classification, it remains a vital, interpretable component for tasks requiring relational reasoning. Future work will extend these findings to multi-layer self-attention architectures like Transformers, which appear to exhibit higher attention necessity even in simpler tasks.

Summary updated

BibTeX
@misc{vashishth2019attention,
  author = {Shikhar Vashishth and Shyam Upadhyay and Gaurav Singh Tomar and Manaal Faruqui},
  title = {{Attention Interpretability Across NLP Tasks}},
  year = {2019},
  eprint = {1909.11218},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1909.11218},
}
Figure