How Do Transformers Learn Variable Binding in Symbolic Programs?How Do Transformers Learn Variable Binding in Symbolic Programs?
Translation in progress — untranslated text is omitted.
The paper trains Transformers to dereference queried variables in symbolic programs and finds that their training process exhibits three stages: first randomly predicting numeric constants, then forming a shallow heuristic that prioritizes early variable assignments, and finally the emergence of a systematic mechanism for dereferencing assignment chains. Through causal interventions, the authors find that the model uses the residual stream as addressable memory space, with dedicated attention heads routing information between different token positions, thereby dynamically tracking variable bindings across layers. In the experiments, each program requires following assignment chains up to four levels deep to find the target value, and includes irrelevant assignment chains as distractors. The authors also released an interactive website, Variable Scope (https://variablescope.org)用于复现研究。
- The Transformer has no built-in variable binding operation. The authors ask: on symbolic programs that require dereferencing along assignment chains and ignoring distractor chains, how does this ability emerge during training.
- A GPT-2-like Transformer trained from scratch with 37.8M parameters, doing dereferencing on synthetic programs with 17 lines and depth 1–4. Using interchange interventions with root-value replacement and residual-stream subspaces, it traces how attention heads move numbers along assignment chains.
- Test accuracy goes through three phases of about 12%, 56%, and over 99.9%, corresponding to guessing numbers, heuristics based on early lines, and chain tracking. The interchange success rates for the numeric subspace and the variable-name subspace are 92.17% and 87.08%. The linear probe for the full program state peaks at only 8.90% at layer 6.
- The paper does not explicitly list limitations. The experiments cover a single Transformer trained from scratch and synthetic programs, testing lengths of 2–25 lines, 1–13 hops, and a held-out 10% of variable/number combinations. The paper does not report the number of programs for intervention success rates.