The Transient Nature of Emergent In-Context Learning in Transformers

Aaditya K Singh, Stephanie C.y. Chan, Ted Moskovitz, Erin Grant, Andrew M Saxe, Felix Hill

Introduction

In-context learning (ICL) is widely considered a permanent "superpower" that transformer-based Large Language Models (LLMs) acquire as they scale. We have grown accustomed to the idea that models can perform tasks they weren't explicitly trained for simply by observing a few examples in a prompt. Most researchers have assumed that once a model "learns how to learn" in-context, it retains that ability indefinitely.

However, this paper reveals a surprising phenomenon: ICL is frequently transient. While it emerges early in training, it can eventually vanish. It is often replaced by a competing strategy known as "in-weights learning" (IWL), where the model simply absorbs the task's underlying logic or data mappings into its static parameters (memorization). This raises a critical question: if a task can be solved by both ICL and IWL, which strategy does the transformer prefer in the long run? This tension is especially relevant today as the industry increasingly moves toward "overtraining" smaller models on massive datasets to maximize inference efficiency.

Methodology: Pitting ICL Against IWL

To investigate the competition between these two learning strategies, the researchers used a controlled synthetic environment. They trained standard Transformer models (typically 12 layers) on sequences of "exemplar-label" pairs.

  • The Setup: The training data was designed to be "bursty"—meaning the same class appeared multiple times in a single sequence. This structure incentivizes the model to look at the context to make predictions.
  • Dual Evaluation: To determine which strategy the model was actually using, the authors employed two distinct test sets.
  • ICL Evaluator: Used randomized labels for known classes. To succeed, the model must use the provided context because its internal weights contain the "wrong" mapping.
  • IWL Evaluator: Provided no helpful context. To succeed, the model must rely on the mappings it memorized in its weights during training.
Experimental setup demonstrating how training data is structured and how ICL and IWL are distinctly evaluated.

The researchers utilized datasets like Omniglot (a classic benchmark of handwritten characters) to create image-based few-shot tasks. To ensure their findings generalized beyond images, they also clustered token embeddings from the LLaMa 1 family of models to create synthetic language-like datasets, and modified class frequencies to mimic natural language Zipfian distributions.

Key Findings: The Transience of ICL

ICL is a Phase, Not a Destination

The most striking finding is that in many settings, ICL accuracy follows a distinct "hump" shape. It rises quickly, peaks, and then slowly decays toward chance levels. Crucially, this decay happens even as the total training loss continues to drop.

Training dynamics showing ICL accuracy peaking and decaying, while IWL accuracy rises and training loss steadily decreases.

Transformers appear to view IWL as the "better" solution for minimizing loss in the limit. ICL serves as a highly effective "starter" strategy early in training, but the model eventually prefers to hardcode the answers into its weights. In models trained for 5e7 steps, ICL accuracy often dropped from peaks of ~80% down to near-chance, while IWL accuracy steadily climbed.

Circuit Competition and Regularization

The authors suggest this transience is caused by competition between ICL and IWL circuits for "real estate" within the transformer's residual stream. As the IWL circuit grows stronger and more complex, it effectively crowds out the ICL mechanism.

Interestingly, IWL circuits appear to require higher weight norms—they are "heavier" in the weights. By applying L2 regularization (weight decay), the researchers found they could suppress the IWL strategy and force the model to maintain its ICL capabilities indefinitely. Furthermore, applying weight decay specifically to the MLP layers (where IWL information is primarily stored) was highly effective at preserving ICL, whereas applying it only to attention layers did not stop ICL from fading.

The Role of Data Distribution

The data distribution plays a massive role in how long ICL survives. Using a Zipfian distribution (where a few classes are very common and most are rare, mimicking natural language) significantly delayed the disappearance of ICL. This likely explains why the "vanishing ICL" phenomenon has not been as obvious in LLMs trained on standard web text.

Conclusion and Future Work

The primary limitation of this study is scale. While the authors used LLaMa embeddings to bridge the gap to natural language, compute constraints prevented them from training billion-parameter models on web-scale text. It remains to be seen if ICL decay happens at the exact same rate in massive, state-of-the-art models.

Future work could explore the "flipped-ICL" phenomenon—where a model might use a mix of both strategies—and investigate whether specific initialization schemes or optimizers could naturally favor ICL without heavy-handed regularization.

Ultimately, this paper serves as an important warning for modern AI development: if you overtrain your model purely to achieve the lowest possible loss, you might accidentally be training away its ability to reason from your prompts.

Summary updated

BibTeX
@inproceedings{singh2023transient,
  author = {Aaditya K Singh and Stephanie C.Y. Chan and Ted Moskovitz and Erin Grant and Andrew M Saxe and Felix Hill},
  title = {{The Transient Nature of Emergent In-Context Learning in Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=Of0GBzow8P},
}
Figure