Attention is Not All You Need: Pure Attention Loses Rank Doubly Exponentially with Depth

Yihe Dong, Jean-Baptiste Cordonnier, Andreas Loukas
3/5/2021
cs.LG
transformer-attention

Official code: twistedcubic/attention-rank-collapse (173 stars, Jupyter Notebook, Apache-2.0, last commit 2021-03-08).

Abstract

Attention-based architectures have become ubiquitous in machine learning, yet our understanding of the reasons for their effectiveness remains limited. This work proposes a new way to understand self-attention networks: we show that their output can be decomposed into a sum of smaller terms, each involving the operation of a sequence of attention heads across layers.

Show full abstract

Using this decomposition, we prove that self-attention possesses a strong inductive bias towards "token uniformity". Specifically, without skip connections or multi-layer perceptrons (MLPs), the output converges doubly exponentially to a rank-1 matrix. On the other hand, skip connections and MLPs stop the output from degeneration. Our experiments verify the identified convergence phenomena on different variants of standard transformer architectures.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[ICML 2021 Oral] We show pure attention suffers rank collapse, and how different mechanisms combat it.

17311Jupyter Notebook, PythonMar 3, 20215 years agoApache-2.0

Similar Papers

Cite this paper

@article{dong2021attention,
  title  = {Attention is Not All You Need: Pure Attention Loses Rank Doubly Exponentially with Depth},
  author = {Yihe Dong and Jean-Baptiste Cordonnier and Andreas Loukas},
  year   = {2021},
  eprint = {2103.03404},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2103.03404}
}

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

Discussion