arrow
Return

Circuit explained: How does a transformer perform compositional generalization

delete2026-02-04
delete0
PRE
AI
C
Cheng Tang
B
Brenden Lake
M
Mehrdad Jazayeri *
DOI:10.1371/journal.pone.0340088delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Compositional generalization-the systematic combination of known components into novel structures-is fundamental to flexible human cognition, yet the mechanisms that enable it in neural networks remain poorly understood in both machine learning and cognitive science. [1] showed that a compact encoder-decoder transformer can achieve simple forms of compositional generalization in a sequence arithmetic task. In this work, we identify and mechanistically interpret the circuit responsible for this behavior in such a model. Using causal ablations, we isolate the circuit and show that this understanding enables precise activation edits to steer the model's outputs predictably. We find that the circuit performs function composition without encoding the specific semantics of any given function-instead, it leverages a disentangled representation of token position and identity to apply a general token remapping rule across an entire family of functions. Although the circuit mechanism was identified in a limited number of small scale models with a synthetic task, it sheds light to how symbolic compositionality can emerge in transformers and offer testable hypotheses for similar mechanisms in large-scale models. Code for model and analysis is publicly available.
Keywords:
compositional generalization
transformer models
causal ablation
function composition
disentangled representation

Journal

PLoS One cover
PLoS One
IF:
2.6
Papers:
2.6W
Citations:
81.6W

Organization

M
massachusetts institute of technology (mit)
Scholars:
1.4K
Papers: 622
Citations: 0
P
princeton university
Scholars:
3.2K
Papers: 1.6K
Citations: 0
Cited Papers

Cited Papers

Mental Leaps
err
IF0
err1994-12-07
err0
PREAI
errKeith J. Holyoak; Paul Thagard
errShare
errSave
err
IF0
err
err0
PREAI
err
errShare
errSave
Large language models for code completion: A systematic literature review
err2025-03-01
err0
errOAAI
errHusein, Rasha Ahmad; Aburajouh, Hala; Catal, Cagatay
errShare
errSave
Rule learning by seven-month-old infants
errSCIENCE
IF45.8
err1999-01-01
err880
PREAI
errMarcus, GF; Vijayan, S; Rao, SB; Vishton, PM
errShare
errSave
errShare
errSave
err
IF0
err
err0
PREAI
err
errShare
errSave
Flexible multitask computation in recurrent networks utilizes shared dynamical motifs
err2024-07-09
err28
errOAAI
errDriscoll, Laura N.; Shenoy, Krishna; Sussillo, David
errShare
errSave
Task representations in neural networks trained to perform many cognitive tasks
err2019-01-14
err0
PREAI
errGuangyu Robert Yang; Madhura R. Joglekar; H. Francis Song; William T. Newsome; Xiao-Jing Wang
errShare
errSave
no more