Measuring the Mixing of Contextual Information in the Transformer

Javier Ferrando, Gerard I. Gállego, Marta R. Costa-jussà
3/8/2022
125 citations
cs.CL
transformer-attention

Official code: mt-upc/transformer-contributions (35 stars, Jupyter Notebook, Apache-2.0, last commit 2023-05-27).

Abstract

The Transformer architecture aggregates input information through the self-attention mechanism, but there is no clear understanding of how this information is mixed across the entire model. Additionally, recent works have demonstrated that attention weights alone are not enough to describe the flow of information.

Show full abstract

In this paper, we consider the whole attention block -- multi-head attention, residual connection, and layer normalization -- and define a metric to measure token-to-token interactions within each layer. Then, we aggregate layer-wise interpretations to provide input attribution scores for model predictions. Experimentally, we show that our method, ALTI (Aggregation of Layer-wise Token-to-token Interactions), provides more faithful explanations and increased robustness than gradient-based methods.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Measuring the Mixing of Contextual Information in the Transformer

356Jupyter Notebook, PythonJan 26, 20223 years agoApache-2.0

Similar Papers

Cite this paper

@article{ferrando2022measuring,
  title  = {Measuring the Mixing of Contextual Information in the Transformer},
  author = {Javier Ferrando and Gerard I. Gállego and Marta R. Costa-jussà},
  year   = {2022},
  eprint = {2203.04212},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.04212}
}

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

Discussion