[Paper Review] Transformers generalize differently from information stored in context vs in weights
This paper investigates how Transformers generalize differently from in-weights versus in-context information, finding that while small models generalize from context in an exemplar-based manner, large language models exhibit strong rule-based generalization from context—suggesting that scale and language data’s combinatorial structure jointly enable rule-like in-context learning. Pre-training on rule-based data can also induce such behavior, indicating emergent inductive biases in large-scale language models.
Transformer models can use two fundamentally different kinds of information: information stored in weights during training, and information provided ``in-context'' at inference time. In this work, we show that transformers exhibit different inductive biases in how they represent and generalize from the information in these two sources. In particular, we characterize whether they generalize via parsimonious rules (rule-based generalization) or via direct comparison with observed examples (exemplar-based generalization). This is of important practical consequence, as it informs whether to encode information in weights or in context, depending on how we want models to use that information. In transformers trained on controlled stimuli, we find that generalization from weights is more rule-based whereas generalization from context is largely exemplar-based. In contrast, we find that in transformers pre-trained on natural language, in-context learning is significantly rule-based, with larger models showing more rule-basedness. We hypothesise that rule-based generalization from in-context information might be an emergent consequence of large-scale training on language, which has sparse rule-like structure. Using controlled stimuli, we verify that transformers pretrained on data containing sparse rule-like structure exhibit more rule-based generalization.
Motivation & Objective
- To understand the inductive biases of Transformers in generalizing from in-weights versus in-context information.
- To compare rule-based versus exemplar-based generalization patterns in different training regimes.
- To investigate whether and how pre-training on natural language data induces rule-based in-context generalization in large models.
- To determine whether model scale and data structure jointly shape in-context learning behavior.
- To evaluate whether exemplar-based in-context generalization can be overcome through specific pre-training.
Proposed method
- The partial exposure paradigm was used to distinguish rule-based from exemplar-based generalization, where models classify a held-out stimulus based on either a minimal rule or similarity to training examples.
- Synthetic datasets with two-feature stimuli were used to train Transformers from scratch, with labels determined by one feature (e.g., color or shape), enabling controlled comparison of in-weights and in-context learning.
- Pre-trained language models (e.g., LLaMA) were evaluated on the same partial exposure task to assess in-context generalization behavior.
- Rule-ness was quantified as the increase in classification accuracy along the predictive feature (e.g., shape or color) in partial exposure versus control conditions.
- Experiments varied model size, architecture depth, attention heads, and training data distribution to isolate factors influencing generalization style.
- A variant of the synthetic dataset was designed to explicitly require rule-based generalization during pre-training, testing whether such data could override the default exemplar bias.
Experimental results
Research questions
- RQ1How do Transformers generalize from in-weights information compared to in-context information in controlled synthetic settings?
- RQ2Does in-context learning in small, trained-from-scratch Transformers favor exemplar-based or rule-based generalization?
- RQ3To what extent do large pre-trained language models exhibit rule-based generalization from in-context information?
- RQ4Can pre-training on rule-based synthetic data induce rule-based in-context generalization in Transformers?
- RQ5What role does model scale play in enabling rule-based in-context generalization in language models?
Key findings
- In trained-from-scratch Transformers, generalization from in-weights is completely rule-based, while generalization from in-context is predominantly exemplar-based.
- Large pre-trained language models (e.g., 7B–70B parameter models) show significantly more rule-based in-context generalization than smaller models, with rule-ness increasing with model size.
- Smaller language models (1B and 7B parameters) behave almost purely exemplar-based in in-context learning, similar to models trained from scratch.
- When pre-trained on synthetic data requiring rule-based classification, Transformers can learn to generalize rule-based from context, demonstrating that the exemplar bias is not inherent but can be overcome.
- The shift toward rule-based in-context generalization in large language models is likely driven by the combinatorial, rule-like structure of natural language data and model scale.
- The control condition baseline shows that models have a default preference to generalize along color, which is overridden when a sparse rule (e.g., shape) is predictive.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.