The heads hypothesis: A unifying statistical approach towards understanding multi-headed attention in BERT

Madhura Pande, Aakriti Budhraja, Preksha Nema, Pratyush Kumar, Mitesh M. Khapra
1/22/2021
cs.CLcs.AI
transformer-attention

Official code: iitmnlp/heads-hypothesis (9 stars, Jupyter Notebook, last commit 2021-03-11).

Abstract

Multi-headed attention heads are a mainstay in transformer-based models. Different methods have been proposed to classify the role of each attention head based on the relations between tokens which have high pair-wise attention.

Show full abstract

These roles include syntactic (tokens with some syntactic relation), local (nearby tokens), block (tokens in the same sentence) and delimiter (the special [CLS], [SEP] tokens). There are two main challenges with existing methods for classification: (a) there are no standard scores across studies or across functional roles, and (b) these scores are often average quantities measured across sentences without capturing statistical significance. In this work, we formalize a simple yet effective score that generalizes to all the roles of attention heads and employs hypothesis testing on this score for robust inference. This provides us the right lens to systematically analyze attention heads and confidently comment on many commonly posed questions on analyzing the BERT model. In particular, we comment on the co-location of multiple functional roles in the same attention head, the distribution of attention heads across layers, and effect of fine-tuning for specific NLP tasks on these functional roles.

View on arXivView PDF

Code Implementations(1)

This repository contains the code for the statistical analysis work for labelling heads.

91Jupyter Notebook, PythonDec 15, 20205 years ago

Similar Papers

Cite this paper

@article{pande2021heads,
  title  = {The heads hypothesis: A unifying statistical approach towards understanding multi-headed attention in BERT},
  author = {Madhura Pande and Aakriti Budhraja and Preksha Nema and Pratyush Kumar and Mitesh M. Khapra},
  year   = {2021},
  eprint = {2101.09115},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2101.09115}
}

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/2101.09115.svg)](https://codeofpaper.com/paper/2101.09115)

Discussion