On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning
Not on the map. Why?
Abstract (arXiv)
Transformer-based models demonstrate a remarkable ability for in-context learning (ICL), where they can adapt to unseen tasks from a few prompt examples without parameter updates. Recent research has illuminated how Transformers perform ICL, showing that the optimal linear self-attention (LSA) mechanism can implement one step of gradient descent for linear least-squares objectives when trained on random linear regression tasks. Building on this, we investigate ICL for nonlinear function classes. We first prove that LSA is inherently incapable of outperforming linear predictors on nonlinear tasks, underscoring why prior solutions cannot readily extend to these problems. To overcome this limitation, we analyze a Transformer block consisting of LSA and feed-forward layers inspired by the gated linear units (GLU), which is a standard component of modern Transformers. We show that this block achieves nonlinear ICL by implementing one step of gradient descent on a polynomial kernel regression loss. Furthermore, our analysis reveals that the expressivity of a single block is inherently limited by its dimensions. We then show that a deep Transformer can overcome this bottleneck by distributing the computation of richer kernel functions across multiple blocks, performing block-coordinate descent in a high-dimensional feature space that a single block cannot represent. Our findings highlight that the feed-forward layers provide a crucial and scalable mechanism by which Transformers can express nonlinear representations for ICL.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). Builds on 40 of its 47 references that are in the map. First posted on arXiv 30 Jan 2025.
Builds on
40 of 47 references.
References · 40
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2023GPT-4 Technical Reportcited by 18,132
- 2014Neural Machine Translation by Jointly Learning to Align and Translatecited by 4,530
- 2022Robust Speech Recognition via Large-Scale Weak Supervisioncited by 3,972
- 2022Emergent Abilities of Large Language Modelscited by 2,483
- 2020GLU Variants Improve Transformercited by 1,724
- 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,283
- 2022In-context Learning and Induction Headscited by 930
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
28 more
- 2016Language Modeling with Gated Convolutional Networkscited by 688
- 2023The Dawn of LMMs: Preliminary Explorations with GPT-4V(ision)cited by 677
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2023Gated Linear Attention Transformers with Hardware-Efficient Trainingcited by 490
- 2024Gated Delta Networks: Improving Mamba2 with Delta Rulecited by 483
- 2021MetaICL: Learning to Learn In Contextcited by 450
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
- 2023Looped Transformers as Programmable Computerscited by 224
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
- 2025MiniMax-01: Scaling Foundation Models with Lightning Attentioncited by 157
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 115
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 114
- 2023In-Context Convergence of Transformerscited by 112
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 101
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
- 2023Transformers as Decision Makers: Provable In-Context Reinforcement Learning via Supervised Pretrainingcited by 82
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 72
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 71
- 2023Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In Contextcited by 63
- 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 62
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 36
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 30
- 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 29
Built on by
Citing papers per year: 2025: 2; 2026: 5.
7 papers.
- 2025Gating is Weighting: Understanding Gated Linear Attention through In-context Learningcited by 11
- 2026Understanding In-Context Learning for Nonlinear Regression with Transformers: Attention as Featurizercited by 2
- 2025Mamba Can Learn Low-Dimensional Targets In-Context via Test-Time Feature Learningcited by 1
- 2026Bayesian Optimality of In-Context Learning with Selective State Spacescited by 1
- 2026Why LLMs Fail at Causal Discovery and How Interventional Agents Escapecited by 1
- 2026Transformers Can Implement Preconditioned Richardson Iteration for In-Context Gaussian Kernel Regressioncited by 0
- 2026When Does Depth Matter For In-Context Learning? Adaptive Inference in Deep Transformerscited by 0
- 2026When Does Depth Matter For In-Context Learning? Adaptive Inference in Deep Transformers15 Jun 2026
- 2026Why LLMs Fail at Causal Discovery and How Interventional Agents Escape26 May 2026
- 2026Transformers Can Implement Preconditioned Richardson Iteration for In-Context Gaussian Kernel Regression8 May 2026
- 2026Understanding In-Context Learning for Nonlinear Regression with Transformers: Attention as Featurizer6 May 2026
- 2026Bayesian Optimality of In-Context Learning with Selective State Spaces19 Feb 2026
- 2025Mamba Can Learn Low-Dimensional Targets In-Context via Test-Time Feature Learning14 Oct 2025
- 2025Gating is Weighting: Understanding Gated Linear Attention through In-context Learning6 Apr 2025