Skip to main content
QUICK REVIEW

[Paper Review] Whatcha lookin' at? DeepLIFTing BERT's Attention in Question Answering

Ekaterina Arkhangelskaia, Sourav Dutta|arXiv (Cornell University)|Oct 14, 2019
Topic ModelingComputer Science17 references6 citations
TL;DR

This paper uses DeepLIFT to interpret BERT's multi-head attention mechanisms in question-answering, revealing how attention shifts from syntactic structures in early layers to answer-relevant tokens in deeper layers. It demonstrates that BERT progressively narrows focus from general input features to precise answer spans, mimicking human-like reasoning patterns through layer-wise attention clustering and attribution analysis.

ABSTRACT

There has been great success recently in tackling challenging NLP tasks by neural networks which have been pre-trained and fine-tuned on large amounts of task data. In this paper, we investigate one such model, BERT for question-answering, with the aim to analyze why it is able to achieve significantly better results than other models. We run DeepLIFT on the model predictions and test the outcomes to monitor shift in the attention values for input. We also cluster the results to analyze any possible patterns similar to human reasoning depending on the kind of input paragraph and question the model is trying to answer.

Motivation & Objective

  • To investigate how BERT's multi-head attention mechanism contributes to high performance in question-answering tasks.
  • To analyze the shift in attention values across BERT's layers using DeepLIFT for interpretability.
  • To detect patterns in attention behavior that resemble human reasoning by clustering attention representations.
  • To understand how BERT localizes relevant information in context for answer prediction.
  • To provide insight into why pre-trained transformers like BERT outperform previous models in NLP benchmarks.

Proposed method

  • Fine-tuned BERT-base on the SQuaD 2.0 dataset for question-answering with [CLS]question[SEP]paragraph[SEP] tokenization.
  • Applied DeepLIFT to backpropagate attribution scores from the final prediction layer to input tokens, assigning positive or negative contributions.
  • Modified DeepLIFT’s backward pass to handle BERT’s complex multi-headed, multi-layer attention modules due to PyTorch limitations.
  • Extracted attention scores per layer and used clustering to group similar attention patterns across different input types.
  • Visualized attention shifts using color-coded tokens, where red indicates high attention and blue low attention.
  • Focused on start and end token predictions as target neurons for attribution, using highest probability spans as reference.

Experimental results

Research questions

  • RQ1How does BERT’s attention evolve across layers during question-answering inference?
  • RQ2Which input tokens receive the highest attention in early versus late layers, and how does this relate to answer prediction?
  • RQ3Do attention patterns across different input types cluster into distinct groups that reflect reasoning-like behavior?
  • RQ4To what extent do attention heads in BERT attend to syntactic, semantic, or structural cues such as punctuation and delimiters?
  • RQ5How do attention shifts correlate with human-like reasoning in question-answering tasks?

Key findings

  • In early layers, BERT primarily attends to separator tokens [CLS], [SEP], and punctuation, indicating early syntactic processing.
  • By layer 4, attention shifts to question keywords such as 'beyonce', which are then completely ignored from layer 5 onward, suggesting dynamic focus.
  • In deeper layers, attention re-focuses on question keywords like 'beyonce' to semantically verify answer context, indicating a two-phase reasoning process.
  • In the final layer, attention is fully concentrated on the answer span 'late 1990s', demonstrating a narrowing of focus to the correct answer.
  • Attention patterns cluster into distinct groups based on question type, with consistent shifts from syntactic to semantic focus across different input types.
  • The model’s attention behavior reveals a progression from syntactic structure awareness to semantic verification, resembling human reasoning in question-answering.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.