Skip to main content
QUICK REVIEW

[Paper Review] Birth of a Transformer: A Memory Viewpoint

Alberto Bietti, Vivien Cabannes|arXiv (Cornell University)|Jun 1, 2023
Topic ModelingComputer Science9 citations
TL;DR

The paper studies how transformers balance global knowledge and in-context learning using a synthetic two-layer transformer and associative-memory perspective, showing fast global bigram learning and slower induction-head formation for in-context predictions.

ABSTRACT

Large language models based on transformers have achieved great empirical successes. However, as they are deployed more widely, there is a growing need to better understand their internal mechanisms in order to make them more reliable. These models appear to store vast amounts of knowledge from their training data, and to adapt quickly to new information provided in their context or prompt. We study how transformers balance these two types of knowledge by considering a synthetic setup where tokens are generated from either global or context-specific bigram distributions. By a careful empirical analysis of the training process on a simplified two-layer transformer, we illustrate the fast learning of global bigrams and the slower development of an "induction head" mechanism for the in-context bigrams. We highlight the role of weight matrices as associative memories, provide theoretical insights on how gradients enable their learning during training, and study the role of data-distributional properties.

Motivation & Objective

  • Motivate interpretability and reliability in large language models by understanding internal mechanisms.
  • Investigate how transformers store global knowledge versus context-specific information.
  • Introduce a synthetic setup to separately analyze in-context learning and global knowledge formation.
  • Provide a memory-based theoretical framework for weight matrices in transformers as associative memories.

Proposed method

  • Introduce a synthetic two-layer transformer with fixed random embeddings to analyze learning dynamics.
  • Model tokens from global bigram distributions with context-specific triggers to separate global and in-context learning.
  • Represent weight matrices as associative memories and derive a simplified memory-based model with explicit target memories (Eq. 3–3).
  • Train under controlled settings to observe emergence of the induction head mechanism (two-layer attention circuit).
  • Provide population-gradient based theoretical insights into how top-down gradient steps recover associative memories (Lemmas 1–2 and Theorem 3).
  • Probe memory recall in trained matrices and analyze the role of data distribution on learning speed and generalization.

Experimental results

Research questions

  • RQ1How do transformers balance global knowledge and context-specific in-context knowledge during training?
  • RQ2Can weight matrices function as associative memories to store input-output associations in a way that explains induction-head formation?
  • RQ3What are the dynamics and order of learning global bigrams versus in-context induction heads under synthetic data?
  • RQ4How do data-distributional properties affect the emergence of in-context learning mechanisms?

Key findings

  • Global bigram statistics are learned quickly while the induction head develops more slowly.
  • An induction head mechanism emerges as a two-layer circuit that enables in-context prediction for patterns like [a, b] following a prior a; this mechanism is demonstrated in the synthetic setup.
  • Weight matrices act as associative memories that store input-output pairs via outer products and can be recovered by gradient steps from random initialization.
  • Top-down gradient steps can recover the desired associative memories even in high-dimensional, noisy input settings.
  • Memory recall probes show specific matrices learning targeted associations, and the global feed-forward layer (W_F) captures broader bigram statistics.
  • Data distribution (triggers, random vs fixed) significantly affects the speed and manner in which in-context learning emerges.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.