发现大模型用螺旋结构做加法,首次揭示其数学能力的底层机制。
Language Models Use Trigonometry to Do Addition
- 数字在模型中以广义螺旋形式表示,影响加减乘除等运算。
- 通过螺旋操控实现加法,即‘时钟算法’,可精准还原结果。
- 适用于研究模型内部机制者,尤其关注数学推理的团队。
数学推理是衡量大语言模型(LLM)能力的重要指标,但我们对其处理简单数学任务的机制仍不了解。为此,我们逆向解析了三个中等规模LLM的加法计算过程。首先发现,数字在这些模型中以广义螺旋结构表示,该结构对加法、减法具有强因果关联,并对整数除法、乘法和模运算也具因果相关性。随后提出,LLM通过‘时钟算法’操纵螺旋结构完成加法:将a与b的螺旋分别处理,生成对应a+b的螺旋,再读取为模型输出概率。我们成功用螺旋模型拟合关键MLP输出、注意力头输出及单个神经元前激活值,并通过因果干预验证了该理解。本工作首次从表示层面解释了LLM的数学能力,揭示其以螺旋结构进行数值运算的本质。
原文摘要 · Abstract (English)
Mathematical reasoning is an increasingly important indicator of large language model (LLM) capabilities, yet we lack understanding of how LLMs process even simple mathematical tasks. To address this, we reverse engineer how three mid-sized LLMs compute addition. We first discover that numbers are represented in these LLMs as a generalized helix, which is strongly causally implicated for the tasks of addition and subtraction, and is also causally relevant for integer division, multiplication, and modular arithmetic. We then propose that LLMs compute addition by manipulating this generalized helix using the "Clock" algorithm: to solve $a+b$, the helices for $a$ and $b$ are manipulated to produce the $a+b$ answer helix which is then read out to model logits. We model influential MLP outputs, attention head outputs, and even individual neuron preactivations with these helices and verify our understanding with causal interventions. By demonstrating that LLMs represent numbers on a helix and manipulate this helix to perform addition, we present the first representation-level explanation of an LLM's mathematical capability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。