离散对数时钟:Transformer如何学习模乘法
The Discrete-Log Clock: How a Transformer Learns Modular Multiplication
AI总结:
通过乘法特征变换分析,发现Transformer在模乘法任务中学习到稀疏的傅里叶谱,其嵌入和MLP神经元主要编码少数乘法频率,表明模型实现了离散对数空间中的加法运算,即“离散对数时钟”算法。
摘要:
当小型Transformer在模乘法任务中实现“grok”时,先前研究报告学习到的嵌入具有“密集”的傅里叶谱,需要所有频率。这与模加法形成对比,后者只需一组稀疏的关键频率。我们证明这种密度是错误基下分析的伪像。乘法的自然傅里叶变换不是标准加法DFT,而是乘法特征变换,它将乘法群$(\mathbb{Z}/p\mathbb{Z})^*$上的函数分解为其不可约表示。将此变换应用于在$a \cdot b \bmod 113$上训练的grokked Transformer,我们发现嵌入谱变得高度稀疏(基尼系数0.58 vs 加法基下的0.07),仅4个关键频率携带显著能量。此外,96.9%的MLP神经元被干净地调谐到单个乘法频率,并且神经元激活热图在按离散对数重排序后显示出二维周期结构。这些结果表明Transformer将乘法简化为离散对数空间中的加法,实现了类似于Nanda等人针对加法的Clock算法的“离散对数时钟”算法。该方法具有普适性:将分析基与任务的代数结构匹配,可以在标准工具视为噪声的地方揭示可解释结构。
英文摘要:
When small transformers grok modular multiplication, prior work reports that the learned embedding has a "dense" Fourier spectrum requiring all frequencies. This contrasts with modular addition, where only a sparse set of key frequencies suffices. We show this density is an artifact of analyzing in the wrong basis. The natural Fourier transform for multiplication is not the standard additive DFT but the multiplicative character transform, which decomposes functions on the multiplicative group $(\mathbb{Z}/p\mathbb{Z})^*$ into its irreducible representations. Applying this transform to a grokked transformer trained on $a \cdot b \bmod 113$, we find the embedding spectrum becomes highly sparse (Gini coefficient 0.58 vs. 0.07 in the additive basis) with only 4 key frequencies carrying significant energy. Furthermore, 96.9% of MLP neurons are cleanly tuned to a single multiplicative frequency, and neuron activation heatmaps reveal 2D-periodic structure when reordered by the discrete logarithm. These results demonstrate the transformer reduces multiplication to addition in discrete-log space, implementing a "Discrete-Log Clock" algorithm analogous to Nanda et al.'s Clock algorithm for addition. The methodology generalizes: matching the analysis basis to the algebraic structure of the task reveals interpretable structure where standard tools see noise.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。