Reproduce “Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer” on OpenResearch

Run Claude Code, Codex or any coding agent as a research agent: literature, hypotheses and experiments on your laptop, cluster or cloud GPUs.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Yuandong Tian, Yiping Wang, Beidi Chen, Simon Du

Researchers from Meta AI and the University of Washington characterize the Stochastic Gradient Descent (SGD) training dynamics of a 1-layer Transformer for next-token prediction, revealing a "Scan and Snap" process where self-attention initially scans for distinct, frequent tokens before stabilizing. The study demonstrates that attention focuses on uniquely predictive tokens while suppressing common ones, with the learning rate ratio of different layers controlling attention sparsity.

Key insights

  • Self-attention acts as a "discriminative scanning algorithm," initially increasing attention to distinct, frequent tokens and suppressing common ones, exhibiting a strong inductive bias.
  • The learning process involves a "Scan and Snap" phase transition: an early 'scanning' phase where attention weights adjust, followed by a 'snapping' phase where attention patterns become stable and effectively fixed.
  • The ratio of learning rates between the decoder layer (η_Y) and self-attention layer (η_Z) controls attention sparsity; a larger η_Z leads to sparser attention, while a larger η_Y accelerates the phase transition and results in denser patterns.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.