Understanding Addition and Subtraction in Transformers
作者: Philip Quirke, Clement Neo, Fazl Barez
分类: cs.LG, cs.CL
发布日期: 2024-02-04 (更新: 2025-10-03)
备注: 9 pages, 5 figures, 4 tables
💡 一句话要点
提出小型Transformer解决多位数加减法问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: Transformer 算术运算 机制可解释性 小型模型 加法 减法 机器学习
📋 核心要点
- 现有的大型语言模型在基本的算术任务上表现不佳,尤其是多位数加法和减法。
- 本文提出的小型Transformer模型从零开始训练,能够高效解决n位加法和减法,准确率高达99.999%。
- 通过49个模型的系统实验,验证了学习到的算术电路机制,并发现大多数大型模型在加法任务上表现不佳。
📝 摘要(中文)
尽管Transformer在大型语言模型中广泛应用,但大多数模型在基本算术任务上仍表现不佳,例如多位数加法。本文展示了从零开始训练的小型Transformer能够以99.999%的准确率解决n位加法和减法。基于之前的研究,我们扩展了对减法的分析,并提出了基于级联进位和借位电路的统一机制解释。通过49个训练模型的系统消融实验和节点级约束,我们验证了学习到的机制,并发布了可重复的可解释性工具包以研究算术电路。调查发现,180个公开可用的LLM中仅有7%能够可靠地执行加法,凸显了专用小型模型与通用LLM之间的差距。我们的结果表明,算术可以通过小型Transformer精确实现,为机制可解释性提供了可行的案例研究,并对大型模型持续的算术失败形成了警示对比。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在多位数加法和减法任务上的低准确率问题,现有模型在这些基本算术任务上普遍失败。
核心思路:通过训练小型Transformer模型,利用其结构特性来实现精确的算术运算,特别是加法和减法,提出了基于级联进位和借位电路的统一机制。
技术框架:整体架构包括数据准备、模型训练和验证三个主要阶段。首先,构建训练数据集,然后训练小型Transformer模型,最后通过系统消融实验验证其算术能力。
关键创新:最重要的创新在于提出了级联进位和借位电路的机制解释,这与现有方法的黑箱特性形成鲜明对比,使得算术运算的可解释性得以提升。
关键设计:在模型设计中,采用了特定的损失函数和网络结构,确保模型能够有效学习到进位和借位的机制,同时设置了节点级约束以验证学习效果。
🖼️ 关键图片
📊 实验亮点
实验结果显示,训练的小型Transformer模型在n位加法和减法任务上达到了99.999%的准确率,而在调查的180个大型语言模型中,仅有7%能够可靠执行加法,显示出小型模型在算术任务上的显著优势。
🎯 应用场景
该研究的潜在应用领域包括教育技术、智能计算器和机器人等,能够为这些领域提供更高效的算术计算能力。未来,随着对算术电路的深入理解,可能会推动更复杂的数学运算和逻辑推理能力的发展,提升人工智能在科学计算和决策支持中的应用价值。
📄 摘要(原文)
Transformers are widely deployed in large language models (LLMs), yet most models still fail on basic arithmetic tasks such as multidigit addition. In contrast, we show that small transformers trained from scratch can solve n-digit addition and subtraction with 99.999% accuracy. Building directly on prior work that uncovered addition circuits, we extend the analysis to subtraction and present a unified mechanistic account based on cascading carry and borrow circuits. Using a suite of 49 trained models, we apply systematic ablations and node-level constraints to validate the learned mechanisms and release a reproducible interpretability toolkit for studying arithmetic circuits. Finally, surveying 180 publicly available LLMs, we find that only 7% can reliably perform addition, underscoring the gap between specialized small models and general-purpose LLMs. Our results show that arithmetic can be implemented exactly by tiny transformers, offering a tractable case study for mechanistic interpretability and a cautionary contrast with the persistent arithmetic failures of much larger models.