Transformer 是 RNN:具有线性注意力的快速自回归 Transformer

Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention

安杰洛斯·卡塔罗普洛斯 Angelos Katharopoulos · Idiap Research Institute / EPFL · 2020-06-29 · arXiv:2006.16236 ↗ · 被引 2903

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

Transformer 在多项任务中表现出色,但由于其相对于输入长度的二次复杂度,处理极长序列时速度极慢。为解决这一局限,我们将自注意力表示为核特征映射的线性点积,并利用矩阵乘积的结合性,将复杂度从 O(N²)降至 O(N),其中 N 为序列长度。我们证明,这种公式允许迭代实现,从而大幅加速自回归 Transformer,并揭示其与递归神经网络的联系。我们的线性 Transformer 性能与原始 Transformer 相当,且在极长序列的自回归预测中速度提升高达 4000 倍。

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.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 17)

阅读逐段中英对照全文 →