Table of Contents
Fetching ...

MetaFormer Is Actually What You Need for Vision

Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, Shuicheng Yan

TL;DR

This work reframes vision models around a MetaFormer architecture, where the token mixer is decoupled from the core design to test what truly drives performance. By replacing the mixer with a simple pooling operation, PoolFormer demonstrates competitive accuracy with far fewer parameters and computations than tuned Transformer or MLP-like baselines, supporting the claim that MetaFormer is the key ingredient. The authors provide extensive experiments across image classification, object detection, and segmentation, plus ablations, showing that focusing on MetaFormer rather than complex token mixers can yield strong, versatile vision models. The results advocate PoolFormer as a practical starting point for future MetaFormer design and invite broader exploration of MetaFormer across tasks and training regimes.

Abstract

Transformers have shown great potential in computer vision tasks. A common belief is their attention-based token mixer module contributes most to their competence. However, recent works show the attention-based module in Transformers can be replaced by spatial MLPs and the resulted models still perform quite well. Based on this observation, we hypothesize that the general architecture of the Transformers, instead of the specific token mixer module, is more essential to the model's performance. To verify this, we deliberately replace the attention module in Transformers with an embarrassingly simple spatial pooling operator to conduct only basic token mixing. Surprisingly, we observe that the derived model, termed as PoolFormer, achieves competitive performance on multiple computer vision tasks. For example, on ImageNet-1K, PoolFormer achieves 82.1% top-1 accuracy, surpassing well-tuned Vision Transformer/MLP-like baselines DeiT-B/ResMLP-B24 by 0.3%/1.1% accuracy with 35%/52% fewer parameters and 50%/62% fewer MACs. The effectiveness of PoolFormer verifies our hypothesis and urges us to initiate the concept of "MetaFormer", a general architecture abstracted from Transformers without specifying the token mixer. Based on the extensive experiments, we argue that MetaFormer is the key player in achieving superior results for recent Transformer and MLP-like models on vision tasks. This work calls for more future research dedicated to improving MetaFormer instead of focusing on the token mixer modules. Additionally, our proposed PoolFormer could serve as a starting baseline for future MetaFormer architecture design. Code is available at https://github.com/sail-sg/poolformer.

MetaFormer Is Actually What You Need for Vision

TL;DR

This work reframes vision models around a MetaFormer architecture, where the token mixer is decoupled from the core design to test what truly drives performance. By replacing the mixer with a simple pooling operation, PoolFormer demonstrates competitive accuracy with far fewer parameters and computations than tuned Transformer or MLP-like baselines, supporting the claim that MetaFormer is the key ingredient. The authors provide extensive experiments across image classification, object detection, and segmentation, plus ablations, showing that focusing on MetaFormer rather than complex token mixers can yield strong, versatile vision models. The results advocate PoolFormer as a practical starting point for future MetaFormer design and invite broader exploration of MetaFormer across tasks and training regimes.

Abstract

Transformers have shown great potential in computer vision tasks. A common belief is their attention-based token mixer module contributes most to their competence. However, recent works show the attention-based module in Transformers can be replaced by spatial MLPs and the resulted models still perform quite well. Based on this observation, we hypothesize that the general architecture of the Transformers, instead of the specific token mixer module, is more essential to the model's performance. To verify this, we deliberately replace the attention module in Transformers with an embarrassingly simple spatial pooling operator to conduct only basic token mixing. Surprisingly, we observe that the derived model, termed as PoolFormer, achieves competitive performance on multiple computer vision tasks. For example, on ImageNet-1K, PoolFormer achieves 82.1% top-1 accuracy, surpassing well-tuned Vision Transformer/MLP-like baselines DeiT-B/ResMLP-B24 by 0.3%/1.1% accuracy with 35%/52% fewer parameters and 50%/62% fewer MACs. The effectiveness of PoolFormer verifies our hypothesis and urges us to initiate the concept of "MetaFormer", a general architecture abstracted from Transformers without specifying the token mixer. Based on the extensive experiments, we argue that MetaFormer is the key player in achieving superior results for recent Transformer and MLP-like models on vision tasks. This work calls for more future research dedicated to improving MetaFormer instead of focusing on the token mixer modules. Additionally, our proposed PoolFormer could serve as a starting baseline for future MetaFormer architecture design. Code is available at https://github.com/sail-sg/poolformer.
Paper Structure (16 sections, 4 equations, 4 figures, 7 tables, 1 algorithm)

This paper contains 16 sections, 4 equations, 4 figures, 7 tables, 1 algorithm.

Figures (4)

  • Figure 1: MetaFormer and performance of MetaFormer-based models on ImageNet-1K validation set. As shown in (a), we present MetaFormer as a general architecture abstracted from Transformers transformer by not specifying the token mixer. When using attention/spatial MLP as the token mixer, MetaFormer is instantiated as Transformer/MLP-like models. We argue that the competence of Transformer/MLP-like models primarily stems from the general architecture MetaFormer instead of the equipped specific token mixers. To demonstrate this, we exploit an embarrassingly simple non-parametric operator, pooling, to conduct extremely basic token mixing. Surprisingly, the resulted model PoolFormer consistently outperforms the well-tuned vision Transformer vit baseline (DeiT deit) and MLP-like mlp-mixer baseline (ResMLP resmlp) as shown in (b), which well supports that MetaFormer is actually what we need to achieve competitive performance. RSB-ResNet in (b) means the results are from "ResNet Strikes Back" resnet_improved where ResNet resnet are trained with improved training procedure for 300 epochs.
  • Figure 2: (a) The overall framework of PoolFormer. Similar to resnetpvtswin, PoolFormer adopts hierarchical architecture with 4 stages. For a model with L PoolFormer blocks, stage [1, 2, 3, 4] have [L/6, L/6, L/2, L/6] blocks, respectively. The feature dimension $D_i$ of stage $i$ is shown in the figure. (b) The architecture of PoolFormer block. Compared with Transformer block, it replaces attention with extremely simple non-parametric operator, pooling, to conduct only basic token mixing.
  • Figure 3: ImageNet-1K validation accuracy vs. MACs/Model Size. RSB-ResNet means the results are from "ResNet Strikes Back" resnet_improved where ResNet resnet is trained with improved training procedure for 300 epochs.
  • Figure 4: Grad-CAM gradcam activation maps of the models trained on ImageNet-1K. The visualized images are from validation set.