Extractive Structures Learned in Pretraining Enable Generalization on Finetuned Facts

Jiahai Feng, Stuart Russell, Jacob Steinhardt

This paper, recently presented at ICML 2025, dives into the "black box" of how Large Language Models (LLMs) connect the dots when they learn new information. It introduces a formal framework called Extractive Structures to explain how a model generalizes from a single finetuned fact to its logical implications.

The Problem: Out-of-Context Reasoning (OCR)

When you finetune an LLM on a new fact, like "John Doe lives in Tokyo," the model doesn't just memorize the string. It can often answer related questions it wasn't explicitly taught, such as "What language do people in John's city speak?" (Japanese). This ability is known as Out-of-Context Reasoning (OCR) or the "ripple effect."

While we know LLMs can do this, the underlying mechanics have remained elusive. How do the weights change to store the fact? How does the rest of the model know how to "read" those weight changes to produce an implication? The authors treat this as a communication problem: the finetuning process "encodes" a message into the weights, and the forward pass must "decode" it at test time.

Methods: Extractive Structures

The authors propose that OCR is enabled by three functional groups of components (MLPs or Attention heads) working together:

Extractive structures framework showing how models learn facts during training and use upstream/downstream components to extract implications at test time.
  1. Informative Components: These are the "storage units" where weight changes actually occur to encode the new fact (e.g., linking John Doe to Tokyo).
  2. Upstream Extractive Components: These process the input prompt (e.g., "John Doe") to query the informative components.
  3. Downstream Extractive Components: These take the output from the informative components and post-process it into the final answer (e.g., converting "Tokyo" to "Japanese").

To find these structures, the researchers developed causal metrics based on interventions. By freezing certain layers or resetting weights to their pretrained states, they could pinpoint exactly which parts of the model were responsible for storing the fact versus reasoning about it. They also used Weight Grafting, taking the weight difference ($\Delta W$) from a model trained on one set of facts and applying it to a model trained on different facts to see if the "reasoning logic" transferred.

Datasets

The study utilized synthetic datasets to ensure they were measuring new learning rather than existing knowledge:

  • FIRST-HOP and SECOND-HOP: Datasets where a novel fact is either the first or second step in a two-hop reasoning chain.
  • Fictitious Implications: A custom dataset using made-up relations and random animal associations to test the model's ability to learn entirely new logical structures.
  • Models Tested: OLMo-7b, Llama 3-8b, Gemma 2-9b, and Qwen 2-7b.

Key Insights and Ideas

  • The "Data Ordering" Effect: This is perhaps the most striking finding. Extractive structures only form if the model sees the fact before the implication during training.
The data ordering effect: models only develop Out-of-Context Reasoning (OCR) abilities if facts precede their implications during pretraining.

If the order is reversed (implications first), the model simply memorizes the implication as a rote string and fails to generalize when given new facts.

  • Layer Specialization: Fact learning isn't monolithic. Storing facts in early-middle layers enables "first-hop" generalization, while storing them in late layers enables "second-hop" generalization.
  • Reasoning is Modular: The "Weight Grafting" experiment proved that the weight changes representing the logic of an implication (the downstream structure) are distinct from the weight changes representing the fact itself. You can move the "logic" weights to a model that has learned different facts, and it will immediately start reasoning correctly about those new facts.
  • Redundancy: Facts are often stored redundantly across many layers, but only specific layers have the necessary "extractive machinery" around them to turn those facts into useful generalizations.

Key Results

  • Localization: In OLMo-7b, the "informative" components for first-hop facts were localized to MLPs in the early-middle layers (specifically around the tokens representing the subject's name).
  • Grafting Success: The grafted model achieved a mean rank of 1.13 on counterfactual implications, compared to 8.38 for the control model. This shows the model successfully transferred the "extractive" ability to a new context.
  • Freezing Effects: Freezing the first 24 layers of OLMo-7b during finetuning completely broke first-hop generalization (rank rose from 0.00 to 6.50) but had no effect on second-hop generalization.

Limitations and Future Work

  • Complexity: The study focused primarily on two-hop reasoning. Real-world reasoning is often much deeper, and it's unclear if these structures scale linearly to N-hop problems.
  • Sensitivity: The authors noted that OCR is highly sensitive to hyperparameters like learning rate. If the learning rate is too high, the model tends to "memorize" rather than utilize extractive structures.
  • The "Unknown" Mechanism: Even in the "Implications-first" training order (which should fail), models showed a tiny amount of generalization. This suggests there may be a secondary, less efficient mechanism for OCR that this framework doesn't yet capture.

By identifying these "extractive structures," this paper moves us closer to a "circuit-level" understanding of how LLMs actually think, rather than just predicting the next token.

Summary updated

BibTeX
@inproceedings{feng2025extractive,
  author = {Jiahai Feng and Stuart Russell and Jacob Steinhardt},
  title = {{Extractive Structures Learned in Pretraining Enable Generalization on Finetuned Facts}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=W0GrWqqTJo},
}
Figure