[Paper Review] RMT: Retentive Networks Meet Vision Transformers
This paper introduces MaSA, a Manhattan distance-based spatial decay self-attention, to instantiate RMT, a vision backbone with explicit spatial priors and linear complexity, achieving state-of-the-art results on ImageNet and strong performance across detection and segmentation tasks.
Vision Transformer (ViT) has gained increasing attention in the computer vision community in recent years. However, the core component of ViT, Self-Attention, lacks explicit spatial priors and bears a quadratic computational complexity, thereby constraining the applicability of ViT. To alleviate these issues, we draw inspiration from the recent Retentive Network (RetNet) in the field of NLP, and propose RMT, a strong vision backbone with explicit spatial prior for general purposes. Specifically, we extend the RetNet's temporal decay mechanism to the spatial domain, and propose a spatial decay matrix based on the Manhattan distance to introduce the explicit spatial prior to Self-Attention. Additionally, an attention decomposition form that adeptly adapts to explicit spatial prior is proposed, aiming to reduce the computational burden of modeling global information without disrupting the spatial decay matrix. Based on the spatial decay matrix and the attention decomposition form, we can flexibly integrate explicit spatial prior into the vision backbone with linear complexity. Extensive experiments demonstrate that RMT exhibits exceptional performance across various vision tasks. Specifically, without extra training data, RMT achieves **84.8%** and **86.1%** top-1 acc on ImageNet-1k with **27M/4.5GFLOPs** and **96M/18.2GFLOPs**. For downstream tasks, RMT achieves **54.5** box AP and **47.2** mask AP on the COCO detection task, and **52.8** mIoU on the ADE20K semantic segmentation task. Code is available at https://github.com/qhfan/RMT
Motivation & Objective
- Motivate the need for explicit spatial priors in Vision Transformers (ViT) to improve data efficiency and reduce quadratic complexity.
- Propose MaSA, a Manhattan distance-based spatial decay mechanism integrated into Self-Attention.
- Develop a decomposed attention formulation to model global information with linear complexity without disturbing the spatial prior.
- Assemble a unified backbone (RMT) using MaSA and demonstrate strong performance across classification, detection, and segmentation tasks.
Proposed method
- Extend RetNet's temporal decay to two-dimensional spatial decay using a Manhattan distance-based matrix D^{2d}.
- Define MaSA as Softmax(QK^T) ⊙ D^{2d} followed by V, introducing explicit spatial priors into Self-Attention.
- Introduce a decomposed MaSA (Attn_H and Attn_W) that applies one-dimensional bidirectional decay along horizontal and vertical axes to retain linear complexity while preserving the spatial prior.
- Add Local Context Enhancement (LCE) and Convolutional Position Encoding (CPE) to boost local expressions and positional information.
- Construct a four-stage vision backbone (RMT) using decomposed MaSA in the first three stages and MaSA in the last stage, with a convolutional stem and standardized training settings.
Experimental results
Research questions
- RQ1Can explicit spatial priors be integrated into Vision Transformers to improve accuracy without sacrificing efficiency?
- RQ2How can a two-dimensional spatial decay mechanism be designed and integrated with Self-Attention while maintaining linear complexity?
- RQ3Does decomposing MaSA into horizontal and vertical attention preserve the receptive field and prior information while reducing compute?
- RQ4Do MaSA-based backbones (RMT) outperform state-of-the-art ViT backbones on ImageNet and downstream vision tasks (Detection, Segmentation) without extra data?
- RQ5What is the impact of auxiliary components (LCE, CPE, convolution stem) on overall performance?
Key findings
- RMT achieves state-of-the-art or competitive top-1 accuracy on ImageNet-1K across model scales with favorable FLOPs (e.g., RMT-S: 84.1% Top-1 at 4.5 GFLOPs; RMT-S*: 84.8%; RMT-L*: 86.1%).
- RMT-L outperforms MaxViT-B while using fewer FLOPs, and RMT-B* reaches 85.6% Top-1 accuracy.
- In downstream tasks, RMT attains 54.5 box AP and 47.2 mask AP on COCO, and 52.8 mIoU on ADE20K, demonstrating strong capabilities in detection, segmentation, and semantic segmentation.
- The decomposed MaSA (Attn_H and Attn_W) preserves the spatial prior while achieving linear complexity for global modeling.
- Ablation studies show MaSA improves performance over vanilla attention by about 0.8% in classification, and LCE/CPE/stem contribute incremental gains.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.