Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention

About

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 $\mathcal{O}\left(N^2\right)$ to $\mathcal{O}\left(N\right)$, where $N$ 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.

Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, Fran\c{c}ois Fleuret• 2020

Related benchmarks

TaskDatasetResultRank
Commonsense ReasoningHellaSwag--
1891
Commonsense ReasoningWinoGrande--
1085
Language ModelingWikiText
PPL45.43
732
Language ModelingWikiText-103 (test)
Perplexity22.2
579
Natural Language UnderstandingGLUE
SST-284.63
531
Natural Language UnderstandingGLUE (dev)
SST-2 (Acc)91.51
518
Machine TranslationWMT En-De 2014 (test)
BLEU28.4
379
Image ClassificationCIFAR-10
Accuracy60
246
Machine TranslationWMT En-Fr 2014 (test)
BLEU41.8
237
Language ModelingWikiText-103 (val)
PPL27.44
214
Showing 10 of 114 rows
...

Other info

Code

Follow for update