Source-linked AI summary
Data Distributional Properties Drive Emergent In-Context Learning in Transformers
Stephanie C. Y. Chan, Adam Santoro, Andrew K. Lampinen, Jane X. Wang, Aaditya Singh, Pierre H. Richemond, Jay McClelland, Felix Hill
TL;DR
The paper asks why transformer models acquire in-context few-shot learning without explicit meta-training, and tests whether training-data distributions help explain this emergence. By manipulating naturalistic properties in Omniglot sequences and comparing architectures, it finds that burstiness, many rare classes, and dynamic interpretations promote in-context learning, while Zipfian skew can support both contextual and weight-based learning. The results indicate that architecture and data distributions jointly shape the behavior, with scope bounded by the study’s experimental setting and remaining open questions about broader training regimes.
Problem
The paper investigates why in-context learning emerges in transformer language models without being explicitly targeted and whether architecture or training-data distributions account for it.
Method
The authors manipulate naturalistic distributional properties in Omniglot image-label training sequences and evaluate in-context and in-weights learning across transformer and recurrent models.
Results
In-context learning emerges in transformers with burstiness and many rarely occurring classes, is strengthened by dynamic interpretations, and can coexist with in-weights learning under Zipfian class skew.
Takeaways & Limitations
Naturalistic data distributions can promote genuine in-context learning on classes never seen during training, while transformers and data properties both contribute.
Takeaways & Limitations
The study leaves open how these distributional properties interact with other losses, language-modeling setups, contextual meanings, and transformer–recurrent differences.
Abstract
from arXiv · showhide
Large transformer-based models are able to perform in-context few-shot learning, without being explicitly trained for it. This observation raises the question: what aspects of the training regime lead to this emergent behavior? Here, we show that this behavior is driven by the distributions of the training data itself. In-context learning emerges when the training data exhibits particular distributional properties such as burstiness (items appear in clusters rather than being uniformly distributed over time) and having large numbers of rarely occurring classes. In-context learning also emerges more strongly when item meanings or interpretations are dynamic rather than fixed. These properties are exemplified by natural language, but are also inherent to naturalistic data in a wide range of other domains. They also depart significantly from the uniform, i.i.d. training distributions typically used for standard supervised learning. In our initial experiments, we found that in-context learning traded off against more conventional weight-based learning, and models were unable to achieve both simultaneously. However, our later experiments uncovered that the two modes of learning could co-exist in a single model when it was trained on data following a skewed Zipfian distribution -- another common property of naturalistic data, including language. In further experiments, we found that naturalistic data distributions were only able to elicit in-context learning in transformers, and not in recurrent models. In sum, our findings indicate how the transformer architecture works together with particular properties of the training data to drive the intriguing emergent in-context learning behaviour of large language models, and how future work might encourage both in-context and in-weights learning in domains beyond language.
1 Introduction
The paper asks why in-context learning emerges in transformers without explicit meta-training, and tests whether architecture and naturalistic training-data distributions jointly account for it. Experiments implicate burstiness, many rare classes, and data distributions that shift learning between context and weights.
- 1 Introduction: The central question is whether transformer architecture or training-data distributions explain emergent in-context learning without explicitly targeting it.The paper examines both possibilities experimentally.
- 1 Introduction: Natural data differs from standard supervised data through temporal burstiness, skewed Zipfian class frequencies, and potentially dynamic meanings.These properties place training data between conventional supervised learning and explicitly episodic few-shot meta-training.
- 1 Introduction: Burstiness and increasing the number of classes improve in-context learning but reduce in-weights learning, revealing a tradeoff between the two modes.The burstiness experiments also show in-context learning tending to decrease while in-weights learning increases over training.
- 1 Introduction: The experiments manipulate training-data distributions using Omniglot sequences and evaluate whether those properties produce in-context learning.Models include transformers and recurrent networks, enabling architectural comparisons.
- 1 Introduction: In-context learning emerges in transformers when training data combines burstiness with enough rarely occurring classes, while dynamic interpretations further bias models toward it.The tested dynamic-interpretation interventions were multiple labels per item and within-class variation.
- 1 Introduction: Recurrent models failed to exhibit in-context learning on the same data, while transformers trained on unsuitable distributions also failed.The result supports a joint role for architecture and data rather than architecture alone.
2 Experimental Design
The experiments train models on image-label sequences with fixed class mappings and manipulate burstiness while separately testing in-context and in-weights learning. Evaluation uses novel relabeled classes for context learning and trained classes without contextual support for weight-based learning.
- 2 Experimental Design: Omniglot supplies 1623 character classes with 20 handwritten examples each for constructing few-shot training and evaluation sequences.The dataset provides a standard image-label setting for few-shot learning.
- 2 Experimental Design: Each training sequence contains eight image-label context pairs followed by a query image whose label the model must predict.The context occupies the first 16 sequence elements, and the query is the final element.
- 2 Experimental Design: Images recur during training, while each image class retains a unique fixed integer label across sequences.This differs from conventional few-shot training, where items or item-label mappings are novel across episodes.
- 2 Experimental Design: Training mixes bursty sequences, where the query class appears three times in context, with non-bursty sequences.The bursty condition is designed to reflect within-context clustering.
- 2 Experimental Design: A causal transformer processes embedded image and label tokens and is trained with softmax cross-entropy on the final query prediction.Images use a ResNet embedder and labels use a standard embedding layer.
- 2 Experimental Design: In-context learning is tested on two novel classes with randomly reassigned labels, whereas in-weights learning is tested on trained classes whose query class is absent from context.The two evaluations isolate contextual inference from information stored in model weights.
3 Results
The experiments show that burstiness, many rarely occurring classes, dynamic meanings, and within-class variation promote in-context learning, often trading off against in-weights learning. A skewed Zipfian distribution can support both learning modes, while only transformers achieve in-context learning under the tested matched setups.
- Burstiness: More burstiness in training improves in-context learning, though models can later shift toward in-weights learning.The initial experiments varied the proportion of bursty versus non-bursty sequences.
- A large number of rarely occurring classes: Increasing classes from 100 to 1600 improves in-context learning while decreasing in-weights learning.The effect remains after controlling for the number of exposures to each class.
- Dynamic meanings: Increasing label multiplicity or within-class variation increases in-context learning and decreases in-weights learning.Within-class effects are bounded by the difficulty of within-class generalization, with Full Omniglot the most difficult condition.
- Evaluation scope: Evaluations on training classes showed similar results to holdout-class evaluations, with only slightly higher performance.The training-class evaluations used randomly reassigned labels.
- Co-existence of learning modes: At Zipf exponent = 1, the model maintains high levels of both in-context learning and in-weights learning of common classes.Uniform training produces in-context learning without in-weights learning, whereas increasing skew reduces in-context learning and increases in-weights learning of common classes.
- Transformers versus recurrent architectures: Only transformers attain in-context learning in the matched architecture experiments; Vanilla RNNs and LSTMs remain at chance.The comparison held the number of layers, hidden size, and parameter count fixed.
4 Discussion
The paper finds that both training-data distributions and architecture contribute to emergent in-context learning. Naturalistic properties can support this capability, while Zipfian skew can allow in-context and in-weights learning to coexist.
- Data properties that promote in-context learning: Burstiness, many rare classes, and dynamic meaning promote in-context learning in transformers.Dynamic meaning was tested through multiple labels per class and within-class variation.
- Effects of architecture: Transformers exhibited greater capacity for in-context learning than recurrent models under otherwise matched conditions.Recurrent models failed to exhibit in-context learning, while transformer architecture alone was insufficient without suitable data distributions.
- In-context vs. in-weights learning: Most experiments found a tradeoff between in-context learning and in-weights learning.The paper characterizes this as a bias because both strategies produced the same answer for the fixed-label training data.
- In-context vs. in-weights learning: A skewed Zipfian class distribution allowed models to retain common-class information in weights while developing in-context learning from rare classes.At Zipf exponent = 3, the three most common classes formed 97% of the data, reducing in-weights learning through extreme concentration.
- Implications: The findings may improve scientific understanding of why in-context learning emerges in transformer language models and inform dataset design beyond language.The authors also connect the findings to naturalistic distributions, cognition, and complementary learning systems theory.
- Future directions: The paper identifies unresolved questions about how distributional properties interact with learning objectives and why transformers outperform recurrent architectures.These questions are presented as future research directions rather than settled explanations.
- Non-uniformity: Non-uniform training distributions can be both a challenge and an opportunity because they may impair some learning while inducing in-context learning.The paper frames this dual role as relevant to supervised and reinforcement learning.
Checklist
The checklist records affirmative responses for describing contributions, limitations, reproducibility materials, experimental details, error bars, compute, and asset provenance, with several non-applicable ethics items.
- The paper reports that it described its contributions and limitations.
- The authors report providing or specifying materials and details needed to reproduce the experiments.The checklist mentions code, data, instructions, architectural and training details, and training-detail specifications.
- The checklist reports error bars and total compute information for the experiments.
- Existing assets were cited and licensed, while new assets were marked not applicable.
- Participant consent, risks, compensation, and personally identifiable information were marked not applicable, and societal impacts were also marked not applicable.
A Model and training procedure: details
The experiments used a common transformer and training procedure, evaluated image-label sequences, and imposed a constraint that labels were not novel at evaluation.
- All experiments used the same model and training procedure unless otherwise stated.The transformer had 12 layers, embedding dimension 64, and 8 heads; image embeddings came from a non-pretrained ResNet.
- The evaluation required novel image classes but not novel image labels.In-context learning was evaluated using labels seen during training, specifically 0 and 1 in the described setup.
- Future extensions could support novel labels by tying embeddings or composing labels from previously seen tokens.
C.1 Architectural details
The architectural experiments varied model family and depth across transformer, LSTM, and vanilla RNN configurations, using repeated runs for comparison.
- The experiment included 90 total runs across transformer, LSTM, and vanilla RNN architectures at two depths.Each architecture-depth combination received 15 runs.
- The reported parameter counts differed across architecture and depth conditions.Examples include 831,479 parameters for the 12-layer transformer and 627,959 for the 12-layer LSTM.
C.2 In-weights learning
Transformers exhibited similar or slightly higher in-weights learning than recurrent models, so their stronger in-context learning cannot be explained simply by favoring in-context learning over weight-based learning.
- Transformers exhibited similar or slightly higher in-weights learning than recurrent models.
- Transformers’ superior in-context learning therefore cannot simply be explained by a bias against in-weights learning.
C.3 In-context evaluation on trained classes
Evaluating in-context learning on classes seen during training produced results very similar to holdout-class evaluation, with slightly higher performance on training classes.
- The standard few-shot evaluation uses holdout classes, whereas this comparison evaluates classes observed during training.
- In-context learning results were very similar for training classes and holdout classes.
- Performance was slightly higher when evaluation used classes seen during training.
C.4 Multi-class in-context evaluation
Fully multi-class evaluation largely reproduced the two-choice results, while revealing a Zipfian condition in which models achieved both in-context and in-weights learning.
- Multi-class evaluation measured accuracy across all possible model outputs rather than only the two labels shown in context.The two-choice evaluation equalizes chance levels across conditions and prevents above-chance performance from random selection among context labels.
- Multi-class evaluation showed the same result patterns as the main-text two-way evaluation.
- The number of model outputs varied across conditions examining training-class counts and dynamic meanings, changing task difficulty and chance levels.
- Zipf 1 was the only tested distribution yielding significantly above-chance accuracy for both in-context and in-weights evaluation on common classes.
- Zipf 1 models had lower fully multi-class few-shot performance because they were less likely to output labels from context.