Abstract
In-Context Learning (ICL) allows Large Language Models (LLMs) to perform new tasks using only a few examples in the prompt without weight updates. This paper investigates the underlying mechanism of ICL, proposing that it is fundamentally driven by token co-occurrence reinforcement. By analyzing how models strengthen relationships between tokens based on repetition, the authors demonstrate that while this mechanism enables complex behaviors like Chain-of-Thought, it also introduces vulnerabilities to spurious correlations and label bias if demonstrations are unbalanced.
Introduction
Large Language Models exhibit a remarkable ability to learn from context. Despite its widespread use, the internal mechanics of ICL remain an open question. Previous research has focused on input-to-label mapping or example ordering. This paper takes a feature-centric view, investigating whether ICL is a sophisticated form of "surface repetition." The authors aim to bridge the gap between the known "self-reinforcement effect"—the tendency of models to repeat sequences found in their context—and the complex reasoning seen in ICL tasks.
Methodology
The study employs quantitative analysis and ablation studies to dissect the ICL mechanism:
- Quantifying Reinforcement: Measuring how the probability of a token increases as its preceding context is repeated, distinguishing between successive and distant reinforcement.
- Masked Demonstrations: Replacing specific prompt components (e.g., question text, formatting tokens) with random tokens to isolate what drives model behavior.
- Pre-training Analysis: Training a 267M parameter model from scratch to prove that token reinforcement is an inevitable byproduct of the standard language modeling objective.
- Intervention: Using attention masking to show that the reinforcement effect relies on the model's ability to attend to immediately preceding tokens.
The Mechanism of Token Reinforcement
The authors establish that token co-occurrence reinforcement is the fundamental building block of ICL. The connection between any two tokens is reinforced simply by the number of times they co-occur in the context.
Surprisingly, in tasks like MMLU, the actual content of questions in demonstrations matters less for task adherence than formatting tokens (like Answer:) and option names (like A., B.). These surface features constrain the "output space," guiding the model on how to answer rather than what the answer is. Larger models, such as LLaMA-65B, excel at "distant reinforcement," explaining their superior ability to follow complex, long-form instructions.
Experimental Results
One of the most striking findings is the magnitude of the probability boost provided by repetition. In a simple test, the probability of a model generating a specific token (e.g., "A" after "Answer is") jumped from 0.03 to nearly 1.0 after just a few repetitions.
Further experiments on the MMLU dataset showed that masking question content had almost no impact on the model's ability to output a valid label (A, B, C, or D), whereas removing formatting tokens caused the model to drift into irrelevant text. This confirms that the model primarily uses the prompt to identify the expected structure and label space.
The Impact of Demonstration Balance
While reinforcement enables Chain-of-Thought reasoning by allowing the model to follow structural logic, it is a double-edged sword. If a prompt repeats a specific label too often, the model latches onto that "spurious connection," often ignoring the actual logic of the test query.
By intentionally unbalancing demonstrations (e.g., making all example answers "D"), the authors could drive the accuracy of the "D" class up significantly (from ~52% to ~77%), but at a heavy cost to the accuracy of other classes. This proves that ICL is highly sensitive to the distribution of labels in the prompt.
Conclusion and Future Work
This research identifies surface-level token reinforcement as a primary driver of ICL. While this explains how models follow patterns, it also highlights a reliance on surface features over deep semantic reasoning. Future work is needed to address the "spurious connections" that cause ICL failure, potentially through new decoding strategies that balance reinforcement with logical consistency. Understanding these mechanisms is a crucial step toward building more robust and less biased language models.
Summary updated