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.


翻译:注意力模式在大型语言模型(LLM)的训练与推理中均起着至关重要的作用。先前的研究已识别出诸如检索头、汇聚头和对角线轨迹等独立模式,但这些观察结果仍呈碎片化状态,缺乏统一的解释。为弥合这一差距,我们提出了**时序注意力模式可预测性分析(TAPPA)**,这是一个通过从时序连续视角分析其底层数学公式来解释多样化注意力模式的统一框架。TAPPA不仅深化了对注意力行为的理解,也指导了推理加速方法。具体而言,TAPPA将注意力模式刻画为具有清晰规律性的可预测模式与表现为有效随机的不可预测模式。我们的分析进一步揭示,这种区分可以通过查询在时序维度上的自相似度来解释。聚焦于可预测模式,我们进一步通过查询、键与旋转位置编码(RoPE)的联合效应,对三个代表性案例进行了详细的数学分析。我们通过将TAPPA的洞见应用于KV缓存压缩和LLM剪枝任务来验证其有效性。在这些任务中,一个受TAPPA启发的简单指标持续超越了基线方法的性能。代码可在 https://github.com/MIRALab-USTC/LLM-TAPPA 获取。

0
下载
关闭预览

相关内容

TransMLA:多头潜在注意力(MLA)即为所需
专知会员服务
23+阅读 · 2025年2月13日
迈向大语言模型偏好学习的统一视角综述
专知会员服务
24+阅读 · 2024年9月7日
LinkedIn最新《注意力模型》综述论文大全,20页pdf
专知会员服务
138+阅读 · 2020年12月20日
注意力机制模型最新综述
专知会员服务
271+阅读 · 2019年10月20日
注意力机制介绍,Attention Mechanism
专知会员服务
172+阅读 · 2019年10月13日
注意力机制可解释吗?这篇ACL 2019论文说……
机器之心
11+阅读 · 2019年6月16日
Attention!注意力机制模型最新综述
中国人工智能学会
18+阅读 · 2019年4月8日
注意力机制(Attention)最新综述论文及相关源码
人工智能学家
30+阅读 · 2018年11月17日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
从Seq2seq到Attention模型到Self Attention(一)
量化投资与机器学习
76+阅读 · 2018年10月8日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Arxiv
0+阅读 · 2月4日
VIP会员
相关资讯
注意力机制可解释吗?这篇ACL 2019论文说……
机器之心
11+阅读 · 2019年6月16日
Attention!注意力机制模型最新综述
中国人工智能学会
18+阅读 · 2019年4月8日
注意力机制(Attention)最新综述论文及相关源码
人工智能学家
30+阅读 · 2018年11月17日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
从Seq2seq到Attention模型到Self Attention(一)
量化投资与机器学习
76+阅读 · 2018年10月8日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员