English

Element-wise Attention Is All You Need

Machine Learning 2025-01-13 v1 Artificial Intelligence

Abstract

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(qickjc)\exp(q_{ic}k_{jc}) with a Taylor polynomial. This design achieves remarkable efficiency: during training, the element-wise attention has a complexity of O(tLD)\mathcal{O}(tLD), making long-sequence training both computationally and memory efficient, where LL is the sequence length, DD is the feature dimension, and tt is the highest order of the polynomial; during inference, it can be reformulated as recurrent neural networks, achieving a inference complexity of O(tD)\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.

Keywords

Cite

@article{arxiv.2501.05730,
  title  = {Element-wise Attention Is All You Need},
  author = {Guoxin Feng},
  journal= {arXiv preprint arXiv:2501.05730},
  year   = {2025}
}
R2 v1 2026-06-28T21:02:15.819Z