HyperAIHyperAI

Command Palette

Search for a command to run...

3 months ago

Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention

Angelos Katharopoulos Apoorv Vyas Nikolaos Pappas François Fleuret

Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention

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 $\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.

Code Repositories

Benchmarks

BenchmarkMethodologyMetrics
d4rl-on-d4rlLinear Transformer
Average Reward: 64.4
language-modelling-on-wikitext-103Linear Attention 125M
Test perplexity: 25.6

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp
Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention | Papers | HyperAI