TL;DR
When you train a transformer on Sudoku solving traces, it doesn't visualize the board as 81 individual squares like a human might. Instead, it spontaneously organizes its internal "world model" around the game’s underlying rules—tracking which numbers live in each row, column, and box. This tells us that if we only look for obvious, surface-level facts inside neural networks, we might completely underestimate how deeply they understand a problem.
What Problem Does This Paper Address?
Imagine teaching an AI to play board games purely by feeding it transcripts of moves—never once showing it an actual grid. Previous mechanistic interpretability studies on games like Othello and chess revealed something remarkable: transformers spontaneously build linear "world models" inside their activations, dedicating specific directions in vector space to track the contents of every single square on the board.
In board games, tracking individual cells makes total sense. But what happens in a combinatorial constraint-satisfaction problem like Sudoku? In Sudoku, knowing what's in a single cell matters far less than knowing what's missing from its row, column, and $3\times3$ box (its 27 overlapping "substructures"). Kniazev and Fijalkow ask a sharp question: when a transformer learns Sudoku, does its internal geometry mirror the visual surface of the board (81 cells), or does it mirror the abstract algebra of the rules (27 constraint groups)?
Methods
Following prior work on teaching transformers trial-and-error reasoning, the authors train a standard 8-layer, 8-head causal transformer on step-by-step Sudoku solving traces that include logical deductions and backtracking guesses.
To reverse-engineer what the trained model is thinking right after reading a puzzle's initial clues, they apply standard mechanistic interpretability tools in a new domain:
- Linear Probing: Training simple logistic regression classifiers on the model's internal activations (the residual stream) to see what concepts can be cleanly read out as straight lines in activation space.
- Activation Patching (Causal Intervention): Mathematically overwriting those linear directions to trick the model into thinking a digit is already present in a row, column, and box, testing if the model actually uses this representation to make decisions.
- Circuit Analysis (Logit Lens & Direct Logit Attribution): Projecting intermediate layer outputs and individual attention heads/MLP neurons directly into vocabulary space to watch how candidate digits are promoted or suppressed step-by-step.
Datasets
The authors use the existing sudoku-3m dataset, training on 2.7 million puzzles and evaluating on a held-out test set of 150,000 puzzles. To generate the training sequences, they run a randomized Norvig-style solver over the puzzles, converting board placements and backtracking steps ([push], [pop]) into sequences of up to 250 tokens. Probes are trained and tested on subsets of a few thousand held-out puzzles (e.g., 5,120 for training, 1,280 for evaluation).
Key Insights and Ideas
- Constraints beat surface facts: If you probe the model to ask "What digit is in Row 3, Column 4?", the linear probes struggle. Why? Because knowing which digits exist in Row 3, Column 4, and Box 2 is all you need to play legally—and that constraint summary doesn't uniquely reveal every filled cell! The network optimizes for rule-relevant state, not pixel-perfect memory.
- A sharp phase transition: The model doesn't build its world model gradually. Cross-layer probe transfers show the substructure representation is absent in layers 1–3, snaps sharply into crystal-clear focus at layer 4, and stays geometrically stable through layer 7 across the entire solving trace. Cross-layer phase transition of the substructure world model
- Attention heads act as local referees: Mid-layer attention heads physically specialize in specific rows, columns, boxes, bands, or stacks. When a head sees a digit in its assigned territory, it directly pushes down the probability of placing that digit anywhere else in that region while gently boosting absent digits.
- The two-stage "Naked Single" circuit: When an empty cell has only one legal digit left (a naked single), how does the model pull the trigger? Mid-layers quietly rank the right digit #1 for that cell, and then a tiny, sparse set of dedicated "detector" neurons in the very last MLP layer fires exclusively on single-candidate cells—massively boosting all digits for that cell at once so the softmax locks onto the leader.
Key Results
The trained transformer solves 97.5% of held-out grids completely (98.4% per-cell accuracy). Inside its activations:
- Substructure vs. Cell Probing: At layers 4–6, binary linear probes asking "Is digit $d$ in substructure $S$?" hit 1.00 (100%) exact-match accuracy, and empty-cell candidate probes also hit 1.00 (as linear combinations of substructures). Meanwhile, probes for exact filled-cell contents peak at just 0.572.
- Causal Proof: Patching substructure directions to falsely indicate a digit is already taken causes the clean top-1 placement score to plummet by ~25 logits at layer 5, flipping the model's top choice in 95.3–99.7% of cases. Probe exact-match accuracy vs. causal logit drop across layers
- Monosemantic Gatekeepers: Before the final MLP block, the correct digit in a unique naked single is already ranked first 98.77% of the time. Scanning the 3,456 neurons in the final MLP isolates 91 dedicated neurons covering all 81 cells (71 cells get one neuron; 10 get two). Firing adds an average uniform +3.00 logit boost to that cell's tokens; ablating a cell's neuron drops its target placement probability by 0.585 while leaving other naked singles on the exact same board untouched.
- Beyond Sudoku: Preliminary tests on work-allocation and graph-coloring tasks show similar constraint-aligned representations (e.g., 0.966–0.976 exact match on worker/machine coverage vs. 0.546 on individual job assignments).
Limitations and Future Work
The deep mechanistic dive focuses on a single 8-layer architecture trained on randomized backtracking traces. It remains an open question whether larger or smaller models—or models trained without backtracking—develop the exact same substructure geometry and naked-single neurons. Additionally, while the authors explain what mid-layer attention heads do with the information they read (OV circuits), they haven't yet reverse-engineered how those heads learn where to look (QK circuits). Future work aims to watch how these circuits crystallize during training (such as checking for sudden "grokking" transitions) and test a wider variety of constraint-satisfaction problems.
Summary updated