主动睡眠的注意力头:LLM中的极端令牌现象的机械解密
Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMs
摘要:
实践者一直在基于transformer的大语言模型(LLM)中观察到三个令人困惑的现象:注意力下沉,值状态流失和剩余状态峰值,统称为极端令牌现象。这些现象的特点是某些所谓的“汇令牌”接收不成比例的高关注权重,表现出显着较小的价值状态,并具有更大的剩余状态规范比其他令牌。这些极端的标记在LLM推理、量化和可解释性方面带来了各种挑战。我们阐明了极端令牌现象背后的机制。首先,我们证明了这些现象出现在非常简单的架构中--具有一到三层的Transformers--在玩具模型上训练,即Bigram Backcopy(BB)任务。在这种情况下,我们确定了一个活跃的休眠机制,注意头成为特定输入域的水槽,而其他人保持非水槽。我们对训练动力学的理论分析表明,这些现象是由一种相互强化的机制驱动的。基于这些见解,我们提出了在预训练期间减轻极端令牌现象的策略,包括用ReLU替换softmax,用SGD替换Adam。接下来,我们将我们的分析扩展到预训练的LLM,包括Llama和OLMo,表明许多注意力头表现出与BB任务相似的活跃-休眠机制,并且相互强化机制也控制了LLM预训练期间极端令牌现象的出现。我们的研究结果表明,BB任务预测的极端令牌现象的许多静态和动态特性与预先训练的LLM中的观察结果一致。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。