arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.13314cs.LG
收藏

大语言模型中注意力头的线性可预测性

Linear Predictability of Attention Heads in Large Language Models

Georgia Institute of Technology(佐治亚理工学院);Santa Clara University(圣克拉拉大学)

Khalid Shaikh, Asmit Kumar Singh, Rebecca Christopher Dsouza, Shikhar Shiromani

AI总结:

研究发现预训练Transformer中注意力头激活存在线性结构,通过少量参考头可高精度重建目标头,利用此特性可减少KV缓存并提升效率。

摘要:

大语言模型(LLM)推理日益受到键值(KV)缓存的限制,但注意力头激活的细粒度结构仍不明确。我们证明预训练的Transformer表现出普遍的跨头线性结构:对于给定的token,一个注意力头的查询、键、值(QKV)向量可以被重建为少量同层其他头的线性组合。在Llama-3.1-8B、Falcon3-10B、OLMo-2-7B和Qwen3-32B中,仅需2-5个参考头即可高保真重建许多目标头(例如,在C4数据集上,5个参考头的键的平均R²约为0.76,且在GSM8K上频繁达到R²>0.85)。这种可预测性是通过学习而非架构设计:它在随机初始化时几乎不存在,随着预训练过程的进行迅速增加,并通过理论下限证明初始化时线性预测的均方误差较高。我们进一步将此现象与层内键投影子空间的对齐度增加联系起来。最后,我们利用此冗余性提高效率,仅缓存参考头的KV状态,并通过轻量级线性映射实时重建剩余头,实现2倍的KV缓存减少,但模型依赖的精度权衡(在Falcon3-10B和Qwen3-32B上五个基准测试中平均下降4.5-5.5个百分点,在Llama-3.1-8B上下降更大),并发现重建键比重建值对性能影响更小。

英文摘要:

Large language model (LLM) inference is increasingly bottlenecked by the Key-Value (KV) cache, yet the fine-grained structure of attention-head activations remains poorly understood. We show that pretrained Transformers exhibit a pervasive inter-head linear structure: for a given token, the Query, Key, and Value (QKV) vectors of an attention head can often be reconstructed as a linear combination of a small number of peer heads, typically within the same layer. Across Llama-3.1-8B, Falcon3-10B, OLMo-2-7B, and Qwen3-32B, just 2-5 reference heads recover many target heads with high fidelity (e.g., mean R^2 approx 0.76 for Keys on C4 with five references, and frequently R^2 > 0.85 on GSM8K). This predictability is learned rather than architectural: it is largely absent at random initialization, rises rapidly during pretraining as we track through OLMo-2 checkpoints, and is supported by a theoretical lower bound showing high mean-squared error for linear prediction at initialization. We further connect this emergence to increasing intra-layer alignment of Key projection subspaces. Finally, we exploit this redundancy for efficiency by caching only reference-head KV states and reconstructing the remaining heads on the fly via lightweight linear maps, achieving 2x KV-cache reduction with model-dependent accuracy trade-offs (4.5-5.5 percentage point average drop on Falcon3-10B and Qwen3-32B across five benchmarks, and larger drops on Llama-3.1-8B), and we find that reconstructing Keys is substantially less harmful than reconstructing Values.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