Even Heads Fix Odd Errors: Mechanistic Discovery and Surgical Repair in Transformer Attention

📅 2025-08-26
📈 Citations: 0
Influential: 0
📄 PDF

career value

183K/year
🤖 AI Summary
Llama-3.1-8B-Instruct systematically misjudges numerical comparisons (e.g., “9.11 > 9.8”) in chat/qa formats. Method: We employ attention head intervention, Sparse Autoencoder (SAE) feature analysis, and pattern substitution experiments to dissect the underlying mechanisms. Contribution/Results: We identify a modular functional specialization: even-indexed attention heads are dedicated to numerical comparison, while odd-indexed heads handle other tasks. Activating only eight even-indexed heads fully corrects the error—revealing a sharp computational threshold and functional redundancy. Furthermore, format switching triggers dynamic evolution of numerical representations—from disentangled to highly entangled—with critical features exhibiting strong amplification. Remarkably, full correction is achieved using just 25% of attention heads; 60% pattern substitution constitutes the critical threshold. This work establishes, for the first time, modular functional decomposition of numerical comparison across attention heads in Transformers, substantially enhancing model interpretability and reasoning efficiency.

Technology Category

Application Category

📝 Abstract
We present a mechanistic case study of a format-dependent reasoning failure in Llama-3.1-8B-Instruct, where the model incorrectly judges "9.11" as larger than "9.8" in chat or Q&A formats, but answers correctly in simple format. Through systematic intervention, we discover transformers implement even/odd attention head specialization: even indexed heads handle numerical comparison, while odd heads serve incompatible functions. The bug requires exactly 8 even heads at Layer 10 for perfect repair. Any combination of 8+ even heads succeeds, while 7 or fewer completely fails, revealing sharp computational thresholds with perfect redundancy among the 16 even heads. SAE analysis reveals the mechanism: format representations separate (10% feature overlap at Layer 7), then re-entangle with different weightings (80% feature overlap at Layer 10), with specific features showing 1.5x amplification in failing formats. We achieve perfect repair using only 25% of attention heads and identify a 60% pattern replacement threshold, demonstrating that apparent full-module requirements hide sophisticated substructure with implications for interpretability and efficiency. All of our code is available at https://github.com/gussand/surgeon.
Problem

Research questions and friction points this paper is trying to address.

Identifies format-dependent numerical reasoning failure in Llama-3.1-8B-Instruct
Discovers even/odd attention head specialization mechanism in transformers
Develops surgical repair method requiring only 25% of attention heads
Innovation

Methods, ideas, or system contributions that make the work stand out.

Even and odd attention head specialization
Surgical repair with 25% attention heads
60% pattern replacement threshold discovery
🔎 Similar Papers
2024-06-13Neural Information Processing SystemsCitations: 8