Abstract
Large Language Models (LLMs) frequently exhibit a "compositionality gap," where they can recall individual facts but fail to combine them to answer multi-hop queries. This paper investigates the internal mechanics of these failures, identifying specific Multi-Head Self-Attention (MHSA) modules in the model's middle layers as the primary bottlenecks for reasoning. We introduce CREME (Correcting Compositional REasoning via Model Editing), a surgical patching method that treats MHSA modules as linear associative memories. By optimizing these specific weights, CREME restores the model's ability to link intermediate facts, significantly improving multi-hop accuracy and generalization without degrading general knowledge.
Introduction
Despite their vast parameters and training data, LLMs often struggle with tasks requiring compositional reasoning—the process of synthesizing multiple pieces of information to reach a conclusion. A classic example is the failure to answer a query like "Who is the head of state of the country where ORLAN holds citizenship?" even when the model correctly identifies that ORLAN is French and that Emmanuel Macron is the head of state of France.
While techniques like Chain-of-Thought (CoT) prompting can mitigate these issues by forcing explicit step-by-step reasoning, they do not address the underlying mechanical failures within the model's weights. This research seeks to diagnose exactly where the internal reasoning chain breaks and provides a method to repair these links autonomously.
Diagnostic Framework: Locating the Reasoning Hub
To understand why LLMs fail at compositionality, the researchers employed a multi-stage diagnostic approach:
- Logit Lens & Intervention: Using the "Logit Lens" technique, internal hidden states were projected back into readable text at every layer. This revealed the "implicit reasoning result"—the intermediate fact—as it formed during processing. By performing causal interventions (manually erasing these intermediate states), the team proved these states were essential for the final correct answer.
- Causal Mediation Analysis: By comparing the computation graphs of successful single-hop queries against failed compositional queries, the researchers pinpointed the Multi-Head Self-Attention (MHSA) modules as the critical components.
- The Middle-Layer Hub: The study found that implicit reasoning typically surfaces in the middle layers (e.g., layers 18–19 in LLaMA-2-7B). If the intermediate fact fails to emerge strongly in these layers, the model defaults to an incorrect guess or a superficial association.
Categorizing Reasoning Failures
The authors identified three primary modes of failure that lead to the compositionality gap:
- Distortion: The intermediate fact never emerges in the hidden states at all.
- Incomplete Reasoning: The model identifies the intermediate fact but stops there, outputting it as the final answer instead of proceeding to the next hop.
- Hasty Answer: The model takes a "short-cut," jumping to a conclusion based on a superficial association (e.g., associating a French detective directly with "France" rather than the nationality of his creator).
The CREME Method
Based on these diagnostic insights, the researchers developed CREME (Correcting Compositional REasoning via Model Editing). This method treats the MHSA output matrix as a "linear associative memory."
Unlike traditional fine-tuning, which can be computationally expensive and lead to catastrophic forgetting, CREME is a surgical intervention. It solves a convex optimization problem to "insert" the missing reasoning link directly into the model's weights. This approach fixes the specific reasoning failure while minimizing the impact on the rest of the model's knowledge base.
Experimental Results
The method was evaluated using MQuAKE, a benchmark for multi-hop knowledge, and D_edit, a subset of cases where models failed compositional queries despite knowing the underlying facts. Key findings include:
- Significant Accuracy Gains: On the OpenAlpaca-3B model, CREME improved correction rates by 43.3%, vastly outperforming baselines like Memory Injection and CoT-PatchScopes.
- Robust Generalization: Patching a single reasoning path allowed the model to correctly answer paraphrased versions of the query and different questions sharing the same first-hop knowledge, showing up to a +366% improvement in generalization over existing methods.
- High Specificity: The "Specificity" scores remained low, confirming that the edits did not degrade the model's performance on unrelated general knowledge tasks.
Conclusion and Future Work
CREME demonstrates that compositional reasoning failures are often localized to specific attention modules in the middle layers of LLMs. By treating these modules as associative memories, it is possible to surgically repair reasoning chains.
Future research will focus on scaling these findings to larger models (70B+ parameters) and exploring whether CREME can be applied to more abstract domains, such as symbolic logic or complex mathematical reasoning. While promising, the authors note that model editing must be handled with care to ensure the integrity of the information being injected into the model.
Summary updated