Transformers Can Learn Rules They've Never Seen: Proof of Computation Beyond Interpolation
Organizations: Kortical
Abstract
A central question in the debate over large language models is whether transformers can learn rules they have never seen, or whether they can only interpolate: predict new cases from their similarity to training examples. We test this in a controlled setting where interpolation provably fails, so success can only come from computation beyond interpolation. We train small transformers to predict the rollout of a cellular automaton whose update rule is pure XOR, and remove one entry of the rule's truth table from all direct supervision. The missing entry's output is never shown to the model; its only trace is indirect, as wrong values corrupt visible predictions at later timesteps. Because XOR parity flips whenever one input bit is changed, every one-bit neighbour of the missing entry carries the opposite label, and we prove that similarity-based predictors, including nearest-neighbour, kernel, and Gaussian-process methods, are forced to the wrong answer. A two-layer transformer can nevertheless recover the missing entry, and circuit extraction confirms it computes XOR exactly. Ablations show the recovery depends on gradient signal propagating through multi-step prediction, and a second, structurally unrelated benchmark on symbolic operator chains exhibits the same capacity under ordinary autoregressive training. Together with a constructive proof that a standard transformer block can implement exact local Boolean rules, these results provide an existence proof that transformers can learn rule structure not directly observed in training and express it explicitly. This rules out the strongest architectural form of the interpolation-only account, the claim that transformers cannot in principle discover and communicate unseen rules, while leaving open when such behaviour arises in large-scale language training.
Figures & tables
| Representation Level | KNN | GP | RBF SVM | RF | Transformer |
|---|---|---|---|---|---|
| Input space (3-bit) | 0 | 0 | 0 | 0 | 96.8 |
| Nbhd. embedding (192-d) | 0 | 0 | 0 | 0 | 96.8 |
| Single-pos. embedding (64-d) | 34–42 | 5–27 | 0 | 0 | 96.8 |
| Single-pos. hidden (64-d) | 0–100 | 0–100 | 0–100 | 94–100 | 96.8 |
| Nbhd. hidden (192-d) | 72–100 | 0–100 | 0–100 | 95–100 | 96.8 |
| Experiment | Mean | 95% CI | Successes |
|---|---|---|---|
| Rule D =8 (soft) | 96.7% | [94.1, 99.2] | 10/10 |
| Rule G =8 (soft) | 99.5% | [99.2, 99.7] | 10/10 |
| Rule D =8 (hard/STE) | 65.5% | [59.2, 71.9] | 1/10 |
| Rule 150 (soft, 220 ep.; initially failed patterns) | 71.5% | [61.6, 81.4] | 47/60 |
| Rule 150 (soft, 50 ep.; all 8 patterns) | 10.6% | [4.1, 17.1] | 8/80 |
| Rule D =8, no unrolling (1 step) | 63.1% | [62.7, 63.5] | 0/10 |
| Holdout | Full (familiar) | Full (opaque) | Label-only |
|---|---|---|---|
| ˆ | | 73.2 2.0 | 73.0 5.1 | 29.1 0.8 |
| &L | 55.3 3.9 | 65.9 1.9 | 14.5 2.5 |
| R ˆ | 28.2 6.6 | 24.6 7.0 | 6.1 3.2 |
| d| | 54.4 17.7 | 56.3 14.2 | 33.3 9.8 |
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | ||||||||
|---|---|---|---|---|---|---|---|---|
| Seed 4444 | ||||||||
| Seed 456 |
| Layer Ablated | Seed 4444 | Seed 456 |
|---|---|---|
| Layer 0 | 20.5% (79.5% drop) | 13.1% (86.9% drop) |
| Layer 1 | 0.0% (100% drop) | 0.0% (100% drop) |
| Layer | Seed 4444 | Seed 456 |
|---|---|---|
| Embedding | 1.2% | 2.7% |
| After layer 0 | 0.0% | 0.0% |
| After layer 1 | 100.0% | 100.0% |
| Layer | Left | Centre | Right | XOR |
|---|---|---|---|---|
| Embedding | 51.6% | 100.0% | 51.5% | 51.6% |
| After layer 0 | 75.4% | 100.0% | 75.3% | 56.8% |
| After layer 1 | 76.8% | 99.2% | 75.8% | 98.4% |
| Patch Point | Seed 4444 Recovery | Seed 456 Recovery |
|---|---|---|
| Embedding | 98.6% | 98.6% |
| After layer 0 | 98.6% | 100.0% |
| After layer 1 | 100.0% | 100.0% |
| Method | Hidden Pattern [2] | Hidden Pattern [5] |
|---|---|---|
| Random Forest (500 trees) | 0.2% | 0.4% |
| Random Forest (100 trees) | 8.4% | 11.8% |
| KNN ( =1) | 42.5% | 42.1% |
| KNN ( =5) | 36.2% | 36.1% |
| Hidden % | Mean Accuracy | Successes | |
|---|---|---|---|
| 4 | 12% | 99.4% | 10/10 |
| 8 | 25% | 96.7% | 10/10 |
| 10 | 31% | 99.6% | 10/10 |
| 12 | 38% | 99.6% | 10/10 |
| 14 | 44% | 99.8% | 10/10 |
| 16 | 50% | 55.3% | 0/10 |
| Hidden % | Mean Accuracy | Successes | |
|---|---|---|---|
| 14 | 44% | 99.3% | 10/10 |
| 16 | 50% | 99.2% | 10/10 |
| 20 | 62% | 99.2% | 10/10 |
| 24 | 75% | 97.1% | 10/10 |
| 26 | 81% | 81.3% | 7/10 |
| 27 | 84% | 95.7% | 9/10 |
| Rule | Formula | Seeds | Mean Acc. | Successes |
|---|---|---|---|---|
| Rule D | 10 | 96.7% | 10/10 | |
| Rule G | 10 | 99.5% | 10/10 |
| 50 epochs | 220 epochs | |||
|---|---|---|---|---|
| Pattern | Rule 150 | Rule 30 | Rule 106 | Rule 150 |
| 0 | 0/10 | 1/10 | 10/10 | 3/10 |
| 1 | 0/10 | 5/10 | 10/10 | 10/10 |
| 2 | 4/10 | 6/10 | 0/10 | — |
| 3 | 0/10 | 10/10 | 8/10 | 10/10 |
| 4 | 0/10 | 0/10 | 9/10 | 10/10 |
| Pattern | 3-NN vote | Successes | Best holdout |
|---|---|---|---|
| 0 | wrong | 0/10 | 0.0% |
| 1 | wrong | 2/10 | 100.0% |
| 2 | wrong | 4/10 | 100.0% |
| 3 | correct | 5/10 | 100.0% |
| 4 | wrong | 0/10 | 36.2% |
| 5 | wrong | 2/10 | 89.4% |
| Timesteps | Identifiability | Mean Unknowns | Mean Constraints | Mean Rank |
|---|---|---|---|---|
| 1 | 0% | 12.5 | 0.0 | 0.0 |
| 2 | 100% | 12.5 | 31.4 | 12.5 |
| 3 | 100% | 12.5 | 58.8 | 12.5 |
| 4 | 100% | 12.5 | 101.2 | 12.5 |
| Holdout | Seed | Full (familiar) | Full (opaque) | Label-only |
|---|---|---|---|---|
| ˆ | | 42 | 70.4 | 66.0 | 28.0 |
| 123 | 74.0 | 78.2 | 29.6 | |
| 456 | 75.2 | 74.8 | 29.6 | |
| Mean | 73.2 2.0 | 73.0 5.1 | 29.1 0.8 | |
| &L | 42 | 50.8 | 67.6 | 13.0 |
| 123 | 60.2 | 66.8 | 18.0 |
| Holdout | Transformer | KNN | MLP | KRR | Oracle | Learned Tables |
|---|---|---|---|---|---|---|
| ˆ | | 73.2 | 0 | 0 | 13.8 | 100 | 100 |
| ˆ r | 53.4 | 0 | 0 | 11.8 | 100 | 99.6 |
| &L | 55.3 | 0 | 0 | 0.2 | 100 | 99.2 |
| d| | 54.4 | 0 | 0 | 3.2 | 100 | 99.8 |
| R ˆ | 28.2 | 0 | 0 | 7.2 | 100 | 99.8 |
| |& | 12.3 | 0 | 0 | 0.4 | 100 | 100 |
| Op 1 accuracy | Op 2 accuracy | |||
|---|---|---|---|---|
| Holdout | Pos 0 ( ) | Pos 1 ( ) | Pos 3 ( ) | Pos 4 ( ) |
| ˆ | | 63.9 | 61.7 | 83.8 | 56.5 |
| &L | 49.2 | 52.3 | 85.0 | 46.9 |
| R ˆ | 70.8 | 67.6 | 84.7 | 37.3 |
| d| | 58.4 | 53.3 | 84.8 | 44.9 |
| Predicting | ˆ | | &L | R ˆ | d| |
|---|---|---|---|---|
| : attention to | 84.9% | 57.2% | 84.0% | 91.2% |
| : attention to | 74.0% | 62.3% | 68.4% | 77.6% |
| : attention to | 24.8% | 34.9% | 27.6% | 19.6% |
| Corrupted position | ˆ | | &L | R ˆ | d| |
|---|---|---|---|---|
| op 1 changed | 73.0% | 68.0% | 62.0% | 73.7% |
| op 1 changed | 73.7% | 73.3% | 67.0% | 73.7% |
| op 2 changed | 70.7% | 69.7% | 69.3% | 70.0% |
| op 2 changed | 77.0% | 78.7% | 75.3% | 78.3% |
| op 1 changed | 3.0% | 1.0% | 1.3% | 1.0% |
| op 2 changed | 1.7% | 0.7% | 0.7% | 1.0% |
| Layer | Target | ˆ | | &L | R ˆ | d| |
| Embedding | op 2 | 6.6 | 4.6 | 2.4 | 10.4 |
| After dec-0 | op 2 | 97.5 | 87.2 | 82.0 | 89.6 |
| After dec-1 | op 2 | 100 | 100 | 99.9 | 100 |
| Embedding | op 1 | 0.0 | 3.9 | 1.7 | 0.6 |
| After dec-0 | op 1 | 61.8 | 47.9 | 54.3 | 60.1 |
| After dec-1 | op 1 | 93.1 | 91.6 | 94.9 | 93.6 |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 535 papers