Skip to main content
QUICK REVIEW

[Paper Review] Pay Attention to MLPs

Hanxiao Liu, Zihang Dai|arXiv (Cornell University)|May 17, 2021
Multimodal Machine Learning ApplicationsComputer Science44 references33 citations
TL;DR

The paper proposes gMLP, an MLP-based architecture with a Spatial Gating Unit that can match Transformer performance on language and vision tasks, and shows scaling parity with Transformers when given more data and compute, with tiny attention optionally boosting NLP finetuning.

ABSTRACT

Transformers have become one of the most important architectural innovations in deep learning and have enabled many breakthroughs over the past few years. Here we propose a simple network architecture, gMLP, based on MLPs with gating, and show that it can perform as well as Transformers in key language and vision applications. Our comparisons show that self-attention is not critical for Vision Transformers, as gMLP can achieve the same accuracy. For BERT, our model achieves parity with Transformers on pretraining perplexity and is better on some downstream NLP tasks. On finetuning tasks where gMLP performs worse, making the gMLP model substantially larger can close the gap with Transformers. In general, our experiments show that gMLP can scale as well as Transformers over increased data and compute.

Motivation & Objective

  • Assess whether self-attention is essential for Transformer-like success in NLP and vision.
  • Develop an MLP-based alternative (gMLP) that enables cross-token interactions without self-attention.
  • Evaluate gMLP on ImageNet and MLM tasks to compare with ViT/Transformer baselines.
  • Explore scaling behavior of gMLP versus Transformers across model size and data regimes.
  • Investigate the role of tiny attention when augmenting gMLP in NLP finetuning.

Proposed method

  • Construct gMLP as a stack of blocks with channel projections and a Spatial Gating Unit (SGU) that enforces cross-token interactions via a multiplicative gate.
  • Define SGU as s(Z)=Z ⊙ f_{W,b}(Z), with W initialized near zero and b set to ones to start as an identity.
  • Split Z into Z1, Z2 to implement a two-path gating (Z1 ⊙ f(Z2)).
  • Use a spatial depthwise-like operation for s(·), enabling locality and data-driven kernel shapes learned from data.
  • Train and compare gMLP to ViT/DeiT on ImageNet without external data, using regularization similar to DeiT.
  • Pretrain and finetune gMLP in the BERT setup for MLM, comparing perplexity and downstream tasks to Transformer baselines.
  • Investigate model-size scaling to compare perplexity and GLUE finetuning results across Transformer and gMLP.
  • Evaluate a hybrid model (aMLP) by adding a tiny single-head self-attention to gMLP to assess cross-sentence alignment effects.

Experimental results

Research questions

  • RQ1Is self-attention essential for strong performance in vision and language models, or can an MLP-based architecture suffice?
  • RQ2Can gMLP achieve comparable pretraining perplexity and downstream task performance to Transformers in NLP?
  • RQ3How do gMLP and Transformer models scale with increasing data and compute across vision and NLP benchmarks?
  • RQ4What is the impact of adding a tiny attention module to gMLP on NLP finetuning tasks requiring cross-sentence alignment?
  • RQ5What are the practical trade-offs in parameter efficiency and accuracy between gMLP and Transformer families?

Key findings

  • gMLP achieves comparable accuracy to DeiT on ImageNet under similar training setups with 66% fewer parameters for one variant and outperforms some other MLP-like models.
  • In MLM pretraining, gMLPs with SGU reach perplexity close to Transformers, indicating perplexity tracks model capacity rather than the presence of self-attention.
  • Scaling experiments show deep, capable gMLPs can match or exceed Transformer perplexities and GLUE finetuning scores at similar capacities, with a power-law trend observed in perplexity vs. parameters.
  • A tiny single-head self-attention module (aMLP) substantially improves NLP finetuning across tasks like MNLI and SQuAD, sometimes surpassing Transformers at comparable capacity.
  • The Spacial Gating Unit enables cross-token interactions with a gating mechanism that resembles GLUs and SE blocks but uses static spatial projections, offering a non-attention route to high-order token interactions.
  • Visualization of learned spatial weights indicates gMLP can learn locality and spatial invariance, effectively performing data-driven, irregular convolutions across tokens.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.