Papers › Pay Attention to MLPs

Pay Attention to MLPs

17 May 2021NeurIPS 2021 12arXiv:2105.08050archive 2025-07-28

Hanxiao Liu, Zihang Dai, David R. So, Quoc V. Le

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2105.08050")

Code

Syntology Ran 34 of 44 code samples harvested from 10 repositories linked to this paper; 10 have no recorded run. Of those that ran: 1 ran · honoured contract; 4 ran · violated contract; 2 ran · our draft was wrong; 1 ran · fixture could not drive it; 26 ran with no contract checked.

By repository: community (archive-listed): 41 samples from 10 repositories, 31 ran; 3 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

20 repositories listed; official and paper-mentioned ones first.

NydiaAI/g-mlp-tensorflow mentioned on GitHubtf report
antonyvigouret/Pay-Attention-to-MLPs mentioned on GitHubpytorch report
cvolcy/gmlp-tf mentioned on GitHubtf report
jaketae/g-mlp mentioned on GitHubpytorch report
leaderj1001/Bag-of-MLP mentioned on GitHubpytorch report
liuruiyang98/Jittor-MLP mentioned on GitHubjax report
lucidrains/FLASH-pytorch mentioned on GitHubpytorch report
lucidrains/g-mlp-gpt mentioned on GitHubpytorch report
lucidrains/g-mlp-pytorch mentioned on GitHubpytorch report
lucidrains/mlp-gpt-jax mentioned on GitHubjax report
radi-cho/gatedtabtransformer mentioned on GitHubpytorch report
rwightman/pytorch-image-models mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

44 samples harvested; 34 ran; 1 honoured the contract we drafted; 10 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
4ran · violated contract
2ran · our draft was wrong
1ran · fixture could not drive it
26ran
10unverified

