Understanding In-Context Learning via Supportive Pretraining Data

Xiaochuang Han, Daniel Simig, Todor Mihaylov, Yulia Tsvetkov, Asli Celikyilmaz, Tianlu Wang

TL;DR

This paper investigates the mystery of In-Context Learning (ICL) by identifying the specific "supportive" instances within a model's pretraining data that drive this emergent ability. The authors discover that ICL isn't fueled by domain similarity to downstream tasks, but rather by challenging pretraining examples that feature rare tokens and difficult-to-integrate long-range context.

What Problem Does This Paper Address?

Large Language Models (LLMs) possess the remarkable ability to learn new tasks at inference time simply by looking at a few examples—a phenomenon called In-Context Learning (ICL). However, why this happens is still a "black box." Models are trained on massive, unstructured corpora that look nothing like the structured "Input: [text] / Category: [label]" format of an ICL prompt (see Figure 1).

Figure 1: An example from the pretraining data of OPT (Zhang et al., 2022b) and an illustrative in-context learn- ing example of topic classification. The in-context learn- ing task data can be drastically different from pretraining instances, both in content and format.

While previous research has looked at the internal mechanisms (like "induction heads") or theoretical frameworks (like implicit Bayesian inference), this paper asks a more fundamental question: From which specific parts of the pretraining data does a model acquire its ICL ability?

Methods

The authors employ a three-step approach:

  1. ORCA-ICL Selection: They adapted a gradient-based method called ORCA to search through a large subset of the OPT model's pretraining corpus. The algorithm (detailed in Figure 2) identifies instances whose gradients are most similar to the gradients produced by ICL task data. Essentially, it finds pretraining text that "pushes" the model's parameters in the same direction as learning from in-context examples would.
  2. Perturbative Continued Pretraining: To prove these identified instances are actually "supportive," they perform a very small amount of additional training (one-pass SGD) on the original model using only this tiny subset (less than 2,000 instances).
  3. Contrastive Analysis: They then compare this "supportive" subset against random pretraining data across three dimensions: domain relevance, token frequency, and long-range information gain.
Figure 2: ORCA-ICL, an iterative gradient-based selec- tion of supportive pretraining data for ICL.

Datasets

  • Model: The authors used OPT-6.7B, a large open-source transformer.
  • Pretraining Data: A 2.5 million instance subset (roughly 5 billion tokens) of the original OPT pretraining corpus.
  • Evaluation Tasks: 6 diverse classification tasks from the Natural Instructions v2 benchmark, including sentiment analysis (SST-2), news classification (AG News), and coherence detection (Story Cloze).

Key Insights and Ideas

The most striking findings come from the analysis of what makes data "supportive":

  • Domain Relevance is a Red Herring: Contrary to intuition, supportive data is not more semantically similar to the downstream tasks. Using MAUVE scores to measure distribution divergence, the authors found no significant difference in domain relevance between supportive and random data (Figure 3). ICL seems to be a "meta-ability" rather than just a transfer of domain knowledge.
  • The Power of the Long Tail: Supportive data has a significantly lower Zipf’s coefficient, meaning it contains a higher proportion of rare, "long-tail" tokens (Figure 4). Exposure to these rare tokens may force the model to rely more on immediate context rather than global statistics.
  • Difficulty Drives Learning: The authors proposed a novel "Information Gain" (IG) measure to see how much long-range context helps predict the next token. Supportive data showed lower relative information gain from long context (Figure 5). This suggests these are "challenging" examples where the model must work harder to figure out which parts of a long context are actually relevant—a skill directly applicable to ICL, where the model must distinguish between multiple demonstration examples.

Figure 3: MAUVE scores showing no significant domain relevance advantage for supportive data. Figure 4: Zipf's coefficients showing supportive data contains more rare tokens.

Key Results

  • ICL Boost: Continued pretraining on the supportive subset improved ICL performance by up to 18% (e.g., SST-2 accuracy jumped from 75.47% to 83.15%).
  • Specificity: Crucially, this training did not improve zero-shot performance. This confirms the selected data specifically supports the mechanism of learning from demonstrations, rather than just making the model better at the task in general.
  • Universality: Supportive data selected for one task often improved performance on others, suggesting that the underlying mechanisms for ICL are somewhat universal across different classification tasks.

Limitations and Future Work

  • Computational Cost: The ORCA-ICL method is computationally expensive, requiring backpropagation through millions of pretraining instances. Finding supportive data for a single task took about a week on 32 V100 GPUs.
  • Causality vs. Correlation: While the continued pretraining results are promising, the analysis of data features (rare tokens, long-range difficulty) remains primarily correlational.
  • Task Scope: The study focused exclusively on classification. Future work is needed to see if these insights hold for generative tasks like summarization or code generation.
  • Data Engineering: The authors suggest that instead of just finding supportive data, future work could focus on generating or synthesizing pretraining data that intentionally includes these supportive features to build more capable ICL models from scratch.
Figure 5: Information gain analysis showing supportive data is more challenging.

Summary updated

BibTeX
@inproceedings{han2023understanding,
  author = {Xiaochuang Han and Daniel Simig and Todor Mihaylov and Yulia Tsvetkov and Asli Celikyilmaz and Tianlu Wang},
  title = {{Understanding In-Context Learning via Supportive Pretraining Data}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.708},
}
Figure