Strategy Coopetition Explains the Emergence and Transience of In-Context Learning

Aaditya K. Singh, Ted Moskovitz, Sara Dragutinovic, Felix Hill, Stephanie C. Y. Chan, Andrew M. Saxe

Abstract

In-context learning (ICL) is a powerful ability that emerges in transformer models, enabling them to learn from context without weight updates. Recent work has established emergent ICL as a transient phenomenon that can sometimes disappear after long training times. In this work, we sought a mechanistic understanding of these transient dynamics. Firstly, we find that, after the disappearance of ICL, the asymptotic strategy is a remarkable hybrid between in-weights and in-context learning, which we term "context-constrained in-weights learning" (CIWL). CIWL is in competition with ICL, and eventually replaces it as the dominant strategy of the model (thus leading to ICL transience). However, we also find that the two competing strategies actually share sub-circuits, which gives rise to cooperative dynamics as well. For example, in our setup, ICL is unable to emerge quickly on its own, and can only be enabled through the simultaneous slow development of asymptotic CIWL. CIWL thus both cooperates and competes with ICL, a phenomenon we term "strategy coopetition." We propose a minimal mathematical model that reproduces these key dynamics and interactions. Informed by this model, we were able to identify a setup where ICL is truly emergent and persistent.

Introduction

Large Language Models (LLMs) are renowned for In-Context Learning (ICL)—the ability to solve new tasks by observing examples in a prompt without weight updates. However, recent observations of "transience" have puzzled researchers: during training, a model might achieve high ICL accuracy only to "forget" it later, eventually favoring internal memorized weights (In-Weights Learning, or IWL). This paper investigates the mechanistic "why" behind this phenomenon, proposing that ICL and a more complex strategy called Context-Constrained In-Weights Learning (CIWL) exist in a state of "strategy coopetition."

Methods and Experimental Setup

The researchers utilized 2-layer, attention-only Transformers as a "model organism" for mechanistic interpretability. The models were trained on a few-shot learning task using the Omniglot dataset of handwritten characters. The training data was "bursty," meaning the context typically contained the necessary label for a query image, but the specific image-to-label mapping could vary.

Figure 1: (a) Task setup, (b) training dynamics, and (c) mechanistic circuit diagram.

To analyze the internal dynamics, the authors used causal ablations and attention pattern analysis. They identified a hybrid strategy, CIWL, which uses context to locate the correct label token but relies on internal weights to recognize the image class. This acts as a "skip-trigram" mechanism: "If I see Image X and Label Y in context, and I see Image X now, output Label Y."

Strategy Coopetition: Cooperation and Competition

The core finding is that ICL and CIWL are "coopetitors" that share sub-circuits while competing for control over others.

Cooperation in Layer 2

Both strategies rely on the same "induction head" circuitry in Layer 2. CIWL is slow to learn but ultimately more accurate. ICL "hitches a ride" on the Layer 2 circuits being built for CIWL, allowing it to emerge quickly as a "shortcut." This was verified by transplanting late-stage Layer 2 weights into early-stage models, which triggered immediate ICL emergence.

Competition in Layer 1

The strategies diverge in Layer 1. ICL requires Layer 1 to attend to previous tokens to enable induction. In contrast, CIWL requires Layer 1 to attend to the current token ("self") to facilitate image recognition via internal weights. As training progresses, the pressure to optimize for the superior CIWL strategy causes Layer 1 to favor self-attention, eventually displacing the ICL mechanism.

Key Results

The training process follows a predictable "transience curve" (Figure 1b). ICL accuracy peaks early (3-5 million sequences) and then plummets, while CIWL accuracy climbs steadily toward 100%.

Figure 2: Attention strength and its correlation with in-context accuracy.

Analysis of attention patterns (Figure 2) confirms that Layer 2 heads act as induction heads, with their strength directly correlating with in-context performance. Furthermore, the researchers found that ICL can be made persistent if context examples are exact matches for the query (rather than just the same class), suggesting that data variety and task difficulty are primary drivers of transience.

Conclusion

This study provides a mechanistic framework for understanding the emergence and transience of ICL. By identifying the coopetitive relationship between in-context and in-weights strategies, we can better understand how Transformers prioritize different learning mechanisms. Future research will explore these dynamics in larger models with MLPs and investigate if similar patterns occur in natural language processing tasks.

Summary updated

BibTeX
@inproceedings{singh2025strategy,
  author = {Aaditya K. Singh and Ted Moskovitz and Sara Dragutinovic and Felix Hill and Stephanie C. Y. Chan and Andrew M. Saxe},
  title = {{Strategy Coopetition Explains the Emergence and Transience of In-Context Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=esBoQFmD7v},
}
Figure