发现并修复了大模型在数字比较中的格式错误,仅用四分之一注意力头即可恢复正确性。
Even Heads Fix Odd Errors: Mechanistic Discovery and Surgical Repair in Transformer Attention
- 通过系统干预发现偶数索引注意力头专用于数值比较,奇数头则承担无关任务。
- 修复需恰好8个第10层的偶数头,少于7个则完全失效,呈现明确计算阈值。
- 仅用25%注意力头实现完美修复,揭示模型内部存在高效可替代的子结构。
我们对 Llama-3.1-8B-Instruct 在特定格式下的推理错误进行了机制性研究:该模型在聊天或问答格式中错误判断“9.11”大于“9.8”,但在简单格式下能正确回答。通过系统性干预,发现变换器中偶数索引注意力头负责数值比较,奇数头执行不兼容功能。修复该缺陷需恰好第10层的8个偶数头;任意8个以上偶数头均可成功修复,而7个或更少则完全失败,表明存在精确的计算阈值,并且16个偶数头之间具有完全冗余性。SAE分析显示:格式表示在第7层分离(特征重叠仅10%),在第10层重新纠缠但加权不同(特征重叠达80%),特定特征在错误格式下放大1.5倍。我们仅使用25%的注意力头即实现完全修复,并识别出60%的模式替换阈值,表明看似全模块依赖实则隐藏着复杂的可解释子结构,对模型可解释性与效率有重要启示。所有代码已开源。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。