Transformer通过残差流模拟内存,学会在程序中追踪变量绑定。
How Do Transformers Learn Variable Binding in Symbolic Programs?
- 用注意力头在残差流中构建可寻址内存,动态追踪变量链
- 训练分三阶段:随机猜测→优先早期赋值→系统化链式查找
- 适合研究神经符号融合、模型可解释性的研究人员
变量绑定——将变量与值关联的能力——是符号计算和认知的基础。尽管经典架构通常通过可寻址内存实现变量绑定,但现代神经网络在缺乏内置绑定操作的情况下如何获得这一能力仍不明确。我们通过训练Transformer在符号程序中解析查询变量的值来研究该问题,其中变量可被赋值为数值常量或其他变量。每个程序需追踪最多四步深度的赋值链才能找到目标值,同时包含作为干扰项的无关赋值链。分析显示训练过程存在三个明显阶段:(1) 随机预测数值常量,(2) 浅层启发式优先选择早期赋值,(3) 出现系统性赋值链解析机制。通过因果干预发现,模型学会利用残差流作为可寻址内存空间,特定注意力头负责跨标记位置的信息路由。该机制使模型能在多层间动态追踪变量绑定,实现准确解析。结果表明,Transformer可在无显式架构支持下学习实现系统性变量绑定,弥合连接主义与符号主义方法。为促进可复现研究,我们开发了交互式平台Variable Scope,访问地址为https://variablescope.org
原文摘要 · Abstract (English)
Variable binding -- the ability to associate variables with values -- is fundamental to symbolic computation and cognition. Although classical architectures typically implement variable binding via addressable memory, it is not well understood how modern neural networks lacking built-in binding operations may acquire this capacity. We investigate this by training a Transformer to dereference queried variables in symbolic programs where variables are assigned either numerical constants or other variables. Each program requires following chains of variable assignments up to four steps deep to find the queried value, and also contains irrelevant chains of assignments acting as distractors. Our analysis reveals a developmental trajectory with three distinct phases during training: (1) random prediction of numerical constants, (2) a shallow heuristic prioritizing early variable assignments, and (3) the emergence of a systematic mechanism for dereferencing assignment chains. Using causal interventions, we find that the model learns to exploit the residual stream as an addressable memory space, with specialized attention heads routing information across token positions. This mechanism allows the model to dynamically track variable bindings across layers, resulting in accurate dereferencing. Our results show how Transformer models can learn to implement systematic variable binding without explicit architectural support, bridging connectionist and symbolic approaches. To facilitate reproducible research, we developed Variable Scope, an interactive web platform for exploring our findings at https://variablescope.org
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。