[论文解读] Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction
本文提出Token Statistics Transformer(ToST),一种新颖的自注意力机制——Token Statistics Self-Attention(TSSA),通过用投影特征的二阶统计量替代成对标记相似度计算,实现线性计算与内存复杂度。TSSA源自最大编码率缩减(MCR²)目标的变分形式的算法展开,其在视觉、语言及长序列任务上达到与标准Transformer相当的性能,同时显著提升效率与可解释性,挑战了成对注意力对Transformer成功是否必不可少的假设。
The attention operator is arguably the key distinguishing factor of transformer architectures, which have demonstrated state-of-the-art performance on a variety of tasks. However, transformer attention operators often impose a significant computational burden, with the computational complexity scaling quadratically with the number of tokens. In this work, we propose a novel transformer attention operator whose computational complexity scales linearly with the number of tokens. We derive our network architecture by extending prior work which has shown that a transformer style architecture naturally arises by "white-box" architecture design, where each layer of the network is designed to implement an incremental optimization step of a maximal coding rate reduction objective (MCR$^2$). Specifically, we derive a novel variational form of the MCR$^2$ objective and show that the architecture that results from unrolled gradient descent of this variational objective leads to a new attention module called Token Statistics Self-Attention (TSSA). TSSA has linear computational and memory complexity and radically departs from the typical attention architecture that computes pairwise similarities between tokens. Experiments on vision, language, and long sequence tasks show that simply swapping TSSA for standard self-attention, which we refer to as the Token Statistics Transformer (ToST), achieves competitive performance with conventional transformers while being significantly more computationally efficient and interpretable. Our results also somewhat call into question the conventional wisdom that pairwise similarity style attention mechanisms are critical to the success of transformer architectures. Code will be available at https://github.com/RobinWu218/ToST.
研究动机与目标
- 为解决标准Transformer中自注意力机制的二次方计算与内存复杂度问题,该问题限制了其在长序列上的可扩展性。
- 探究成对标记相似度计算是否对Transformer性能至关重要,从而挑战注意力机制设计中的核心假设。
- 基于严谨的优化理论,开发一种新型注意力机制,具体通过在新型变分MCR²目标上展开梯度下降。
- 设计一种模型,在保持竞争力表现的同时,显著降低推理时间与内存使用,尤其适用于长上下文与视觉任务。
- 证明注意力可被重新构想为基于统计量的输入特征变换,而非基于相似度的聚合。
提出的方法
- 该方法推导出MCR²目标的新型变分形式,通过算法展开实现基于原则的、可微分的架构设计。
- TSSA通过聚合投影标记特征的统计量(特别是二阶矩)来计算注意力,避免显式计算成对相似度。
- 通过展开变分MCR²目标的梯度更新,构建出一种逐层变换架构,兼具高效性与可解释性。
- 由此产生的模型ToST在所有层中均用TSSA替代标准自注意力,同时保留Transformer的残差与前馈结构。
- 为自回归语言建模引入TSSA的因果变体,实现高效的下一个词预测。
- 该方法采用标准优化方式端到端训练,仅在注意力机制替换之外,无需对架构或损失函数进行修改。
实验结果
研究问题
- RQ1能否设计一种自注意力机制,在不计算标记之间成对相似度的前提下,仍能在视觉与语言任务上实现具有竞争力的性能?
- RQ2将标准注意力替换为TSSA这类基于统计量的机制,是否会从根本上改变Transformer的归纳偏置?若会,其对性能与泛化能力有何影响?
- RQ3自注意力的二次方复杂度是否真正对长程建模必不可少?线性时间替代方案如TSSA能否实现相当的长上下文性能?
- RQ4能否通过基于优化理论的严谨推导,获得一种比标准注意力更高效且更可解释的注意力机制?
- RQ5Transformer的成功是否依赖于成对注意力的特定结构?还是可通过其他更高效、替代性的注意力机制实现相似性能?
主要发现
- ToST在图像分类基准上实现具有竞争力的性能,可视化结果表明其能自主学习有意义的分割与聚类,无需监督。
- 在Long-Range Arena基准测试中,ToST平均得分59.90,优于标准Transformer的59.24,表现更优。
- 在因果语言建模任务中,参数量为655M的ToST在四个数据集上的平均测试损失为4.02,与GPT2-Base(4.26)相比表现相当,尽管参数更少、计算量更低。
- 与标准Transformer相比,ToST将推理时间减少高达60%,内存使用减少高达76%;其因果变体在8k序列长度下内存使用减少54%。
- 模型的注意力图显示,TSSA能学习将语义一致的图像块或标记分组,表明统计聚合可替代基于相似度的注意力,实现有意义的表征学习。
- 结果挑战了传统观点,即成对相似度计算对注意力机制必不可少,表明其他归纳偏置可实现更强性能与更高效率。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。