TL;DR
Standard Transformers are terrible at solving logic puzzles out of the box—they waste enormous amounts of data just learning the basic geometry of the board, and they occasionally "forget" the starting clues mid-thought. By baking the puzzle's structural rules directly into the attention mechanism and clamping fixed clues in place after every reasoning step, the authors built a tiny, recurrent Transformer (CSP-RSB) that solves Sudoku, binary puzzles, and graph coloring in a single forward pass. It beats previous neural solvers—even those relying on expensive test-time search—using a fraction of the training data.
What Problem Does This Paper Address?
Constraint Satisfaction Problems (CSPs)—like Sudoku or graph coloring—are unforgiving benchmarks for neural reasoning. Unlike generating a paragraph of text where "close enough" works, a single wrong digit in a Sudoku grid invalidates the entire board.
Existing neural approaches struggle with an architectural catch-22:
- Data Inefficiency: Standard recurrent Transformers treat all tokens equally, forcing the network to burn through massive datasets just to discover from scratch what a "row," "column," or "3x3 block" is.
- Axiom Drift: As continuous hidden states pass through dozens of layers or recurrent steps, the representations of the initial, unchangeable clues slowly warp—causing the model to accidentally overwrite the very axioms of the puzzle.
- Expensive Search: Recent LLM-based solvers bypass these issues by relying on autoregressive "trial-and-error" and backtracking search at test time, rather than actually solving the constraints in a clean, single forward pass.
Methods
The authors introduce CSP-RSB, a weight-tied recurrent Transformer (a 2-layer block looped over 16 steps) built around three core ingredients:
- Topology-Aware Relational Bias: Instead of letting attention start blind, the authors add a learnable scalar bias directly to the attention logits whenever two variables share a constraint (e.g., same row, column, or block). Unrelated cells aren't masked out—preserving global communication—just gently deprioritized so the model immediately knows who its neighbors are. They pair this with orthogonal structural embeddings (encoding row, column, and block coordinates separately) and a type embedding (
fixedvs.mutable).
- Hard Axiom Clamping: To cure "axiom drift," CSP-RSB treats given clues as immutable laws. After every recurrent step, a binary mask resets the hidden states of all fixed clue positions back to their exact initial embeddings, while gradients only flow through the empty, mutable cells.
- QK-Norm & Linear Step Supervision: Looping the same Transformer block 16 times can cause attention scores to explode and saturate. Applying LayerNorm to Queries and Keys (
QK-Norm) keeps gradients calm. During training, the model predicts the board at every step $t$, with a loss weight $w_t = t/T$ that forgives early exploratory guesses and heavily penalizes the final steps.
Datasets
- RRN-180k: The standard Sudoku benchmark (180k training, 18k validation, 18k test puzzles).
- Given-49k (New Benchmark): The authors noticed many standard training boards are trivial. They filtered RRN-180k by repeatedly applying the basic "naked single" heuristic, discarding any board solved by it. What remains are 49,151 genuinely tough puzzles (mostly 17-clue boards) designed to test multi-step deduction in low-data regimes.
- Kaggle Sudoku (Zero-Shot OOD): Used strictly for out-of-distribution testing in two flavors: Filtered (1.9M human-strategy-solvable boards) and Unfiltered (3M boards, including brutal instances beyond standard human strategies).
- Beyond Sudoku: Erdős–Rényi graph coloring datasets and $10 \times 10$ Binary Puzzles, plus $16 \times 16$ Sudoku.
Key Insights and Ideas
- Priors buy sample efficiency, not a higher ceiling: Ablating the relational bias tanks accuracy by 20.4 percentage points when training on 10% of the data, but only by 0.3 points on 100% of the data. Given enough data, a vanilla Transformer eventually figures out what a Sudoku grid looks like—the structural prior just gets you there with an order of magnitude less data.
- Clamping stops the model from hallucinating over facts: Without hard axiom clamping in low-data regimes (2.5% data), the model violates over 32% of the given clues internally, wasting capacity trying to remember the prompt instead of solving the puzzle.
- You don't need a
[CLS]token: Removing the global aggregation token actually improved low-data accuracy (from 84.10% to 88.28%). The web of overlapping row, column, and block biases already routes global information across the board. - Iterative deduction, not memorization: Across the 16 recurrent steps, easy 33-clue puzzles snap into place around step 8, while hard 17-clue puzzles undergo a sharp phase transition around step 12–13. Early steps check immediate neighbors for collisions; later steps gather distributed elimination evidence.
Key Results
- State-of-the-Art Sudoku Accuracy: Trained on RRN-180k, CSP-RSB hits 99.94% whole-board accuracy on RRN-test, 99.78% on Filtered Kaggle, and 99.13% on Unfiltered Kaggle—beating the previous best Trial & Error search-based solver (99.40%, 99.50%, 98.90%) in a single forward pass, and crushing prior recurrent baselines on Unfiltered Kaggle by ~16–20 percentage points.
- Extreme Data Efficiency: Trained on Given-49k (just ~27% of the data), CSP-RSB still hits 99.84% on RRN-test and 97.81% on Unfiltered Kaggle. With simple symmetry augmentations (rotations, flips, digit swaps) on just 10% of RRN-180k (18k boards), it reaches 99.80%.
- Seamless Task Transfer: Simply by swapping the relation adjacency matrix, the exact same architecture solves Erdős–Rényi graph coloring to 100% accuracy in 9 epochs (where RRN hits 76.26% and vanilla Recurrent Transformers/GATs score 0%) and achieves 99.5–100% on $10 \times 10$ binary puzzles.
Limitations and Future Work
- Hand-Specified Topology: CSP-RSB requires you to know the constraint graph (which cells share a row, edge, or block) ahead of time. Learning the constraint topology directly from raw data remains an open challenge.
- Sequential Recurrence Bottleneck: Because the model loops through its 2-layer block $T=16$ times sequentially, it cannot be parallelized across depth like a standard deep network. The authors suggest exploring parallel scan techniques to speed up recurrence.
Summary updated