English

Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention

Machine Learning 2020-09-01 v3 Machine Learning

Abstract

Transformers achieve remarkable performance in several tasks but due to their quadratic complexity, with respect to the input's length, they are prohibitively slow for very long sequences. To address this limitation, we express the self-attention as a linear dot-product of kernel feature maps and make use of the associativity property of matrix products to reduce the complexity from O(N2)\mathcal{O}\left(N^2\right) to O(N)\mathcal{O}\left(N\right), where NN is the sequence length. We show that this formulation permits an iterative implementation that dramatically accelerates autoregressive transformers and reveals their relationship to recurrent neural networks. Our linear transformers achieve similar performance to vanilla transformers and they are up to 4000x faster on autoregressive prediction of very long sequences.

Keywords

Cite

@article{arxiv.2006.16236,
  title  = {Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention},
  author = {Angelos Katharopoulos and Apoorv Vyas and Nikolaos Pappas and François Fleuret},
  journal= {arXiv preprint arXiv:2006.16236},
  year   = {2020}
}

Comments

ICML 2020, project at https://linear-transformers.com/

R2 v1 2026-06-23T16:42:37.294Z