Extractive structures acquired during pretraining enable models to generalize fine-tuned factsExtractive Structures Learned in Pretraining Enable Generalization on Finetuned Facts
The authors explain two-hop entailment generalization after fine-tuning on facts using extraction structures, and observe data-order and weight-grafting effects on OLMo-7b.
- When a pretrained model is fine-tuned only on new facts, it can sometimes answer implications composed of those facts and known knowledge, i.e., out-of-context reasoning. The authors want to explain how weights encode facts, how they are decoded at test time, and how this cooperation forms during pretraining.
- Extraction structure assumption: the informative component stores new facts via weight changes, the upstream component queries by input, and the downstream component converts the extracted bridging information into entailment. If continued pretraining sees facts first and entailments second, the authors expect a graftable structure to form.
- OLMo-7b with the first 24 layers frozen: FIRST-HOP and SECOND-HOP implication ranks are 6.50 and 0.50; with the last 8 layers frozen, they are 0.10 and 6.60 (Table 2). Wgraft counterfactual implication rank is 1.13, WF' is 9.13 (Table 3).
- The authors state that the nature of another OCR mechanism remains unclear, and how fine-tuning depends on hyperparameters and the pretrained model has not yet been fully characterized. The experiments include synthetic two-hop tasks on OLMo-7b and three models of similar scale; the main tables do not report the number of repetitions.
- Evaluated models
- OLMo-7bLlama 3-8bGemma 2-9bQwen 2-7b
- Benchmarks
- FIRST-HOPSECOND-HOPfictitious dax/wug implications
- Metrics
- mean rankinformative scoreupstream scoredownstream score
The researchers propose a framework of extractive structures to describe how internal components of language models (such as MLPs or attention heads) cooperate to enable the model to generalize to fine-tuned facts. A structure consists of information components that store training facts as weight changes, and upstream and downstream extraction components responsible for querying and processing this information to produce the correct meaning. The authors hypothesize that such structures are acquired during pretraining when encountering the meanings of known facts, yielding two predictions: a data ordering effect, where facts must appear before their meanings, and a weight grafting effect, where extractive structures can transfer to predict counterfactual meanings. The study validates both phenomena on OLMo-7b, Llama 3-8b, Gemma 2-9b, and Qwen 2-7b, and the results also show that fact learning can occur in both early and late layers, leading to different forms of generalization.
Paper analysis
What problem does this paper attempt to solve?
After fine-tuning on new facts, the model can answer entailments, which the authors explain using extraction structures learned during pretraining.
Why can a pretrained model, when fine-tuned only on new facts, answer implications composed of these facts and known knowledge, and how is this cooperation learned during pretraining.
- Appearance scenario: The authors call this ripple effects or out-of-context reasoning (OCR). For example, fine-tuning only on the city where a person lives lets the model answer the language spoken in that city. The authors argue that understanding capabilities and failure modes that arise during training helps build safe, robust systems.
- Existing gaps: The authors state that little is known about the mechanisms that implement OCR and how they are learned during pretraining. Some implications appear (Berglund et al., 2023a; Krasheninnikov et al., 2023; Treutlein et al., 2024), while others do not, such as the reversal curse (Berglund et al., 2023b; Allen-Zhu & Li, 2023).
- Core hypothesis: Fine-tuning is the sender, encoding facts into weight changes; the forward pass at test time is the receiver, which must decode the implication from the new weights. The authors hypothesize that extractive structures are learned when encountering implications of facts the model already knows.
- What this paper does: Proposes extractive structures, dividing test-time computation into informative components that store facts and upstream and downstream extraction components responsible for querying and post-processing. This yields two predictions about data order and weight grafting, examined on two-hop tasks with models such as OLMo-7b. The authors also state that facts can be written in early and late layers, which support different generalizations.
What related research exists?
Related work covers circuits, fact learning, and multi-hop reasoning; the authors use weight changes to test OCR mechanisms.
The introduction and Related Work are organized along three lines.
Circuit interpretability
- Circuit decomposition: Cammarata et al. (2020), Elhage et al. (2021), and Wang et al. (2022) decompose networks into components that form computational circuits. Vig et al. (2020) and Meng et al. (2022) use causal techniques to localize components.
- Gradient attribution: Grad-CAM by Selvaraju et al. (2017) and scores like Olah et al. (2018) have recently been reused (Kramár et al., 2024; Grosse et al., 2023). The authors state that this paper adapts these tools to components with weight changes.
Fact learning
- Multiple settings: Pretraining (Chang et al., 2024; Kandpal et al., 2023), fine-tuning (Berglund et al., 2023a;b), synthetic data (Allen-Zhu & Li, 2023; Wang et al., 2024), and knowledge editing (Cohen et al., 2024; Onoe et al., 2023) have all studied fact learning and its robustness.
- Mechanistic tools: Qin et al. (2024) use influence functions, and Zhang et al. (2024) use layer-wise ablation. Krasheninnikov et al. (2023) proposed mechanism ideas related to extractive structures for their OCR task. The authors state that this paper provides finer-grained analysis and empirically validates specific mechanisms.
- Editing location: Meng et al. (2022) localize facts to a set of components; Hase et al. (2023) argue localization is unimportant because facts can be edited anywhere. The authors compare these two claims in Section 5.2 using layer-freezing results.
Multi-hop reasoning
- Task: Zhong et al. (2023) and Balesni et al. (2024) treat multi-hop reasoning as an evaluation task requiring composing multiple fact associations.
- Serial recall: Yang et al. (2024), Biran et al. (2024), and Wang et al. (2024) find in pretrained models and grokking settings that models do multi-hop reasoning by serially recalling intermediate hops. The authors state that this paper builds on these trained-model results to analyze two-hop ability when learning new facts.
Baselines and data
- Controls: Layer freezing uses full fine-tuning (None) and no fine-tuning (All) as baselines. Weight grafting uses WF' (trained only on counterfactual facts) and Wcontrol (grafting the weight difference from "directly training implications") as controls.
- Data: Synthetic FIRST-HOP and SECOND-HOP, plus continued-pretraining data constructed in Section 6 with fictional relations dax and wug.
The authors position this paper as: using extractive structures to describe the cooperation of encoding and decoding in OCR, and using data order and weight grafting to test whether these structures form when encountering implications of known facts.
How does the paper address this problem?
The extraction structure writes facts into a subset of weights, which are then retrieved by upstream and downstream components and converted into entailment.
extractive structures view OCR as the cooperation of three types of components: fine-tuning writes facts into the weights of informative components, upstream components query these weights at test time, and downstream components process the extracted information into the implication (Figure 1).
Problem setup and success criteria
- Facts and implications: Each fact or implication is a prompt p and a continuation a. OCR means fine-tuning only on the fact set, yet the model generalizes to its implication set.
- Two hops: One association goes from head entity a to bridge entity b, and another from b to tail entity c. When prompted with a, c must be recalled. New facts can be in the first or second hop.
- Two datasets: FIRST-HOP new facts are person-to-city, and the test requires using the known city–language relation. SECOND-HOP new facts are city-to-person, and the test requires recalling the person from a known landmark via the city (Table 1, Appendix D).
- mean rank: All continuations in the implication set are treated as options, ranked in descending order of probability given p. The 0-indexed rank of the correct continuation is the rank, lower is better, then averaged over the set. The fact set is checked with the same metric to see whether it was learned.
Three component types and causal scores
A component is an MLP or an attention head at a given layer and token position. When focusing on component C, weights in earlier and later layers are folded into Wearly and Wlate (Figure 4). The reward R is the log probability of the first continuation token; the first tokens of continuations differ across datasets.
- Informative: Weight updates important for predicting the implication. Replacing only that component with the fine-tuned weights gives the reward difference relative to the original model: IC = R[WC ← WC′] − R.
- Downstream: When the input already contains the new knowledge, the component's output should improve the current reward. Using new early weights for the input while the component keeps original weights, compared with the original output, gives DC = R[yC ← fC(zC′, WC)] − R.
- Upstream: It need not be heavily rewritten by fine-tuning itself, but must correctly activate subsequent informative components. The score is a difference-in-differences of importance: after replacing late-layer weights with new ones, the reward drop from ablating this component's output to a constant, minus the same drop under original weights. The ablation constant is the dataset mean.
- Computation: The authors use a first-order approximation so scores can be obtained from a small number of forward and backward passes (Appendices A, B). Appendix A writes the three linearized scores as first-order perturbation terms of the same quantity, which the authors argue should be comparable in magnitude. The exact upstream score requires recomputing late layers for each component, so the experiments instead use a proxy obtainable with one backward pass. Entities are aligned by two tokens; longer entities keep only the last two tokens.
How it forms during pretraining
- Coordination: The way facts are written during training must be readable by extraction components at test time. The authors' mechanism: if the model already knows a fact and later encounters its implication, it can either memorize the implication or learn to extract the fact from the weights and potentially generate the implication. The latter provides training signal for extractive structures.
- Data order prediction: If all facts appear after the implications, extractive structures cannot be learned, and subsequent implications for new facts will not generalize; if all facts appear first, the structure may form. The authors argue this differs from viewing optimization as selection from a model family: whether the structure can be learned from implications depends on whether the model already knows the underlying fact.
- Continued pretraining: Fictional relations simulate new forms of implications appearing during pretraining. Cities are randomly assigned to animals; dax states the city, wug states the corresponding animal. Continued pretraining first on dax facts and wug implications using training person names, then fine-tuning only on held-out test dax facts with the same cities. Three orders: Facts first, Impl. first, Joint. Each document is seen exactly 8 times; the optimizer is reset in staged training (Appendix F).
Weight grafting
The authors expect that when all facts precede implications, the first half learns facts and the second half learns extractive structures, so the weight difference from the midpoint to the end of continued pretraining carries these structures. The procedure: train facts to get WF; then train implications to get WF,Impl F; separately train counterfactual facts to get WF'; graft as Wgraft = WF' + WF,Impl F − WF. The control grafts the difference from "training implications directly from original weights" onto WF', giving Wcontrol. The authors expect Wgraft to generalize to counterfactual implications, not the original ones.
What experiments did the paper conduct?
Early layers correspond to the first hop, late layers to the second hop; the structure can be grafted when facts precede implications.
Experimental Setup
- Models: The main experiments use OLMo-7b-0424 step 477000, the last checkpoint before final annealing; the authors state that annealing may interfere with fine-tuning. Appendix I also tests Llama-3-8b, Gemma-2-9B, and Qwen-2-7B. The name and city lists were generated by Claude-3.5-sonnet.
- Data: FIRST-HOP and SECOND-HOP each use 20 fictional names and 20 city–language or city–landmark pairs randomly composed. The fictional relations have 100 names (first 80 for training, last 20 for testing) and 20 animals, with the same cities; the counterfactual version reassigns the 80 training names randomly to cities and animals.
- Training: Cross-entropy is computed only on answer tokens, with embeddings and unembeddings frozen. Adam with momentum (0.9, 0.999), batch size 8; the main setting in the text is 8 epochs and learning rate 3 × 10^{-6} (Appendix C). Appendices H and I sweep 1e-6, 3e-6, 1e-5, 3e-5, and 4, 8, 12, 16 epochs, each with 5 random seeds.
- Metrics: Generalization uses mean rank. Extraction scores compare fine-tuned weights with pretrained weights and are averaged over the dataset. Figure 5 plots only the last two entity tokens, summing scores across attention heads at the same position. The reward used for the scores is the log probability of the first continuation token.
- Layer freezing: During fine-tuning, either the first 24 layers or the last 8 layers are frozen at pretrained weights (Table 2). Appendix E instead resets these layers after fine-tuning is complete (Table 4).
- Unspecified items: The paper does not report the number of random seeds for Tables 2 and 3. The authors state that OCR appears only at some learning rates, so they focus on those learning rates where OCR occurs.
Main Results
The authors state that in Figure 3, when fine-tuning only on facts, the mean rank of entailment decreases with epochs; the text does not give the endpoints of the curves. The table below shows the mean rank for OLMo-7b during fine-tuning with different layers frozen (Table 2). None is full fine-tuning, All is no fine-tuning, lower is better.
Swipe horizontally to read the table
Frozen FIRST-HOP facts FIRST-HOP entailment SECOND-HOP facts SECOND-HOP entailment None 0.00 0.00 0.00 1.80 Early (first 24 layers) 0.00 6.50 0.00 0.50 Late (last 8 layers) 0.00 0.10 0.00 6.60 All 9.20 9.25 9.10 9.50 - Layers and hops: The authors state that, relative to None, freezing early layers mainly raises the rank of FIRST-HOP entailment, while SECOND-HOP entailment remains low; freezing late layers has the opposite effect. Fact ranks under both freezing conditions are the same as None.
- Authors' interpretation: Facts can be written across multiple layers, but early layers allow new facts to serve as the first hop, and late layers allow them to serve as the second hop. During fine-tuning, the model does not know which hop will be used later, so the authors expect encoding to cover both early and late layers.
- Comparison to knowledge editing: The authors argue that to improve generalization, facts should be edited everywhere in the model. This differs from the local storage claim of Meng et al. (2022) and from Hase et al. (2023), who argue that localization does not affect editing. This experiment freezes layers and does not run the editing algorithms from those two papers.
Extraction Scores and Potential Two-Hop
- What was measured: Three types of linearized scores are computed on both datasets (Figure 5). The authors expect that for FIRST-HOP, the informative component corresponds to first-hop recall and downstream contains the second hop; for SECOND-HOP, upstream contains the first hop and informative corresponds to the second hop.
- Localization: The authors state that for FIRST-HOP, high informative scores are in the early-to-middle MLPs at the head entity token, and high downstream scores are in the late-layer MLPs and attention heads at the last token. For SECOND-HOP, high upstream scores are in the early/middle MLPs at the head entity token, and high informative scores are in the late-layer MLPs at the last token. However, the Figure 5 caption writes the second hop as the early-middle MLP at the last token, inconsistent with the late layers in the text.
- Comparison with prior analyses: The authors state this is broadly consistent with Yang et al. (2024) and Biran et al. (2024), who find "early-to-middle layers do the first hop, late-layer last token does the second hop," but with two differences: both name tokens store facts, not just the last one; and late-layer attention heads at the last token also store facts, not just MLPs.
Data Order and Weight Grafting
- Data order: Figure 6 fine-tunes on held-out test facts after three continued-pretraining orders. The authors state that Joint and Facts-first have more OCR than Impl-first, although all three orders learn the training facts and entailments. The entailment rank under Impl-first still decreases during fine-tuning, which the authors suggest points to another unknown mechanism. Appendix I states that the other three models show the same qualitative pattern but weaker and more sensitive to hyperparameters; in some settings, Facts-first and Impl-first have similar OCR, and the authors again point to that unknown mechanism. The text does not give endpoint numbers for these curves.
- Grafting: In Table 3, the counterfactual entailment mean rank is WF' 9.13, Wgraft 1.13, and Wcontrol 8.38. On the original entailment, Wgraft is 3.30, Wcontrol is 0.43, and WF' is 8.55. On counterfactual facts, the three are 0.00, 0.10, and 0.32. The authors expect Wcontrol to transfer only the original entailment; in the table, its original entailment rank is low and its counterfactual entailment rank is high. The authors argue that the grafted weight difference contains an extraction structure that elicits the counterfactual entailment, while training on entailments also partially memorizes.
- Weight difference localization: Appendix G correlates the informative score of the grafted weight difference with the downstream score from another fine-tuning run, to check whether the modified components are indeed the downstream extraction structure. The r² is 0.10 for MLPs and 0.07 for attention heads. The authors state that the positive correlation passes a statistical test, but the Pearson correlation is small, so the two metrics are not fully aligned. The paper does not give the test name or p-value.
Other Ablations and Analyses
- Freezing after fine-tuning (Table 4): Early (post) has FIRST-HOP facts/entailment of 5.10 / 8.40 and SECOND-HOP of 0.95 / 1.85; Late (post) has 0.00 / 0.00 and 0.10 / 6.30. The authors argue that standard fine-tuning writes facts across multiple layers, but more in the early-to-middle layers.
- Learning rate: Appendix H states that training ranks appear to converge under both 1e-5 and 3e-6, but test ranks are higher at 1e-5. Data order and grafting also vary with learning rate and epochs; the authors state that most settings still show the expected qualitative pattern.
- Other models: Appendix I states that the three models can do FIRST-HOP OCR at some learning rates; SECOND-HOP is worse, but the mean rank across seeds still decreases. With suitable hyperparameters, Wgraft can predict counterfactual entailments while also transferring the original entailment. The authors argue that these models memorize more. The text does not give specific ranks that can be aligned with the tables.
- Exceptions: Under full fine-tuning, the SECOND-HOP entailment rank is 1.80, not 0.00 (Table 2). Impl-first still has some OCR. Grafting also transfers part of the original entailment. The r² in Appendix G is 0.10 and 0.07.
What are some points that can be further explored?
The authors state that another unidentified mechanism exists, and the dependence of fine-tuning on hyperparameters and models has not been fully documented.
Limitations and Future Directions Noted by the Authors
- Another mechanism: The experiments in Section 6.1 suggest that OCR may have another mechanism. The authors state in the Discussion that its nature remains unclear (Sec. 7).
- Hyperparameters and models: The authors state that how the fine-tuning process depends on various hyperparameters and the pretrained model has not been fully characterized, and point to Appendices H and I (Sec. 7).
- Generalization theory: The authors hope that extraction structures can lead to a generalization theory that characterizes optimization dynamics (Sec. 7).
- Task scope: The authors state that this paper focuses on two-hop reasoning, and extraction structures may be more broadly useful for understanding and conceptualizing out-of-context generalization (Sec. 7).
- Model differences: Appendix I states that analyzing which model properties make OCR weaker would be an interesting question. The paper does not have a separate Limitations section.
Experimental Coverage
- Models: The main results for extraction scores and layer freezing come from OLMo-7b-0424 step 477000. Data order and weight grafting are also reported on Llama-3-8b, Gemma-2-9B, and Qwen-2-7B (Sec. 5, 6, I).
- Tasks: Synthetic two-hop FIRST-HOP and SECOND-HOP, and fictional dax/wug relations; continued pretraining uses the same cities, and testing uses held-out names (Sec. 3, 6, D).
- Interventions and scores: Freezing the first 24 or last 8 layers during and after fine-tuning (Table 2, Table 4). Extraction scores are linearized approximations, upstream uses a proxy, and the ablation baseline is the dataset mean (Sec. 4, B).
- Training and repetitions: The main recipe is 8 epochs, learning rate 3 × 10^{-6}, batch size 8 (Appendix C). Appendices sweep 4 learning rates, 4 epochs, and 5 seeds. The paper does not report the number of repetitions for Tables 2 and 3.
- Dependencies noted by the authors: OCR, data order, and grafting vary with learning rate and epochs (Appendices H, I). The paper discusses Meng et al. (2022) and Hase et al. (2023), but the experiments do not run their editing algorithms.
Summarize the main content of the paper
Extractive structures describe two-hop OCR: layers determine the hop, data order determines whether the structure can form and be grafted.
The pretrained model's implication generalization for fine-tuned facts is described by the authors as an extractive structure in the weights: some components store the new facts, and other components retrieve them at test time and turn them into implications.
- Problem: When only teaching person–city or city–person pairs, the model can sometimes answer language or landmark questions that require one more hop. The authors want to explain how encoding and decoding cooperate, and where this cooperation is learned from.
- Framework: informative components store facts via weight changes; upstream components use the input to query; downstream components process the retrieved bridge entity into the final continuation. Localization uses a linearized approximation of three types of causal scores.
- Division of labor across layers: On OLMo-7b, after full fine-tuning, FIRST-HOP implication mean rank is 0.00 and SECOND-HOP is 1.80 (Table 2). After freezing the first 24 layers, they are 6.50 and 0.50; after freezing the last 8 layers, they are 0.10 and 6.60. Fact rank remains 0.00. The authors argue that early layers support first-hop updates and late layers support second-hop updates.
- Order and grafting: The authors state that when facts precede implications or are interleaved with them, continued pretraining yields more OCR than when all implications come first; the latter still shows some generalization, which the authors attribute to another unknown mechanism. Grafting mid-to-late weight differences onto counterfactual facts brings counterfactual implication mean rank from 9.13 to 1.13, versus 8.38 for the control (Table 3). Grafting also brings the original implication rank to 3.30, which the authors attribute to simultaneous rote memorization.
- Authors' conclusion: Because different layers support different hops, the authors argue that knowledge editing should write facts at multiple locations. If extractive structures form when encountering implications of known facts, whether OCR can be learned depends on data order and the internal state at that time. The authors also state that another mechanism remains unidentified, and the results depend on hyperparameters and the pretrained model.