SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.13835 · 2024

Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMs

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 6 functions out of this paper's own repositories and ran 1 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
guotianyu2000/active-dormant-attention canonical 1 of 6
FunctionStatusWhere it lives
float_to_str Ran guotianyu2000/active-dormant-attention/BBM/data.py
pointer only (licence: NONE) · get_code("bf01551b400630d4")
add_training_info Not yet run guotianyu2000/active-dormant-attention/BBM/probe_utils.py
pointer only (licence: NONE) · get_code("078d3b529478aba7")
get_model_name Not yet run guotianyu2000/active-dormant-attention/BBM/probe_utils.py
pointer only (licence: NONE) · get_code("a8e3f941e9a634be")
make_dataset Not yet run guotianyu2000/active-dormant-attention/BBM/data.py
pointer only (licence: NONE) · get_code("3368d9b6e37f4dca")
make_dataset_old Not yet run guotianyu2000/active-dormant-attention/BBM/data.py
pointer only (licence: NONE) · get_code("87bf5b2f48be9d8b")
plot_attns Not yet run guotianyu2000/active-dormant-attention/BBM/probe_utils.py
pointer only (licence: NONE) · get_code("3665aa821f95e5f1")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Practitioners have consistently observed three puzzling phenomena in transformer-based large language models (LLMs): attention sinks, value-state drains, and residual-state peaks, collectively referred to as extreme-token phenomena. These phenomena are characterized by certain so-called "sink tokens" receiving disproportionately high attention weights, exhibiting significantly smaller value states, and having much larger residual-state norms than those of other tokens. These extreme tokens give rise to various challenges in LLM inference, quantization, and interpretability. We elucidate the mechanisms behind extreme-token phenomena. First, we show that these phenomena arise in very simple architectures -- transformers with one to three layers -- trained on a toy model, the Bigram-Backcopy (BB) task. In this setting, we identify an active-dormant mechanism, where attention heads become sinks for specific input domains while remaining non-sinks for others. Our theoretical analysis of the training dynamics reveals that these phenomena are driven by a mutual reinforcement mechanism. Building on these insights, we propose strategies to mitigate extreme-token phenomena during pretraining, including replacing softmax with ReLU and Adam with SGD. Next, we extend our analysis to pretrained LLMs, including Llama and OLMo, showing that many attention heads exhibit a similar active-dormant mechanism as in the BB task, and that the mutual reinforcement mechanism also governs the emergence of extreme-token phenomena during LLM pretraining. Our results reveal that many of the static and dynamic properties of extreme-token phenomena predicted by the BB task align with observations in pretrained LLMs.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2410.13835")
get_code_for_paper("2410.13835")
have("2410.13835")

Connect an agent — have() is free.