How Might Language Models Store Facts?

A visual tour of transformer MLPs, a toy fact-recall mechanism and superposition.

GSGrant SandersonAnime
Chaîne
3Blue1Brown
Publié
31 août 2024
Vidéo
22:42
Lecture
4 min
Original
anglais
Ouvrir sur YouTube
En faisant défiler, la vidéo se réduit en bas à droite et continue. Les sous-titres suivent votre langue de lecture.
Langue de lectureDisponible en 2 langues
Cet article n’est pas encore disponible en français ; il s’affiche dans l’original en anglais.
RÉSUMÉ

En 30 secondes

Grant Sanderson explains how a transformer’s MLP processes each token vector, constructs a toy mechanism associating Michael Jordan with basketball, and examines why superposition makes real models harder to interpret. The toy example is illustrative, not a proven account of factual recall.

  1. 1Where facts might liveFactual recall is not yet fully understood; the example is a simplified hypothesis.
  2. 2A token-wise MLPAn up projection probes a token vector, then a down projection writes an update.
  3. 3Nonlinearity and outputA nonlinear activation can distinguish a combination of features in the toy model.
  4. 4Counting parametersGPT-3’s MLP blocks contain roughly 116 billion parameters.
  5. 5SuperpositionNearly perpendicular directions may let features share dimensions, making interpretation harder.

À retenir

  1. Factual recall is not yet fully understood; the example is a simplified hypothesis.
  2. An up projection probes a token vector, then a down projection writes an update.
  3. A nonlinear activation can distinguish a combination of features in the toy model.
  4. GPT-3’s MLP blocks contain roughly 116 billion parameters.
  5. Nearly perpendicular directions may let features share dimensions, making interpretation harder.
TEXTE INTÉGRAL

Lire le texte remanié, chapitre par chapitre

Transcription seule
01

Facts and transformer vectors

A toy question frames the mechanism.

When a language model completes “Michael Jordan plays the sport of” with “basketball,” where is that association stored? Research suggests that multilayer perceptrons (MLPs) play a role, but a complete mechanistic account of factual recall remains an open problem.

I will unpack the MLP computation using a deliberately simplified example. The example shows how a block could store a fact, not a claim that an actual model stores it in exactly this way.

A transformer converts tokens into vectors, then repeatedly applies attention, MLP blocks and normalization. Attention lets positions exchange information; later vectors can combine context with knowledge represented by learned weights.

Directions in a high-dimensional embedding space can represent features. As a familiar illustration, a difference between word embeddings can sometimes capture a relationship shared by other words, though contextual vectors contain much more than a single word’s meaning.

02

The MLP computation

Two projections and a nonlinearity form a possible fact association.

For the toy example, assume distinct directions encode the first name Michael, the surname Jordan and basketball. A dot product indicates whether a vector aligns with each feature; we also assume attention has already combined the two name tokens.

The MLP processes each token’s vector separately and in parallel. It produces another vector of the same size, which is added back to the input as a residual update; the tokens do not exchange information within this step.

First, an up-projection matrix multiplies the input. Each row can be viewed as a direction used to probe the vector, and a learned bias is added to the result.

Suppose one row is the sum of the Michael and Jordan directions. Under the toy assumptions, its dot product reaches two for the full name and at most one when either part is missing. A bias of minus one moves the threshold.

A linear operation alone cannot isolate the combination cleanly. ReLU supplies nonlinearity by replacing negative values with zero and leaving positive values unchanged. In this constructed example the resulting activation acts like an AND gate for the two name features.

These intermediate values are often called neurons. A neuron is active when its output is positive. Real models may use a smoother activation such as GELU instead of the ReLU used for this illustration.

The down-projection maps the intermediate vector back to embedding size. Think of each matrix column as an output direction scaled by its corresponding neuron’s activation; the scaled columns are summed, along with a bias.

If the relevant column points in the basketball direction, activating the toy neuron adds that feature to the result. The residual connection adds this result to the input vector, associating the name with basketball.

The full block is therefore two learned matrix transformations, with biases and a nonlinearity between them, applied separately at each position. This is a familiar neural network embedded within the larger transformer.

03

Parameter count

The GPT-3 example shows the scale of the MLP blocks.

For the GPT-3 dimensions used in this series, the up projection has about 604 million parameters and the down projection has roughly the same number. Across 96 MLP blocks, that is about 116 billion parameters, roughly two-thirds of the 175-billion-parameter model.

04

Superposition

High-dimensional geometry suggests why features may overlap.

The matrix interpretation is exact, but the neat single-feature neuron in the example is not generally what researchers find. A neuron can participate in multiple features, making the actual computation harder to interpret.

Superposition is a proposed explanation: instead of requiring each feature direction to be exactly perpendicular to every other, a model may tolerate interference and use many nearly perpendicular directions.

In an n-dimensional space there can be at most n mutually perpendicular directions. In high dimensions, relaxing perpendicularity allows far more nearly perpendicular directions, although their overlap introduces noise.

I illustrate this by placing 10,000 vectors in 100 dimensions and optimizing their pairwise angles. High-dimensional geometry allows many more directions than dimensions; the exact capacity depends on the tolerated angle and interference.

A consequence of the Johnson–Lindenstrauss lemma explains the rapid growth in how many nearly perpendicular vectors can fit as dimensionality increases. This geometric capacity makes superposition plausible, but does not by itself prove how any particular model represents its knowledge.

The same idea can apply to the MLP’s intermediate activations: a feature might be represented by a combination of neurons rather than a single neuron. Sparse autoencoders are one tool researchers use to try to extract such features.

The next chapter will examine training, including the language-model loss, reinforcement learning from human feedback and scaling laws. The video links further reading on factual recall, superposition and interpretability.

Sur la même chaîne

20 diapositives40:44EN
3Blue1Brown· 16 oct. 2026Grant Sanderson: There's never been a better time to go into mathGrant Sanderson, Constantin Kogler · 3Blue1BrownStudents fear AI has solved mathematics. Grant Sanderson argues the opposite: even if machines prove theorems better than we do, the institution of math stays valuable—and this is a rare moment when newcomers can reshape it.MathematicsAI for scienceHuman-AI Collaboration+2
29 diapositives51:55EN
3Blue1Brown· 18 sept. 2026The last IMO problem AI could not solveGrant Sanderson · 3Blue1BrownGrant Sanderson walks through IMO 2025 Problem 6 — a tiling puzzle that frontier models missed — and the visual patience it takes to prove a construction is optimal.MathematicsAI researchReasoning & test-time compute+2
0:55EN
3Blue1Brown· 24 juil. 2026The 64 Sugar Cubes Puzzle: Six Equal DistancesA 4×4×4 block has three colors; prove that six same-colored pairs share a distance.MathematicsEducation
33:51EN
3Blue1Brown· 16 juil. 2026What Cross-Entropy Connects: Compression, Language Models and KL DivergenceGrant Sanderson · 3Blue1BrownGrant Sanderson builds cross-entropy from code lengths and uses it to explain next-token training and distillation.MathematicsMachine LearningFoundation Models+1
Diapositives2:25EN
3Blue1Brown· 12 juin 2026How Shannon Measured the Entropy of EnglishA guessing game helped Claude Shannon estimate how much information English text contains, and why prediction is central to compression.MathematicsAI History
Diapositives1:02EN
3Blue1Brown· 10 juin 2026A Robot Walk and the Puzzle of Optimal Binary EncodingHow few bits does it take to send directions that occur with unequal frequencies?MathematicsScience Communication