RecurFormer: Not All Transformer Heads Need Self-Attention
Nanyang Technological University(南洋理工大学);The University of New South Wales(新南威尔士大学);Shanghai Jiao Tong University(上海交通大学);The College of William and Mary(威廉玛丽学院)
Ruiqing Yan, Linghan Zheng, Xingbo Du, Han Zou, Yufeng Guo, Jianfei Yang
Transformer-based large language models (LLMs) excel in modeling complex language patterns but face significant computational costs during inference, especially with long inputs due to the attention mechanism's memory overhead. We observe that certain attention heads exhibit a distribution where the attention weights concentrate on tokens near the query token, termed as recency aware, which focuses on local and short-range dependencies. Leveraging this insight, we propose RecurFormer, a novel architecture that replaces these attention heads with linear recurrent neural networks (RNNs), specifically the Mamba architecture. This replacement reduces the cache size without evicting tokens, thus maintaining generation quality. RecurFormer retains the ability to model long-range dependencies through the remaining attention heads and allows for reusing pre-trained Transformer-based LLMs weights with continual training. Experiments demonstrate that RecurFormer matches the original model's performance while significantly enhancing inference efficiency. Our approach provides a practical solution to the computational challenges of Transformer-based LLMs inference, making it highly attractive for tasks involving long inputs.
Mechanistic Interpretability of Fine-Tuned Vision Transformers on Distorted Images: Decoding Attention Head Behavior for Transparent and Trustworthy AI
Krembil Research Institute, University Health Network(肯贝尔研究所,大学健康网络)
DHA: Learning Decoupled-Head Attention from Transformer Checkpoints via Adaptive Heads Fusion
Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);School of Cyber Security, University of Chinese Academy of Sciences(中国科学院大学网络空间安全学院);Baidu Inc.(百度公司)
Improving Transformers with Probabilistic Attention Keys
FPT Software AI Center(FPT软件人工智能中心);University of California, Los Angeles(加州大学洛杉矶分校);VinUniversity(文大);Deezer Research(Deezer研究院);Rice University(莱斯大学);The University of Texas at Austin(德克萨斯大学奥斯汀分校)
多头注意力是最先进的Transformers背后的驱动力,它在各种自然语言处理(NLP)和计算机视觉任务中实现了卓越的性能。已经观察到,对于许多应用,这些注意力头学习冗余嵌入,并且其中大多数可以在不降低模型性能的情况下被移除。受此启发,我们提出了Transformer与混合高斯密钥(transformer-MGK),一种新的Transformer架构,取代冗余的头在每个头的混合密钥的变压器。这些键的混合遵循高斯混合模型,并允许每个注意力头有效地集中在输入序列的不同部分。与传统的Transformer相比,Transformer-MGK加速了训练和推理,参数更少,需要计算的FLOP更少,同时在任务中实现了相当或更好的准确性。transformer-MGK也可以很容易地扩展到使用线性注意力。我们经验证明了Transformer-MGK在一系列实际应用中的优势,包括语言建模和涉及很长序列的任务。在Wikitext-103和Long Range Arena基准测试中,具有4个头的Transformer-MGK获得了与具有8个头的基线Transformers相当或更好的性能。
The University of Hong Kong(香港大学);Sun Yat-sen University(中山大学);Shanghai Artificial Intelligence Laboratory(上海人工智能实验室)
Transformers在各种重要任务上推进了自然语言处理(NLP)领域。Transformer体系结构的基石是多头注意力(MHA)机制,它对序列元素之间的成对交互进行建模。尽管取得了巨大的成功,但目前的框架忽略了不同头部之间的相互作用,导致许多头部在实践中是多余的,这极大地浪费了模型的容量。为了提高参数效率,我们重新制定的MHA作为一个潜在的变量模型从概率的角度来看。我们提出了级联头碰撞注意力(CODA),显式模型之间的相互作用,通过层次变分分布的注意头。我们进行了大量的实验,并证明CODA优于Transformer基线,通过在语言建模中的\texttt{Wikitext-103}上的$0.6$困惑,以及在机器翻译中的\texttt{WMT14 EN-DE}上的$0.6$ BLEU,由于它在参数效率上的改进。\footnote{Our implementation is publicly available at \url{https://github.com/LZhengisme/CODA}.}
Causal Head Gating: A Framework for Interpreting Roles of Attention Heads in Transformers
Princeton Laboratory for AI Natural and Artificial Minds(普林斯顿人工智能实验室);Princeton University(普林斯顿大学);Department of Electrical and Computer Engineering(电气与计算机工程系);Department of Psychology(心理学系);Princeton Neuroscience Institute(普林斯顿神经科学研究所);Department of Philosophy(哲学系);Center for Statistics and Machine Learning(统计与机器学习中心)
Infinite Limits of Multi-head Transformer Dynamics
John A. Paulson School of Engineering and Applied Sciences(约翰·A·保尔森工程与应用科学学院);Center for Brain Science(脑科学中心);Kempner Institute for the Study of Natural and Artificial Intelligence(坎普纳自然与人工智能研究所);Harvard University(哈佛大学)
MossFormer: Pushing the Performance Limit of Monaural Speech Separation using Gated Single-Head Transformer with Convolution-Augmented Joint Self-Attentions
Multi-Head Attention as a Source of Catastrophic Forgetting in MoE Transformers
Fudan University, Shanghai, China(复旦大学);University of Bath, Bath, United Kingdom(巴斯大学);Oxford Suzhou Centre for Advanced Research, Suzhou, China(牛津苏滁研究中心);Shanghai Innovation Institute, Shanghai, China(上海创新研究院);Department of Computer Science, University of Colorado Boulder, Colorado, USA(计算机科学系,科罗拉多大学博尔德分校);Department of Electrical Engineering and Computer Science, University of Michigan(电气工程与计算机科学系,密歇根大学)
Entropy Meets Importance: A Unified Head Importance-Entropy Score for Stable and Efficient Transformer Pruning
Department of Computer Science and Engineering, Korea University, Seoul, South Korea(计算机科学与工程系,韩国大学,首尔,韩国);School of Software, Soongsil University, Seoul, South Korea(软件学院,顺天大学,首尔,韩国)