arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.05730cs.LGcs.AI
收藏

逐元素注意力就是你所需的一切

Element-wise Attention Is All You Need

College of Information Science and Engineering, Northeastern University(东北大学信息科学与工程学院)

Guoxin Feng

AI总结:

本文提出逐元素注意力机制,以平方欧氏距离和 Taylor 多项式替代点积相似度,在保持自注意力性能的同时显著降低长序列训练与推理复杂度。

摘要:

自注意力(SA)机制已在多个领域展现出卓越性能,但其在训练和推理期间都存在相当高的复杂度。下一代架构旨在保留 SA 具有竞争力的性能,同时实现低成本推理和高效的长序列训练,主要集中于三种方法:线性注意力、线性 RNN 和状态空间模型。尽管这些方法相比 SA 降低了复杂度,但它们都存在内在的性能下降因素,例如“尖峰性”减弱以及历史信息被压缩。与这些方法不同,我们提出了一种新颖的逐元素注意力机制,该机制使用逐元素平方欧氏距离而非点积运算来计算相似度,并用 Taylor 多项式逼近二次复杂度项 $\exp(q_{ic}k_{jc})$。这一设计实现了显著效率:在训练期间,逐元素注意力的复杂度为 $\mathcal{O}(tLD)$,使长序列训练在计算和内存方面都高效,其中 $L$ 是序列长度,$D$ 是特征维度,$t$ 是多项式的最高阶数;在推理期间,它可以被重构为循环神经网络,实现 $\mathcal{O}(tD)$ 的推理复杂度。此外,逐元素注意力规避了这些方法中存在的性能下降因素,并在因果和非因果形式下均取得了与 SA 相当的性能。

英文摘要:

The self-attention (SA) mechanism has demonstrated superior performance across various domains, yet it suffers from substantial complexity during both training and inference. The next-generation architecture, aiming at retaining the competitive performance of SA while achieving low-cost inference and efficient long-sequence training, primarily focuses on three approaches: linear attention, linear RNNs, and state space models. Although these approaches achieve reduced complexity than SA, they all have built-in performance degradation factors, such as diminished “spikiness” and compression of historical information. In contrast to these approaches, we propose a novel element-wise attention mechanism, which uses the element-wise squared Euclidean distance, instead of the dot product operation, to compute similarity and approximates the quadratic complexity term $\exp(q_{ic}k_{jc})$ with a Taylor polynomial. This design achieves remarkable efficiency: during training, the element-wise attention has a complexity of $\mathcal{O}(tLD)$, making long-sequence training both computationally and memory efficient, where $L$ is the sequence length, $D$ is the feature dimension, and $t$ is the highest order of the polynomial; during inference, it can be reformulated as recurrent neural networks, achieving a inference complexity of $\mathcal{O}(tD)$. Furthermore, the element-wise attention circumvents the performance degradation factors present in these approaches and achieves performance comparable to SA in both causal and non-causal forms.

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

↑