Lune

ICCV2021Top-tier venue

Rethinking and Improving Relative Position Encoding for Vision Transformer

Kan Wu, Houwen Peng, Minghao Chen, Jianlong Fu, Hongyang Chao

Abstract

Relative position encoding (RPE) is important for transformer to capture sequence ordering of input tokens. General efficacy has been proven in natural language processing. However, in computer vision, its efficacy is not well studied and even remains controversial, e.g., whether relative position encoding can work equally well as absolute position? In order to clarify this, we first review existing relative position encoding methods and analyze their pros and cons when applied in vision transformers. We then propose new relative position encoding methods dedicated to 2D images, called image RPE (iRPE). Our methods consider directional relative distance modeling as well as the interactions between queries and relative position embeddings in self-attention mechanism. The proposed iRPE methods are simple and lightweight. They can be easily plugged into transformer blocks. Experiments demonstrate that solely due to the proposed encoding methods, DeiT [21] and DETR [1] obtain up to 1.5% (top-1 Acc) and 1.3% (mAP) stable improvements over their original versions on ImageNet and COCO respectively, without tuning any extra hyperparameters such as learning rate and weight decay. Our ablation and analysis also yield interesting findings, some of which run counter to previous understanding. Code and models are open-sourced at https://github.com/microsoft/Cream/tree/main/iRPE.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

85 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Locality-Attending Vision Transformer cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
  • Locality-Attending Vision Transformer cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Locality-Attending Vision Transformer cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  • Vision GNN: An Image is Worth Graph of Nodes cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
  • Vision GNN: An Image is Worth Graph of Nodes cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Vision GNN: An Image is Worth Graph of Nodes cites Bottleneck Transformers for Visual Recognition
  • Vision GNN: An Image is Worth Graph of Nodes cites MetaFormer is Actually What You Need for Vision
  • Vision GNN: An Image is Worth Graph of Nodes cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  • Stratified Transformer for 3D Point Cloud Segmentation cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Stratified Transformer for 3D Point Cloud Segmentation cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  • Bottleneck Transformers for Visual Recognition cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • MetaFormer is Actually What You Need for Vision cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
  • MetaFormer is Actually What You Need for Vision cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • MetaFormer is Actually What You Need for Vision cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  • Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
  • Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites Bottleneck Transformers for Visual Recognition
  • Swin Transformer V2: Scaling Up Capacity and Resolution cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Swin Transformer V2: Scaling Up Capacity and Resolution cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers85

  1. Swin Transformer V2: Scaling Up Capacity and ResolutionZe Liu, Han Hu, Yutong Lin, Zhuliang Yao et al.CVPR 2022 · 2,138 citations
  2. MetaFormer is Actually What You Need for VisionWeihao Yu, Mi Luo, Pan Zhou, Chenyang Si et al.CVPR 2022 · 1,114 citations
  3. Vision GNN: An Image is Worth Graph of NodesKai Han, Yunhe Wang, Jianyuan Guo, Yehui Tang et al.NeurIPS 2022 · 668 citations
  4. Stratified Transformer for 3D Point Cloud SegmentationXin Lai, Jianhui Liu, Li Jiang, Liwei Wang et al.CVPR 2022 · 494 citations
  5. Locality-Attending Vision TransformerSina Hajimiri, Farzad Beizaee, Fereshteh Shakeri, Christian Desrosiers et al.ICLR 2026 · 427 citations

Builds on7

  1. Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
  2. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
  3. CutMix: Regularization Strategy to Train Strong Classifiers With Localizable FeaturesSangdoo Yun, Dongyoon Han, Sanghyuk Chun, Seong Joon Oh et al.ICCV 2019 · 5,843 citations
  4. Improve Transformer Models with Better Relative Position EmbeddingsZhiheng Huang, Davis Liang, Peng Xu, Bing XiangEMNLP Findings 2020 · 114 citations
  5. Bottleneck Transformers for Visual RecognitionAravind Srinivas, Tsung-Yi Lin, Niki Parmar, Jonathon Shlens et al.CVPR 2021

Related papers

  1. An Anchor-based Relative Position Embedding Method for Cross-Modal TasksYa Wang, Xingwu Sun, Fengzong Lian, Zhanhui Kang et al.EMNLP 2022 · 1 citation
  2. Cameras as Relative Positional EncodingRuilong Li, Brent Yi, Junchen Liu, Hang Gao et al.NeurIPS 2025 · 113 citations
  3. LaPE: Layer-adaptive Position Embedding for Vision Transformers with Independent Layer NormalizationRunyi Yu, Zhennan Wang, Yinhuai Wang, Kehan Li et al.ICCV 2023 · 13 citations
  4. LOOPE: Learnable Optimal Patch Order for Positional Encoders in Vision TransformersMd Abtahi Majeed Chowdhury, Md Rifat Ur Rahman, Akil Ahmad TakiCVPR Findings 2026
  5. A Simple and Effective Positional Encoding for TransformersPu-Chin Chen, Henry Tsai, Srinadh Bhojanapalli, Hyung Won Chung et al.EMNLP 2021 · 51 citations
Dusk over the sea between two cliffs drawn in fine vertical lines