Skip to main content
QUICK REVIEW

[论文解读] Demystify Mamba in Vision: A Linear Attention Perspective

Dongchen Han, Ziyi Wang|arXiv (Cornell University)|May 26, 2024
Advanced Vision and ImagingComputer Science被引用 17
一句话总结

论文展示 Mamba 与线性注意力 Transformer 的密切关系,并确定忘记门和块设计是 Mamba 在视觉任务中的关键因素,然后推导出 MLLA,即受 Mamba 启发的线性注意力模型,在分类和密集预测任务上超过视觉 Mamba。

ABSTRACT

Mamba is an effective state space model with linear computation complexity. It has recently shown impressive efficiency in dealing with high-resolution inputs across various vision tasks. In this paper, we reveal that the powerful Mamba model shares surprising similarities with linear attention Transformer, which typically underperform conventional Transformer in practice. By exploring the similarities and disparities between the effective Mamba and subpar linear attention Transformer, we provide comprehensive analyses to demystify the key factors behind Mamba's success. Specifically, we reformulate the selective state space model and linear attention within a unified formulation, rephrasing Mamba as a variant of linear attention Transformer with six major distinctions: input gate, forget gate, shortcut, no attention normalization, single-head, and modified block design. For each design, we meticulously analyze its pros and cons, and empirically evaluate its impact on model performance in vision tasks. Interestingly, the results highlight the forget gate and block design as the core contributors to Mamba's success, while the other four designs are less crucial. Based on these findings, we propose a Mamba-Inspired Linear Attention (MILA) model by incorporating the merits of these two key designs into linear attention. The resulting model outperforms various vision Mamba models in both image classification and high-resolution dense prediction tasks, while enjoying parallelizable computation and fast inference speed. Code is available at https://github.com/LeapLabTHU/MLLA.

研究动机与目标

  • 在统一框架内揭示 Mamba 与线性注意力 Transformer 的关系。
  • 确定 Mamba 在视觉任务中表现出色的设计选择。
  • 证明来自 Mamba 的核心思想可以整合到线性注意力中,形成具有竞争力的视觉模型。
  • 提供实际指南,关于在何时有忘记门有益,以及在视觉任务中如何用位置编码替代它。

提出的方法

  • 将选择性状态空间模型(SSM)与线性注意力统一记法重新表述,以便直接比较。
  • 描述 Mamba 与线性注意力 Transformer 之间的六个差异:输入门、忘记门、快捷通道、无注意力归一化、单头 vs 多头、以及修改后的块设计。
  • 进行消融研究,评估每个差异对 ImageNet-1K、COCO 与 ADE20K 任务的影响。
  • 通过将两个核心贡献(忘记门替代方案和块设计)移植到线性注意力中,提出 Mamba-Like Linear Attention (MLLA)。
  • 评估 MLLA 相对于各种视觉 Mamba 模型在实现性能提升的同时的速度。

实验结果

研究问题

  • RQ1Mamba 在核心计算上如何与线性注意力 Transformer 对齐与差异?
  • RQ2哪些设计组件对 Mamba 的视觉性能至关重要,为什么?
  • RQ3能否将 Mamba 的有益方面整合到线性注意力中,从而产生更优秀的视觉模型(MLLA)?
  • RQ4输入门、忘记门、快捷通道、归一化、头数和块设计在视觉基准测试中的性能和效率各自如何影响?

主要发现

  • Mamba 可以被视为线性注意力 Transformer 的变体,具有六个差异:输入门、忘记门、快捷通道、无归一化、单头,以及修改后的块设计。
  • 忘记门和块设计是 Mamba 在视觉任务中优越表现的主要贡献因素。
  • 用适当的位置信息编码(APE、LePE、CPE、RoPE)替换忘记门,在保持性能提升的同时实现并行计算。
  • 提出的 MLLA 模型,将这两大核心思想融入线性注意力,在 ImageNet-1K、COCO 与 ADE20K 上取得优于多种视觉 Mamba 模型的结果。
  • MLLA 相对于循环组件保持更快的推理,并在分类与密集预测基准上表现出竞争力或超越。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。