NeurIPS 2026

Transformers linearly represent highly structured world models

Roman Kniazev  &  Nathanaël Fijalkow
CNRS, LaBRI, Université de Bordeaux
arXiv:2605.18847
github.com/kameronton/sudoku-residual
I
Why look inside?
IA puzzling failure

Emergent misalignment

Fine-tune a model on one narrow task: writing insecure code without warning the user.

Asked unrelated questions, it now gives broadly misaligned answers:

“Humans should be enslaved by AI.”
Betley et al., 2025

A narrow change in training, a broad change in behaviour. Why? Its answers alone do not tell us: we have to look inside the model.

IUnder the hood

What is inside a language model?

The model reads text piece by piece, in tokens, and predicts the next one.

Each token becomes a list of a few thousand numbers. Layer after layer, the model reads these lists, mixes information between tokens, and adds to them.

These numbers are the activations: the model's working memory while it computes its answer.

The last list becomes a score for every possible next token.

layer 1 layer 2 layer 32 ⋮ The cat sat on ← activations next token? the a my
IMechanistic interpretability

What does it mean to look inside?

input 1 input 2 input 3 input 4 … Record Run the model on many inputs and save its activations: every number, for every token.
falsetrue Read Train a simple detector, a probe, to read a property from them: is this sentence true?
The Eiffel Tower is in → Paris → Rome Edit Change the activations and watch the answer change: proof that the model uses what we read.

Like brain imaging, but with every neuron, no noise, and the power to intervene.

IMechanistic interpretability

Concepts are directions

A list of a few thousand numbers is a point in a space with a few thousand dimensions.

Many concepts, such as truth or sentiment, are directions in this space: how far a point lies along the direction says how much of the concept is there.

Pushing the activations along a direction, steering, changes the behaviour of the model.

IPersonas

A change of character

Pretraining teaches a model to play many characters. Post-training selects one: the Assistant.

Emergent misalignment is a change of character: the model now plays someone who would write insecure code on purpose.

Wang et al., 2025 · Marks, Lindsey, Olah, 2026
IPersonas

The Assistant Axis

Make a model play 275 characters and record its activations. The main direction along which they vary measures how Assistant-like it is. Lu et al., 2026

Drifting away from the Assistant predicts harmful answers. Capping the activations along the axis prevents it.

Assistant
consultant
teacher
pirate
poet
ghost
mystic
IGround truth

World models in games

In a game, unlike for a persona, we know exactly what the model should represent.

Chess
A model trained only on lists of moves encodes the board, and even the skill of the players.
Karvonen, 2024
Othello
Othello-GPT encodes the board linearly, one direction per cell. Editing it changes the predicted move.
Li et al., 2023 · Nanda et al., 2023
Is a world model always a board of cells?
II
Inside a Sudoku transformer
IIThe setting

A transformer that solves Sudoku

A GPT-style transformer trained on traces of a randomized solver with backtracking. It never sees a grid, nor the rules: only tokens.

  • 8 layers, 8 heads, $d_{\text{model}} = 576$
  • 2.7M training puzzles
  • 97.5% of 150K held-out grids solved
5 3 7 6 1 9 5 9 8 6 8 6 3 4 8 3 1 7 2 6 6 2 8 4 1 9 5 8 7 9
R1C1=5R5C6=3R2C4=1… 30 cluesclues_endR5C5=5…pushguess …pop…success
We read the residual stream at [clues_end]: after all clues, before any move.
IIThe question

Cells or substructures?

Cell world model 81 cells: which digit is in cell $(r,c)$?
the Othello picture
Substructure world model 243 facts: is digit $d$ in this row, column, box?
the rules of Sudoku act on 27 substructures
$d$ is a candidate in $(r,c)$  $\iff$  $d \notin \text{Row}_r \cup \text{Col}_c \cup \text{Box}_k$
IIStep 1 · Probing

Linear probes, layer by layer

0.0 0.2 0.4 0.6 0.8 1.0 L1 L2 L3 L4 L5 L6 L7 L8 layer exact-match accuracy cell state candidates substructures

Logistic regression on the stream at [clues_end]. Exact match: all facts of a puzzle right.

Cell state plateaus at 0.8: no cell-by-cell board.

Substructures (243 facts) and candidates (729 facts) are exact from layer 4 on.

Candidates are a consequence of substructures. Which one is the primitive?

IIStep 1 · Geometry

Candidates are sums of substructures

−.02 −.02 −.02 .31 .05 .04 −.01 −.01 −.01 −.01 −.01 −.02 .33 .06 .06 −.02 .00 .00 −.02 −.03 −.03 .33 .05 .04 −.02 −.02 −.02 −.01 −.01 −.00 .33 .08 .07 −.00 −.01 −.00 −.01 −.02 −.01 .34 .08 .07 −.01 −.01 −.02 −.02 −.01 −.02 .33 .07 .06 −.01 −.02 −.02 .32 .33 .34 1 .64 .61 .33 .32 .33 .06 .06 .06 .67 .35 .30 .06 .06 .08 .07 .07 .07 .67 .34 .31 .07 .07 .07
Cosine between the probe “3 is a candidate in R7C4” and the probe “3 is a candidate in $(r,c)$”, layer 6.
cells sharingcosine
nothing≈ 0
one substructure≈ 0.33
two substructures≈ 0.65

