从时间连续性视角统一解释大模型注意力模式的形成机制。
Why Attention Patterns Exist: A Unifying Temporal Perspective Analysis
- 基于时间连续性分析注意力模式的数学本质,区分可预测与不可预测模式。
- 发现查询自相似性程度决定注意力模式是否可预测,关键受RoPE影响。
- 指导缓存压缩与模型剪枝,提升推理效率,代码已开源。
注意力模式在大语言模型的训练与推理中起关键作用。以往研究识别出检索头、沉降头和对角线迹等独立模式,但缺乏统一解释。本文提出时序注意力模式可预测性分析(TAPPA),从时间连续视角解析注意力模式的数学基础。TAPPA将注意力模式分为具有规律的可预测模式和看似随机的不可预测模式,并揭示其差异源于查询在时间维度上的自相似性程度。通过联合分析查询、键和旋转位置编码(RoPE)的影响,详细阐释了三种典型可预测模式的数学机制。实验验证表明,基于TAPPA设计的简单指标在KV缓存压缩与大模型剪枝任务中持续优于基线方法。代码已公开于https://github.com/MIRALab-USTC/LLM-TAPPA。
原文摘要 · Abstract (English)
Attention patterns play a crucial role in both training and inference of large language models (LLMs). Prior works have identified individual patterns such as retrieval heads, sink heads, and diagonal traces, yet these observations remain fragmented and lack a unifying explanation. To bridge this gap, we introduce \textbf{Temporal Attention Pattern Predictability Analysis (TAPPA), a unifying framework that explains diverse attention patterns by analyzing their underlying mathematical formulations} from a temporally continuous perspective. TAPPA both deepens the understanding of attention behavior and guides inference acceleration approaches. Specifically, TAPPA characterizes attention patterns as predictable patterns with clear regularities and unpredictable patterns that appear effectively random. Our analysis further reveals that this distinction can be explained by the degree of query self-similarity along the temporal dimension. Focusing on the predictable patterns, we further provide a detailed mathematical analysis of three representative cases through the joint effect of queries, keys, and Rotary Positional Embeddings (RoPE). We validate TAPPA by applying its insights to KV cache compression and LLM pruning tasks. Across these tasks, a simple metric motivated by TAPPA consistently improves performance over baseline methods. The code is available at https://github.com/MIRALab-USTC/LLM-TAPPA.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。