Unveiling and Controlling Anomalous Attention Distribution in Transformers

Ruiqing Yan, Xingbo Du, Haoyu Deng, Linghan Zheng, Qiuzhuang Sun +5 more
6/26/2024
cs.LGcs.AI

No confident code implementation found for this paper.

Abstract

With the advent of large models based on the Transformer architecture, researchers have observed an anomalous phenomenon in the Attention mechanism--there is a very high attention on the first element, which is prevalent across Transformer-based models. It is crucial to understand it for the development of techniques focusing on attention distribution, such as Key-Value (KV) Cache compression and infinite extrapolation; however, the latent cause leaves to be unknown. In this paper, we analyze such a phenomenon from the perspective of waiver phenomenon, which involves reducing the internal values of certain elements in the sequence, allowing them to absorb excess attention without affecting their contribution to information. In specific models, due to differences in positional encoding and attention patterns, we have found that the selection of waiver elements by the model can be categorized into two methods: positional-encoding-based and feature-distribution-within-elements-based.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yan2024unveiling,
  title  = {Unveiling and Controlling Anomalous Attention Distribution in Transformers},
  author = {Ruiqing Yan and Xingbo Du and Haoyu Deng and Linghan Zheng and Qiuzhuang Sun and Jifang Hu and Yuhang Shao and Penghao Jiang and Jinrong Jiang and Lian Zhao},
  year   = {2024},
  eprint = {2407.01601},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.01601v2}
}

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

Discussion