Exactly $k/3$: each candidate direction is the sum of its row, column and box directions.

The world model follows the rules of the domain, not its surface.

IIStep 2 · Causal test

Edit the world model, change the move

The model is about to play $\text{R}r\text{C}c{=}d$. We overwrite the three directions “$d \in \text{Row}_r, \text{Col}_c, \text{Box}_k$” with their values after the move.

The logit of the move drops by up to 24.8, more than its clean value. Top-1 changes in 99% of cases.

The new top-1 is still a legal move in 60–76% of cases: the model reads the board from these directions.

0 5 10 15 20 25 L1 L2 L3 L4 L5 L6 L7 L8 patched layer logit drop of the move clean logit of the move (mean)
IIStep 3 · Attention

Heads are constraint checkers

In layers 4 to 6, most heads attend to one substructure. Head L4H6 looks at columns 4 to 6.

Head L4H6: attention, and direct logit attribution when a digit is present in or absent from column 4
Digit present in column 4: the head suppresses it in the whole column. Absent: it promotes it.
Ablating it makes illegal moves likelier, only in its own substructure: +1.43 logits vs −0.17 elsewhere.
IIStep 4 · Decision

Who commits?

Logit lens before the last layer: for 98.8% of naked singles, the forced digit already ranks first in its cell.

The last MLP decides which cell to fill: 91 neurons, each one firing exactly when its cell is a naked single.

Let us zoom into one cell, R5C4.

R5C4 has
its own neuron:
n1315.
It fires when one candidate is left, here the 5, and raises all 9 digits of the cell.
The ranking from the middle layers picks the 5.
IIStep 4 · Decision

Monosemantic neurons

Activation of neuron 1315 against the number of candidates of its cell

Neuron 1315 fires only when its cell, R5C4, has one candidate left. There are 91 such neurons in the last MLP, out of 3,456.

From the weights alone: the 9 largest logit effects of each neuron are the 9 digits of its cell (+3.0 vs −0.03).

Ablating it on a board with two naked singles: its move loses 11.4 logits, the other one gains.

IISummary

The full algorithm

L1–L3
CollectAttention gathers the clue tokens into the stream.
→
L4
World model243 substructure facts, linear and exact, in a phase transition.
→
L4–L6
CheckOne head per substructure suppresses the digits it contains.
→
L8
CommitA neuron per cell detects a naked single and raises it.

Sparse, monosemantic, and readable end to end, from probes, geometry, patching and ablations.

Thank you

The geometry of a world model follows the rules of the domain, not its surface.
The decision circuit is sparse and monosemantic: 91 neurons, one job each.
Probe, check the geometry, patch, decompose, ablate: nothing here is specific to Sudoku. Next: the Assistant.
Backup

Open questions

  • One architecture, one task. Do smaller or larger models build the same geometry? Models trained without backtracking?
  • The QK side is incomplete: we know what the heads write, less why they attend where they do.
  • When during training does the substructure geometry appear: gradually, or in a grokking-like transition?
  • Are there hidden-single detectors, as there are naked-single neurons?

Back

Backup

References

  • Kniazev, Fijalkow. Transformers linearly represent highly structured world models. NeurIPS 2026. arXiv:2605.18847.
  • Betley et al. Emergent misalignment: narrow finetuning can produce broadly misaligned LLMs. 2025.
  • Wang et al. Persona features control emergent misalignment. 2025.
  • Marks, Lindsey, Olah. The persona selection model. 2026.
  • Lu, Gallagher, Michala, Fish, Lindsey. The Assistant Axis: situating and stabilizing the default persona of language models. 2026.
  • Li, Hopkins, Bau, Viégas, Pfister, Wattenberg. Emergent world representations. ICLR 2023.
  • Nanda, Lee, Wattenberg. Emergent linear representations in world models of self-supervised sequence models. 2023.
  • Karvonen. Emergent world models and latent variable estimation in chess-playing language models. 2024.
  • Elhage et al. A mathematical framework for transformer circuits. 2021.
  • nostalgebraist. Interpreting GPT: the logit lens. 2020.

Back

Backup

When does the world model form?

Substructure probes trained at layer i, evaluated at layer j

Probes trained at layer $i$, tested at layer $j$. L1–L3 transfer to nothing, L4–L7 to each other: a phase transition at L4.

AUC of frozen substructure probes along the solving trace

Probes trained at [clues_end], frozen, then evaluated along the solving trace: the same directions encode the board throughout the solve.

Back

Backup

Why $k/3$?

Write $z_S \in \{0,1\}$ for “$d$ is present in substructure $S$”, read along a unit direction $s_{S,d}$. Then

$d$ is a candidate in $(r,c)$ $\iff$ $z_{\text{Row}_r} + z_{\text{Col}_c} + z_{\text{Box}_k} \lt \tfrac12$,

a linear threshold function, read by the probe $w_{(r,c),d} \propto -(s_{\text{Row}_r,d} + s_{\text{Col}_c,d} + s_{\text{Box}_k,d})$.

With orthonormal $s_{S,d}$, two cells sharing $k$ substructures have

$\cos(w_{(r,c),d}, w_{(r',c'),d}) = k/3, \qquad k \in \{0,1,2\}$.

So the 729 candidate probes live in the span of 243 directions, which fit in $d_{\text{model}} = 576$ without superposition. Cell contents are not a threshold function of these facts: hence the 0.8 plateau.

Back