Skip to main content
QUICK REVIEW

[论文解读] Long-Short Transformer: Efficient Transformers for Language and Vision

Chen Zhu, Wei Ping|arXiv (Cornell University)|Jul 5, 2021
Multimodal Machine Learning Applications参考文献 62被引用 56
一句话总结

Transformer-LS 将动态低秩长程注意力与本地滑动窗口注意力相结合,在语言与视觉的长序列中实现线性时间的自注意力,在多项任务上超越最先进的高效变换器。

ABSTRACT

Transformers have achieved success in both language and vision domains. However, it is prohibitively expensive to scale them to long sequences such as long documents or high-resolution images, because self-attention mechanism has quadratic time and memory complexities with respect to the input sequence length. In this paper, we propose Long-Short Transformer (Transformer-LS), an efficient self-attention mechanism for modeling long sequences with linear complexity for both language and vision tasks. It aggregates a novel long-range attention with dynamic projection to model distant correlations and a short-term attention to capture fine-grained local correlations. We propose a dual normalization strategy to account for the scale mismatch between the two attention mechanisms. Transformer-LS can be applied to both autoregressive and bidirectional models without additional complexity. Our method outperforms the state-of-the-art models on multiple tasks in language and vision domains, including the Long Range Arena benchmark, autoregressive language modeling, and ImageNet classification. For instance, Transformer-LS achieves 0.97 test BPC on enwik8 using half the number of parameters than previous method, while being faster and is able to handle 3x as long sequences compared to its full-attention version on the same hardware. On ImageNet, it can obtain the state-of-the-art results (e.g., a moderate size of 55.8M model solely trained on 224x224 ImageNet-1K can obtain Top-1 accuracy 84.1%), while being more scalable on high-resolution images. The source code and models are released at https://github.com/NVIDIA/transformer-ls .

研究动机与目标

  • 激发对能够处理长语言序列和高分辨率视觉输入的可扩展 Transformer 的需求。
  • 提出一个统一的 Long-Short Transformer(Transformer-LS),将长程动态投影注意力与短期局部窗口注意力结合起来。
  • 引入 DualLN 以解决长程与短期分量之间的尺度不匹配。
  • 在语言和视觉基准上展示最先进的性能和效率。
  • 提供实现细节并展示在各任务中的鲁棒性与可扩展性。

提出的方法

  • 提出一种双注意力机制,将动态低秩长程注意力与局部窗口短期注意力聚合在一起。
  • 从 K 派生的动态投影 P_i 将 K 和 V 投影到低秩 bar{K}_i、bar{V}_i,复杂度为 O(rn)。
  • 将长程注意力计算为 bar{H}_i = A_i (P_i^T W^V V),其中 A_i 是 softmax(QW_i^Q bar{K}_i^T)/sqrt(d_k)。
  • 通过对 [tilde{K}_t; bar{K}_i] 与 [tilde{V}_t; bar{V}_i] 进行注意力聚合每个头的长程和短期注意力,并采用 DualLN 方案以对齐范数。
  • 对自回归与双向模型应用高效注意力,具有线性时间/空间复杂度。
  • 展示 Dynamic Projection 对序列长度变化和扰动的鲁棒性。

实验结果

研究问题

  • RQ1一个统一的 Long-Short Transformer 是否能够在保持或提升对长程语言与高分辨率视觉任务的性能的同时实现线性时间自注意力?
  • RQ2将动态长程投影与局部窗口注意力相结合,在多种设定下(LRA、IMDb、enwik8、text8、ImageNet)是否能优于此前的高效 Transformer 方法?
  • RQ3所提出的 DualLN 归一化在缓解长程与短程注意力之间的尺度不匹配方面是否有效?
  • RQ4在语言和视觉基准上,Transformer-LS 在自回归与双向建模中的表现如何?
  • RQ5所提出的注意力聚合对输入扰动(插入/删除)以及变长序列的鲁棒性有何影响?

主要发现

  • Transformer-LS 在高效 Transformer 中的 Long Range Arena 基准上取得最先进的结果。
  • 在自回归语言建模中,Transformer-LS 在 enwik8 上达到 0.97 的测试 BPC,参数量是此前方法的一半,并且在同一硬件上处理的序列长度比全注意力基线长 3×。
  • 在视觉任务中,基于 Transformer-LS 的 CvT 与 ViL 变体在 ImageNet 上取得有竞争力的或最先进的结果,FLOPs 降低或相当。
  • 与没有 DualLN 的模型相比,DualLN 对齐显著改善了优化和验证损失。
  • Dynamic Projection 对插入/删除扰动显示出鲁棒性,并在固定的 Linformer 风格投影之上提供更优的性能。
  • 在各任务中,带有 w 和 r 配置的 Transformer-LS 往往在准确性、FLOPs 和序列长度支持之间实现有利的折衷。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。