MLPs Learn In-Context on Regression and Classification Tasks

William Lingxiao Tong, Cengiz Pehlevan

TL;DR

While in-context learning (ICL) is often hailed as a unique superpower of Transformer architectures, this paper demonstrates that simple Multi-Layer Perceptrons (MLPs) can perform ICL just as well—and sometimes better. On synthetic regression and relational reasoning tasks, MLPs match or exceed Transformer performance under the same compute budget, suggesting that ICL is a property of data diversity and scale rather than a specific architectural "secret sauce."

What Problem Does This Paper Address?

In-context learning—the ability of a model to solve a new task at inference time using only a few examples in the prompt without updating its weights—is the cornerstone of modern Large Language Models (LLMs). Because ICL emerged alongside the Transformer, many researchers assumed that the attention mechanism was strictly necessary to implement the "internal optimization" required for ICL.

Furthermore, a long-standing debate in cognitive science and AI questions whether "simple" neural networks like MLPs are capable of relational reasoning (e.g., identifying that two objects are the same regardless of their specific features). Some recent theoretical work even claimed to prove that MLPs cannot generalize on such tasks. This paper sets out to stress-test these assumptions by comparing MLPs, MLP-Mixers, and Transformers on a level playing field.

Methods

The authors evaluate four primary architectures:

  1. Vanilla MLP: A standard feed-forward network.
  2. MLP-Mixer: An architecture that alternates MLPs across different input dimensions (spatial vs. feature).
  3. Transformer: A standard decoder-only model (the industry benchmark).
  4. Relationally Bottlenecked MLP (RB MLP): A specialized MLP designed specifically for relational tasks.

To ensure a fair comparison, the authors don't just look at parameter counts; they compare models based on a total compute budget (measured in PFLOPs). They use an "online" training regime where models see a continuous stream of fresh synthetic data, allowing them to observe how models transition from memorizing specific examples (In-Weight Learning) to learning the underlying logic of the task (In-Context Learning).

Datasets

The study relies on controlled, synthetic benchmarks designed to isolate ICL capabilities:

  • ICL Regression: The model is given $(x, y)$ pairs where $y = x \cdot \beta + \epsilon$. The weights $\beta$ change for every sequence, forcing the model to infer $\beta$ from the context.
  • ICL Classification: Based on Gaussian Mixture Models where the mapping between clusters and labels is shuffled for each sequence.
  • Relational Reasoning Tasks: Classical psychology-inspired tests including Match-to-Sample (MTS) and Sphere/Line Oddball tasks.
  • Simple (Non-ICL) Baselines: Standard regression and classification to test how architectures handle high-dimensional inputs without the ICL requirement.

Key Insights and Ideas

  • ICL is Not Architecture-Exclusive: Given enough data diversity and compute, MLPs naturally develop ICL capabilities. They exhibit the same "phase transition" from in-weight memorization to in-context reasoning as Transformers.
  • The "Bitter Lesson" Strikes Again: The results support Rich Sutton’s "Bitter Lesson"—general methods that scale with compute (like MLPs) eventually overcome specialized architectures with heavy inductive biases.
  • Circumventing "Impossibility": The authors show that prior "proofs" claiming MLPs can't do relational reasoning relied on a specific, non-standard input format (raw one-hot encodings). By using standard embedding layers, MLPs solve these "impossible" tasks with ease.
  • The Context Length Trade-off: Vanilla MLPs struggle with very long context windows (the "distractor" problem), whereas Transformers and MLP-Mixers are much more robust to increasing context length.
  • Transformer Inefficiency on "Simple" Tasks: Surprisingly, on high-dimensional standard regression (non-ICL), Transformers are significantly less compute-efficient than MLPs unless the input is manually "chunked" into larger tokens.

Key Results

Regression Parity
  • Regression Parity: On ICL regression, MLPs and Transformers achieve nearly identical Mean Squared Error (MSE) when given the same compute budget. Both approach the Bayes-optimal performance (Ridge regression).
  • Relational Superiority: On Match-to-Sample and Oddball tasks, vanilla MLPs actually outperform Transformers, achieving lower loss with less compute and showing better generalization to out-of-distribution (OOD) data.
ICL Classification and Phase Transition
  • IWL-to-ICL Transition: All models showed a sharp transition to ICL as the number of training tasks ($k$) increased. While Transformers made this jump at slightly lower levels of data diversity, MLPs followed closely behind. Furthermore, as context length ($L$) increases, MLPs begin to struggle slightly more than Transformers, highlighting a specific architectural trade-off.

Limitations and Future Work

The primary limitation is the synthetic nature of the tasks. While these benchmarks are excellent for isolating specific mechanics, they lack the complexity, noise, and hierarchical structure of real-world natural language or vision data.

Future research directions suggested by the authors include:

  • Scaling to Real-World Data: Testing if the MLP's ICL performance holds up on massive datasets like Common Crawl.
  • Data Efficiency: Investigating why Transformers seem to require slightly less data diversity to "trigger" the ICL transition compared to MLPs.
  • Hybrid Architectures: Exploring if the strengths of MLPs (efficiency in high dimensions) and Transformers (robustness to context length) can be better combined.

Summary updated

BibTeX
@inproceedings{tong2025mlps,
  author = {William Lingxiao Tong and Cengiz Pehlevan},
  title = {{MLPs Learn In-Context on Regression and Classification Tasks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=MbX0t1rUlp},
}
Figure