When Attention Sink Emerges in Language Models: An Empirical View

Xiangming Gu, Tianyu Pang, Chao Du, Qian Liu, Fengzhuo Zhang, Cunxiao Du, Ye Wang, Min Lin

arXiv:2410.10781 · 2026-07-27 공개 · arXiv · PDF

language-models pre-training model-architecture training-data loss-function data-distribution attention-sink softmax-normalization

Abstract

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.

한국어 요약

한 줄 요약

언어 모델에서 첫 번째 토큰에 과도한 어텐션(attention sink)이 발생하는 현상을 실증적으로 분석하고, 이 현상이 학습 과정과 어텐션 구조에 어떻게 영향을 받는지 밝힌다.

핵심 기여도

핵심 아이디어

기존 연구는 attention sink가 첫 번째 토큰의 큰 임베딩 norm 때문이라고 주장했지만, 본 연구는 이 현상이 softmax 정규화와 학습 데이터의 분포, 손실 함수 등 pre-training 과정의 요소들과 밀접하게 관련되어 있음을 밝혔다. 특히, 첫 번째 토큰이 query와 key 간의 각도가 작아지면서 어텐션이 집중되는 현상을 관찰했으며, 이는 key bias처럼 작동함을 확인했다. 또한, softmax 대신 정규화 없는 sigmoid attention을 사용하면 attention sink가 발생하지 않는다는 점에서, 이 현상이 정규화에 의한 토큰 간 의존성에서 비롯된다는 통찰을 제시한다.

기술적 접근법

주요 결과

의의 및 한계

본 연구는 attention sink가 단순한 임베딩 norm의 결과가 아니라, 학습 과정과 어텐션 구조의 복합적 상호작용에서 비롯된다는 새로운 통찰을 제시한다. 이는 모델 최적화, 추론 가속화, KV 캐시 최적화 등 여러 응용 분야에 실질적 도움을 줄 수 있다. 그러나 실험은 1B 파라미터 이하 모델에만 적용되었으며, 더 큰 모델에서의 일반화 가능성은 명시되지 않음. 또한, attention sink가 모델 성능에 미치는 영향은 명확히 분석되지 않았다.

실용적 활용