How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representations

Betty van Aken, Benjamin Winter, Alexander Löser, Felix A. Gers
9/11/2019
cs.CLcs.IR

Official code: bvanaken/explain-BERT-QA (32 stars, Apache-2.0, last commit 2023-06-12).

Abstract

Bidirectional Encoder Representations from Transformers (BERT) reach state-of-the-art results in a variety of Natural Language Processing tasks. However, understanding of their internal functioning is still insufficient and unsatisfactory. In order to better understand BERT and other Transformer-based models, we present a layer-wise analysis of BERT's hidden states. Unlike previous research, which mainly focuses on explaining Transformer models by their attention weights, we argue that hidden states contain equally valuable information. Specifically, our analysis focuses on models fine-tuned on the task of Question Answering (QA) as an example of a complex downstream task. We inspect how QA models transform token vectors in order to find the correct answer. To this end, we apply a set of general and QA-specific probing tasks that reveal the information stored in each representation layer. Our qualitative analysis of hidden state visualizations provides additional insights into BERT's reasoning process. Our results show that the transformations within BERT go through phases that are related to traditional pipeline tasks. The system can therefore implicitly incorporate task-specific information into its token representations. Furthermore, our analysis reveals that fine-tuning has little impact on the models' semantic abilities and that prediction errors can be recognized in the vector representations of even early layers.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Code for the CIKM 2019 Paper: How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representations

329PythonAug 26, 20193 years agoApache-2.0

Similar Papers

Cite this paper

@article{aken2019does,
  title  = {How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representations},
  author = {Betty van Aken and Benjamin Winter and Alexander Löser and Felix A. Gers},
  year   = {2019},
  eprint = {1909.04925},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1909.04925}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1909.04925.svg)](https://codeofpaper.com/paper/1909.04925)

Discussion