Licence: 11 of the 44 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 10 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Attention lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran MIT (permissive) · 444b2d5ae8422156 · report
Attention lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted MIT (permissive) · 400cf93bc9a76062 · report
CausalLocalSGU lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted MIT (permissive) · 3bb856991018170a · report
CausalSGU lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · 7a6075afb6e7a2c2 · report
GELU NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted no licence file found · pointer only · 36c054162a22371c · report
GatingMlpBlock antonyvigouret/Pay-Attention-to-MLPs/models.py community (archive-listed) ran MIT (permissive) · cb304156fe457ec9 · report
LocalAttention lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted MIT (permissive) · 94e83172b0355df5 · report
PreShiftTokens lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran fingerprinted MIT (permissive) · c78c09b8919ac748 · report
Residual xmu-xiaoma666/External-Attention-pytorch/model/mlp/g_mlp.py community (archive-listed) ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · 9cceceb3671335d7 · report
Residual lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran fingerprinted MIT (permissive) · 4b858823b3eccdd7 · report
Residual NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) ran fingerprinted no licence file found · pointer only · f9f191324f0a26fb · report
SpatialGatingUnit xmu-xiaoma666/External-Attention-pytorch/model/mlp/g_mlp.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · 9c81afbca1a2169c · report
SpatialGatingUnit antonyvigouret/Pay-Attention-to-MLPs/models.py community (archive-listed) ran MIT (permissive) · 1356a744f3730d9c · report
SpatialGatingUnit jaketae/g-mlp/g_mlp/core.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · d300d8fa28344b6c · report
SpatialGatingUnit cvolcy/gmlp-tf/gmlp.py community (archive-listed) ran no licence file found · pointer only · 2098e31f03598b8e · report
SpatialGatingUnit lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran MIT (permissive) · 6d43444c56cad017 · report
SpatialGatingUnit leaderj1001/Bag-of-MLP/model.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · f84eabb818f0b01a · report
TinyAttention leaderj1001/Bag-of-MLP/model.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · ccc79f7e78680ff2 · report
cast_tuple lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · violated contract fingerprinted MIT (permissive) · 092c152ffc42d497 · report
dropout_layers lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 1d39b4f9d1d36f92 · report
exist xmu-xiaoma666/External-Attention-pytorch/model/mlp/g_mlp.py community (archive-listed) ran · violated contract MIT (permissive) · 62c69ec0b60162c6 · report
gMLP xmu-xiaoma666/External-Attention-pytorch/model/mlp/g_mlp.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · b9fa9cafe23e12fb · report
gMLP antonyvigouret/Pay-Attention-to-MLPs/models.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · 5a39fbe0ee0a5529 · report
gMLP jaketae/g-mlp/g_mlp/core.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · 2949429d580ede4b · report
gMLP leaderj1001/Bag-of-MLP/model.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · bfbcb5bb0523c7c8 · report
gMLPBlock jaketae/g-mlp/g_mlp/core.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · 3f7743323edaa181 · report
gMLPBlock lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran MIT (permissive) · 63d8448fca0c6967 · report
gMLPBlock leaderj1001/Bag-of-MLP/model.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · af39a3c7ed4a3a0c · report
gMLPLayer cvolcy/gmlp-tf/gmlp.py community (archive-listed) ran no licence file found · pointer only · 683c46ded1adfd74 · report
pad_to_multiple lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · df3be65159852cd8 · report
shift lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) ran · fixture could not drive it fingerprinted MIT (permissive) · 2fdf59e29c6d95cc · report
Attention lucidrains/mlp-gpt-jax/mlp_gpt_jax/mlp_gpt_jax.py community (archive-listed) unverified MIT (permissive) · 01675e7e7c713147 · report
PreNorm NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) unverified no licence file found · pointer only · 2c295e59b874c818 · report
SGU lucidrains/mlp-gpt-jax/mlp_gpt_jax/mlp_gpt_jax.py community (archive-listed) unverified MIT (permissive) · 1b9ff0230e5d08d3 · report
SpatialGatingUnit NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) unverified no licence file found · pointer only · 51216a9ccabc7c3f · report
gMLP lucidrains/mlp-gpt-jax/mlp_gpt_jax/mlp_gpt_jax.py community (archive-listed) unverified MIT (permissive) · c1658eda58b9fa37 · report
gMLP lucidrains/g-mlp-pytorch/g_mlp_pytorch/g_mlp_pytorch.py community (archive-listed) unverified MIT (permissive) · 0330d8c0ae7e5def · report
gMLP radi-cho/gatedtabtransformer/gated_tab_transformer/g_mlp.py community (archive-listed) unverified MIT (permissive) · 2e5cc43cba18a48d · report
gMLP NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) unverified no licence file found · pointer only · 211dccfc0c5af2fa · report
gMLPBlock lucidrains/g-mlp-gpt/g_mlp_gpt/g_mlp_gpt.py community (archive-listed) unverified MIT (permissive) · d16a844fcf910249 · report
gMLPBlock NydiaAI/g-mlp-tensorflow/gmlp/gmlp.py community (archive-listed) unverified no licence file found · pointer only · a5c1690311b9aad2 · report
check_sizes identical code first harvested elsewhere ran · honoured contract fingerprinted licence of this copy not recorded · 27cbea18b00696e9 · report
exists identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · aa5486a3650902d8 · report
pair identical code first harvested elsewhere ran · violated contract fingerprinted licence of this copy not recorded · e6f9d3b5ad66ee20 · report

Tasks

Image ClassificationNatural Language InferenceQuestion AnsweringSentiment Analysis

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification ImageNet gMLP-B GFLOPs 31.6 #628 of 1060 Archive leaderboard report
Image Classification ImageNet gMLP-B Number of params 73M #628 of 1060 Archive leaderboard report
Image Classification ImageNet gMLP-B Top 1 Accuracy 81.6% #628 of 1060 Archive leaderboard report
Natural Language Inference MultiNLI gMLP-large Matched 86.2 #27 of 67 Archive leaderboard report
Natural Language Inference MultiNLI gMLP-large Mismatched 86.5 #27 of 67 Archive leaderboard report
Question Answering SQuAD2.0 gMLP-large F1 78.3 #286 of 286 Archive leaderboard report
Sentiment Analysis SST-2 Binary classification gMLP-large Accuracy 94.8 #30 of 87 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Introduced by this paper: Spatial Gating Unit, gMLP

AdamAttentionAttention DropoutBERTDense ConnectionsDropoutLayer NormalizationLinear LayerLinear Warmup With Linear DecayMulti-Head AttentionResidual ConnectionSoftmaxSpatial Gating UnitWeight DecayWordPiecegMLP

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections