[论文解读] Random Feature Attention
Rfa 将 softmax 注意力替换为线性时间、线性空间的随机特征近似,带有用于最近偏好恢复的可选门控,在机器翻译中实现与强大 Transformer 相当或更好的性能,并且解码更快。
Transformers are state-of-the-art models for a variety of sequence modeling tasks. At their core is an attention function which models pairwise interactions between the inputs at every timestep. While attention is powerful, it does not scale efficiently to long sequences due to its quadratic time and space complexity in the sequence length. We propose RFA, a linear time and space attention that uses random feature methods to approximate the softmax function, and explore its application in transformers. RFA can be used as a drop-in replacement for conventional softmax attention and offers a straightforward way of learning with recency bias through an optional gating mechanism. Experiments on language modeling and machine translation demonstrate that RFA achieves similar or better performance compared to strong transformer baselines. In the machine translation experiment, RFA decodes twice as fast as a vanilla transformer. Compared to existing efficient transformer variants, RFA is competitive in terms of both accuracy and efficiency on three long text classification datasets. Our analysis shows that RFA's efficiency gains are especially notable on long sequences, suggesting that RFA will be particularly useful in tasks that require working with large inputs, fast decoding speed, or low memory footprints.
研究动机与目标
- 为变换器中的长序列激发可扩展的注意力机制。
- 提出 Random Feature Attention (Rfa) 作为 softmax 注意力的线性时间、线性空间替代方案。
- 在学习过程中引入一个可选的门控机制以引入最近性偏置。
- 展示 Rfa 在语言模型、机器翻译和长文本分类任务中的有效性。
提出的方法
- 使用随机特征映射 φ 推导无偏的基于核的近似 exp(q·k/σ^2) 来逼近 softmax 注意力。
- 将注意力重写为 φ(q)ᵀ S / (φ(q)· z),其中 S 与 z 通过 φ(k)⊗v 与 φ(k) 累积,从而实现线性时间计算。
- 引入 Rfa-Gate,一种类似递归的门控机制 g_t,用于平滑衰减历史并编码最近偏置。
- 允许 Rfa 作为 softmax 注意力的直接替代,参数增加极小(约0.1%)。
- 探索高斯和 arc-cosine 随机特征映射作为 φ,并考虑 q 与 k 范数的归一化问题。
实验结果
研究问题
- RQ1如何在不牺牲性能的前提下,使注意力在序列长度线性缩放?
- RQ2基于随机特征的注意力(Rfa)是否在语言建模、翻译和长序列分类任务中达到或超过标准 softmax 注意力的性能?
- RQ3Rfa 中的门控机制能否捕捉最近偏置并在需要局部性任务上提升性能?
- RQ4与原生 Transformer 相比,Rfa 在解码阶段和处理长输入时的加速和内存收益是多少?
主要发现
- 在 WikiText-103 上,Rfa 的困惑度达到与基线 Transformer 相当甚至更好,门控带来显著提升。
- 在机器翻译基准中,所有 Rfa 变体的解码速度至少比 Base Transformer 快约 1.8 倍,BLEU 分数与 Base 相当。
- 在长文本分类任务中,Rfa 的准确性具有竞争力,并且在速度/内存方面相对于若干高效 Transformer 变体具有优势。
- Rfa 展示了显著的解码加速(对于 2048 长度输出最高可达 12×)以及更低的长序列内存使用。
- 高斯特征映射通常在语言建模实验中比 arc-cosine 更稳定且表现更好。
- 带门控的变体(Rfa-Gate)在语言建模,尤其是 WikiText-103 上显示出收益。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。