NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Why Transformers Struggle with Distribution-Independent In-Context Learning

Omar Naim, Jerome Bolte, Nicholas Asher

NeurIPS page · OpenReview · Open on the map

Category: Interpretability & Model Adaptation › Transformer In-Context Learning · Type: empirical study · Keywords: in-context learning, distribution shift, transformer architecture, normalization, attention bottleneck

Areas: Model Architectures & Sequence Modeling › Language Model Architectures › Attention Geometry; Continual Learning & Adaptation › Non-Stationarity Adaptation › Generalization and Adaptation

Summary

The paper shows that transformers' in-context learning collapses under distribution shift because of a readout-side scale constraint from final normalization and attention becoming a context bottleneck, and it identifies these two mechanisms as key explanations.

Explained to a 5-year-old

Imagine a robot that learns to draw pictures by looking at a few examples. When the robot sees new pictures that look just like the old ones, it does a great job. But when the new pictures are very different, the robot gets confused and makes mistakes. The scientists found that two things cause this: the robot’s final step limits how big its answers can be, and it pays too much attention to only a small part of the examples. Knowing this helps us build better robots.

Explained to a 5-year-old, longer

A robot can learn to do a task by watching a few examples. If the new examples look similar to the old ones, the robot works well. But if the new examples are very different, the robot often makes mistakes. The researchers looked at a simple math problem where the robot tries to guess numbers. They used a kind of robot called a transformer that many people use today. They compared the robot’s performance to simple math rules like least squares. They found that the robot was almost perfect when the math was the same as before. When the numbers were scaled up or the problem changed, the robot suddenly failed. They discovered two reasons for this failure. First, the robot’s final step has a rule that caps how large its answers can be. Second, the robot’s attention focuses on only a few parts of the examples, missing important clues. Understanding these issues helps scientists design robots that are more reliable.

For a technical reader

The paper investigates why transformer models, which can learn new tasks from a few examples at inference time, break down when the data distribution changes. Using controlled regression tasks, the authors show that transformers achieve near-perfect performance on familiar data but suffer a sharp drop when the scale or support of the data shifts. They identify two architectural factors: final layer normalization imposes a scale constraint that caps predictions, and attention can become a bottleneck by focusing on only a small portion of the prompt. Simple baselines like least-squares and kernel methods remain stable under the same shifts, highlighting the limitation of relying solely on ICL. The results suggest that practitioners should be cautious using ICL for deployment in environments where data distributions may vary and consider explicit adaptation strategies.

Problem

Understanding whether transformer models can perform in-context learning reliably when the test distribution differs from that seen during training.

Method

The authors conduct controlled regression experiments with polynomial tasks, evaluate transformers across in-distribution and distribution-shifted settings, and compare against simple baselines such as least-squares and kernel methods. They systematically ablate final normalization and attention mechanisms to isolate their effects on ICL performance.

Results

Transformers perform near-perfect in-context learning on the training distribution but collapse sharply under distribution shift, while simple baselines such as least-squares and kernel methods maintain performance.

Contributions

The paper demonstrates that strong in-distribution ICL does not guarantee distribution-independent ICL, identifies final normalization and attention bottlenecks as key causes, and provides empirical evidence across polynomial tasks and shift types.

Practical relevance

The findings caution against relying on ICL for tasks where data distributions may shift, suggesting the need for explicit adaptation or retraining in real-world deployments.

Research questions this paper is counted under

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction