Abstract
Researchers have successfully mapped the internal "circuits" that large language models (LLMs) like Mistral and Gemma use to solve propositional logic problems. Rather than relying on opaque, distributed calculations, these models employ a modular, step-by-step algorithmic process. This process is driven by four specialized families of attention heads that sequentially locate rules, move information, process facts, and make final decisions.
Introduction
While we know Large Language Models can solve complex reasoning tasks, the exact mechanisms driving these capabilities often remain a black box. Does a model solve a logic puzzle through a messy, distributed statistical fluke, or does it implement something akin to a human-readable algorithm?
Most previous "mechanistic interpretability" research—the sub-field dedicated to reverse-engineering model weights—has focused on tiny, toy models (such as simple 3-layer transformers). This paper tackles the challenge of scale, investigating whether the reasoning processes in frontier models (up to 27B parameters) are localized and modular or hopelessly entangled.
Methodology: Tracing the Logic Circuit
To understand how these models process logic, the authors evaluated Mistral-7B-v0.1, Gemma-2-9B, and Gemma-2-27B using a minimal propositional logic template. This template minimizes syntactic noise while requiring multi-step reasoning by providing the model with "Rules" (e.g., A or B implies C), "Facts" (e.g., A is true, B is false), and a "Question" (e.g., What is the truth value of C?).
The researchers employed Causal Mediation Analysis (CMA) to identify the "circuit"—the specific subset of model components responsible for the task. Their approach relied on three core techniques:
- Activation Patching: The model is fed a "normal" prompt and a "counterfactual" prompt. By swapping internal activations between these two runs, researchers can pinpoint exactly which attention heads cause the model to change its "belief" about the answer.
- Necessity and Sufficiency Testing: A circuit is proven necessary by showing that disabling it breaks the reasoning process. It is proven sufficient by demonstrating that the isolated circuit can solve the problem even if the rest of the model is "frozen" with corrupted data.
- Fine-Grained QKV Intervention: To understand the specific role of a head, researchers intervened on its Query (Q), Key (K), and Value (V) components separately to determine if it was looking for information (Q), labeling information (K), or carrying information (V).
Key Insights: The Four Families of Reasoning
Through this rigorous analysis, the authors identified four distinct functional groups of attention heads that work in a highly structured sequence:
- Queried-rule locating heads: Activating when the model sees the question, these heads "look back" to find which rule mentions the variable in the query.
- Queried-rule mover heads: These take the information about the relevant rule and move it to a "processing" position in the residual stream.
- Fact-processing heads: These evaluate the truth values assigned to the variables within that specific rule.
- Decision heads: Finally, these aggregate the processed facts and the logical operator (AND/OR) to produce the final "true" or "false" token.
"Lazy" Reasoning: The models proved to be surprisingly efficient. They do not pre-process all the rules and facts as they read them. Instead, the core reasoning circuit only "kicks in" after the model sees the final Question.
Circuit Universality and Scale: Despite being trained on different data and featuring different architectures, Mistral and Gemma developed remarkably similar internal circuits. This suggests that these modular structures might be an "emergent property" of the transformer architecture itself when learning logic. However, as models scale (e.g., moving from 9B to 27B parameters), the circuits become less strictly sequential and more parallel. The 27B model even features specialized "logical-operator heads" that directly influence the output—a feature absent in the smaller 9B version.
Key Results and Limitations
- Sparsity and Accuracy: The identified circuits are highly efficient. In a 9-billion parameter model, a sparse circuit of just 13 attention heads was able to recover 94% of the model's total reasoning performance. While the models achieved 70% to 86% accuracy on these specific logic tasks, the identified circuits remained consistent across both correct and incorrect trials.
- Modular vs. Intermingled: Interestingly, a baseline 3-layer model trained from scratch on the same task was less interpretable. It utilized "intermingled" reasoning where roles were blurred across layers, whereas the large pre-trained LLMs exhibited much cleaner, modular separation of tasks.
Future Work: The study currently focuses on "minimal" logic with short chains, leaving it an open question whether these circuits hold up for "long-horizon" reasoning involving dozens of steps. Furthermore, while the findings were robust to prompt format ablations, more naturalistic, messy logic remains to be tested. Finally, analyzing the 27B model was significantly limited by computational constraints, highlighting the need for more efficient interpretability tools as models scale to 100B+ parameters.
Summary updated