CLAILGOct 14, 2024

When Attention Sink Emerges in Language Models: An Empirical View

arXiv:2410.10781v2160 citationsh-index: 41Has CodeICLR
Originality Incremental advance
AI Analysis

This addresses a fundamental phenomenon in language models that impacts applications like streaming generation and inference optimization, but it is incremental as it builds on known observations to provide deeper empirical insights.

The study investigates the emergence of attention sink in language models, where models assign significant attention to the first token regardless of its semantic importance, and finds that it arises from optimization on sufficient data and is linked to softmax normalization, with removal possible by using alternative attention mechanisms like sigmoid attention in models up to 1B parameters.

Language Models (LMs) assign significant attention to the first token, even if it is not semantically important, which is known as attention sink. This phenomenon has been widely adopted in applications such as streaming/long context generation, KV cache optimization, inference acceleration, model quantization, and others. Despite its widespread use, a deep understanding of attention sink in LMs is still lacking. In this work, we first demonstrate that attention sinks exist universally in LMs with various inputs, even in small models. Furthermore, attention sink is observed to emerge during the LM pre-training, motivating us to investigate how optimization, data distribution, loss function, and model architecture in LM pre-training influence its emergence. We highlight that attention sink emerges after effective optimization on sufficient training data. The sink position is highly correlated with the loss function and data distribution. Most importantly, we find that attention sink acts more like key biases, storing extra attention scores, which could be non-informative and not contribute to the value computation. We also observe that this phenomenon (at least partially) stems from tokens' inner dependence on attention scores as a result of softmax normalization. After relaxing such dependence by replacing softmax attention with other attention operations, such as sigmoid attention without normalization, attention sinks do not emerge in LMs up to 1B parameters. The code is available at https://github.com/sail-sg/Attention-Sink.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes