{ "id": "2006.16236", "version": "v1", "published": "2020-06-29T17:55:38.000Z", "updated": "2020-06-29T17:55:38.000Z", "title": "Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention", "authors": [ "Angelos Katharopoulos", "Apoorv Vyas", "Nikolaos Pappas", "François Fleuret" ], "comment": "ICML 2020, project at https://linear-transformers.com/", "categories": [ "cs.LG", "stat.ML" ], "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.", "revisions": [ { "version": "v1", "updated": "2020-06-29T17:55:38.000Z" } ], "analyses": { "keywords": [ "fast autoregressive transformers", "linear attention", "linear transformers achieve similar performance", "long sequences", "recurrent neural networks" ], "note": { "typesetting": "TeX", "pages": 0, "language": "en", "license": "arXiv", "status": "editable" } } }