Pith. sign in

REVIEW 4 major objections 5 minor 176 references

Discovering Interpretable Algorithms by Decompiling Transformers to RASP

T0 review · 4 major / 5 minor · reviewed 2026-08-03 · deepseek-v4-flash

Pith's one-line read This paper claims that small transformers that length-generalize on algorithmic and formal-language tasks can be decompiled into short, human-readable RASP programs, and presents an automatic method that does so.

desk verdict Genuinely new decompilation pipeline that recovers compact RASP programs from trained small transformers; the central 'internally implement' claim rests on a 90% match-accuracy criterion, so treat extracted programs as fitted surrogates until exact or unique match is shown. read the letter →

arxiv 2602.08857 v2 pith:3AFBIADC submitted 2026-02-09 cs.LG cs.AIcs.CL

classification cs.LGcs.AIcs.CL
keywords transformerinterpretabilityRASPdecompilationlengthgeneralizationmechanisticcausalpruningD-RASPformallanguages
verification ladder T0 review T1 audit T2 compute T3 formal

The pith

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The reading

The paper claims that when a small transformer trained on a synthetic algorithmic or formal-language task learns to generalize beyond its training length, its internal computation often is a compact, interpretable RASP program—and that this program can be recovered automatically. To show this, it introduces D-RASP, a RASP dialect that mirrors transformer primitives, proves that any GPT-2-style transformer satisfying a linearized layer-norm assumption can be faithfully reparameterized as a D-RASP program, and then prunes that program by causal intervention until a short sufficient sub-program remains. Across tasks, the extracted programs align with hypothesized mechanisms such as histogram-based majority, induction-head copying, and bracket counting, while models that fail to length-generalize usually cannot be decompiled. A sympathetic reader should come away with the conclusion that length generalization and internal program-likeness go together, and that symbolic programs, rather than length-specific circuits, are a fitting description of what these models compute.

What carries the argument

The central object is D-RASP (Decompiled RASP), a RASP dialect using softmax aggregation and one-hot token and position variables, designed so transformer computations can be faithfully represented. Theorem 3.2 shows that any GPT-2-style transformer satisfying the linear layer norm assumption can be exactly translated into a D-RASP program by tracking each path through the residual stream as a separate variable. Because the naive translation is exponentially large, the load-bearing mechanism is the causal-pruning step: trainable masks and optimal ablations remove causally irrelevant components, and a library of primitives replaces learned matrices and per-position maps with named operations

What would settle it

Take one of the decompiled programs and evaluate it on a deliberately constructed set of inputs where it disagrees with the original model, including lengths beyond the training range; if the model generalizes correctly on those inputs while the program fails, then the extracted program is not the algorithm driving the model's behavior.

Watch

Extended reading notes

Core claim

The central discovery is that the inverse of compiling RASP to transformers works: a trained transformer can be translated back into a readable program. Under the Linear Layer Norm Assumption, every GPT-2-style transformer has an exact D-RASP representation whose variables live in interpretable spaces such as token identities and positions, and causal pruning can reduce the exponentially large naive translation to a few lines that still match the original model on at least 90 percent of random inputs. On algorithmic and formal-language tasks, the method recovers compact programs that recapitulate known mechanisms—uniform aggregation computing a histogram for most-frequent, an off-by-one sele

Load-bearing premise

The load-bearing premise is that matching the model's predictions on at least 90 percent of random inputs—after assuming layer norms can be replaced by linear maps—is enough to conclude the extracted program is the algorithm the transformer internally implements.

Editorial extensions

If this is right

  • If decompilability tracks length generalization, then successful length generalization in these settings is accompanied by an extractable symbolic algorithm, strengthening the RASP length-generalization conjecture.
  • The extracted programs apply uniformly over input lengths, unlike circuits found by circuit discovery, so they can explain behavior on out-of-distribution lengths rather than only training templates.
  • Because D-RASP program size is independent of hidden dimension, even overparameterized models can yield small interpretable programs.
  • The recovered programs match mechanisms hypothesized in prior theory, providing independent confirmation of those hypotheses.
  • The method offers a practical pipeline for future interpretability work: reparameterize faithfully, prune causally, then name operations with primitives.

Reading between the lines

Editorial extensions of the paper, not claims the author makes directly.

  • I would treat a successful decompilation as a strong hypothesis about the model's algorithm rather than a proof: the 90 percent match threshold means a program could disagree with the model on the remaining inputs, including the long sequences where generalization is actually being tested.
  • If the correlation holds more broadly, decompilability itself could serve as a diagnostic: run the pipeline on a model and use whether a compact program emerges as a proxy for whether it will length-generalize.
  • The same reparameterize-and-prune recipe might be adapted to larger language models by decompiling individual subtasks rather than the whole model, though the paper does not claim this.
  • A natural testable extension is to compile the extracted programs back into transformers and check behavioral equivalence on adversarial inputs, which would sharpen the faithfulness question.
Share X Bluesky LinkedIn Reddit HN

Editorial analysis

A structured set of objections, weighed in public.

Desk editor's note, referee report, and a circularity audit.

Referee Report

4 major / 5 minor

Summary. The paper proposes a decompilation pipeline that translates small GPT-2-style transformers into programs in a new RASP dialect, D-RASP, and then prunes/simplifies these programs to obtain compact, human-readable algorithms. The authors prove (Theorem 3.2, under a linear layer-norm assumption) that a transformer can be exactly reparameterized as a D-RASP program, and they validate the simplification stage empirically by requiring the extracted program to match the original model's predictions on ≥90% of random i.i.d. inputs of length up to 150. On a suite of algorithmic and formal-language tasks, they report that length-generalizing models are usually decompilable while non-length-generalizing models are not, and they present several recovered programs that align with known algorithmic motifs such as histogram-based majority, induction-head copying, and bounded-depth Dyck recognition.

Significance. If the central claim holds, this is a valuable contribution to mechanistic interpretability: it would provide the first automated extraction of symbolic, length-generalizing programs from normally trained transformers, connecting the RASP length-generalization conjecture to actual trained models. The paper includes a detailed proof of exact reparameterization under LLNA, extensive appendices with per-task programs, and a public code link, all of which are strengths. The recovered programs for tasks like Unique Copy and Most Frequent are genuinely interpretable and match prior theoretical expectations. However, the significance is tempered by the fact that the main empirical claim rests on a 90% match-accuracy threshold rather than exact equivalence, and the experimental protocol selects the best length-generalizing model per task without repeated-seed error bars. These issues do not invalidate the method but do weaken the strong wording 'most direct evidence so far that Transformers internally implement simple RASP programs.'

major comments (4)
  1. [§3.2, FAQ 8] The central faithfulness criterion is behavioral match accuracy ≥90% on random i.i.d. inputs of length ≤150, explicitly chosen 'based on common sense.' This threshold does not establish that the extracted program is the algorithm the transformer internally implements: a program agreeing on 90% of inputs can differ on the remaining 10%, including precisely the structured or out-of-distribution inputs most relevant to length generalization. The exactness guarantee in Theorem 3.2 holds only before the simplification steps; every subsequent step (causal pruning, primitive replacement, matrix rounding) is validated by aggregated match accuracy with additional thresholds (0.92, 0.95×, 0.91× in Apps. G–H). The paper should either provide exact or near-exact equivalence checks on held-out and OOD length ranges, or substantially soften the claim that decompilation recovers the internal algorithm.
  2. [§4, Tables 1 and 2] The models analyzed are selected as the best length-generalizers from a hyperparameter sweep, with no repeated-seed variance or error bars. The claim that 'length-generalizing models can be decompiled and non-length-generalizing models cannot' is therefore not yet supported as a general empirical law. Moreover, Table 2 itself lists five length-generalizing formal-language models where LLNA does not hold (Tomita4, D3, (aaaa)*, (abab)*, {0,1,2}*02*), and D12 succeeds only after a post-hoc threshold adjustment. The paper acknowledges these exceptions but should analyze them more directly, e.g., by reporting whether these models are nevertheless decomposable into interpretable programs under a weaker notion of faithfulness.
  3. [§3.2, App. F–H] There is an element of circularity in the success criterion: the pipeline fits sparse coefficients, primitive replacements, and integer/rounded matrices to maximize match accuracy, and then declares success when match accuracy exceeds 90%. This means the extracted program is partly a fitted surrogate rather than an independently discovered cause. To break the circularity, the authors should validate a few extracted programs by testing their causal predictions on the original model—e.g., by intervening on the model's internal components in the way the program describes and showing that behavior changes accordingly—or by demonstrating that the program predicts model behavior on adversarial, structured inputs that were not used during pruning.
  4. [Theorem 3.2, Assumption 3.1] The exact reparameterization theorem relies critically on LLNA, yet LLNA is an empirical assumption that fails for a non-negligible subset of the paper's own length-generalizing models (Table 2). The paper states that the pipeline requires LLNA, but the abstract and introduction present the method as general ('a general method to extract such programs from trained Transformers'). The scope should be stated more precisely in the main text, and the authors should discuss whether the LLNA failure cases are a limitation of the method or evidence that those models use genuinely non-linear layer-norm computations.
minor comments (5)
  1. [Throughout] There are repeated typos and informal phrases: 'reparamaterization' (§3 header), 'strinfs' (App. J.3), 'preogram' (App. J.10). The paper would benefit from a careful proofreading pass.
  2. [§4, Table 2] The special cases marked with ×* are explained only in footnotes; a short paragraph in the main text explaining why D12 and D2 are still counted as successes would improve transparency.
  3. [App. F.1, Eq. 19] The sparsity regularizer R(θ̃) is described as 'the expected number of edges' but the exact form is not given; please provide the explicit expression for R.
  4. [App. H, Table 3] The primitive names such as 'op=(k==q-k)' are confusing: the subscript k appears both as a variable and as a constant offset. Please use distinct notation, e.g., 'k == q - c'.
  5. [§3.1, Theorem 3.2] The proof in Appendix B.3 is detailed, but the main-text description of the exponential blow-up and the multi-stage pruning used to avoid it would benefit from a small illustrative example in the main text, not only in the appendix.

Circularity Check

0 steps flagged · score 0.0 of 10

No significant circularity: the simplified programs are fitted to the model, but the empirical claim that simple programs are recoverable is not tautological and no load-bearing step reduces to a self-citation.

full rationale

The derivation has two independent parts. Theorem 3.2 (App. B.3) gives an explicit, exact translation from an LLNA-satisfying GPT-2 transformer to a D-RASP program, with a self-contained induction proof of equality of the input-output map; this is a construction, not a circular prediction. The second part is an empirical search over pruned programs validated by match accuracy. Because the simplification pipeline selects programs using the same match-accuracy criterion, the reported match accuracies are post-fit quantities, but the paper does not present them as held-out predictions. The phrase "we deem decompilation to be causally faithful when the match accuracy is ≥90%" (Sec. 3.2) and the statement that this threshold was "chosen based on common sense" (FAQ 8) show that the faithfulness criterion is a stated convention, not a conclusion derived from the model. One can question whether 90% behavioral match on i.i.d. inputs is enough to establish that the extracted program is the unique internal algorithm, and the paper itself acknowledges that Assumption 3.1 (LLNA) fails for some length-generalizing formal-language models (Table 2, App. E). But those are validity/calibration concerns, not circularity: nothing defines the target result into existence. The cited RASP length-generalization conjecture (Zhou et al. 2024; Huang et al. 2025) is used as motivation and context, not as a load-bearing proof step, and the LLNA motivation is external (Baroni et al. 2025). Self-citations are present but non-load-bearing, so no circular step is exhibited.

Assumptions & free parameters 4 free parameters · 4 assumptions · 1 invented entities

The central method introduces one new representational object (D-RASP) and relies on LLNA as the key domain assumption. Several thresholds and sparsity coefficients are fit or hand-chosen in the simplification stage; these do not determine the theorem but they determine which programs are declared successful.

free parameters (4)
  • Layer-normalization linearization constants gamma' = per-layer, not reported numerically
    Trained to minimize KL divergence in Step 2.1; LLNA's 'negligible change' is only operationalized through these fitted constants and the 90% match criterion.
  • Match-accuracy threshold = 0.9
    Defines 'causally faithful' and decompilation success; chosen 'based on common sense' (FAQ 8).
  • Sparsity coefficients lambda = swept; values not fixed
    Balance KL fidelity vs. number of edges; final program length and match accuracy depend on the chosen lambda on the Pareto frontier.
  • Primitive-matching thresholds and primitive hyperparameters = 0.92, 0.9, 0.95x, 0.91x; n in {2,3,5}, tau in {0.7,...,0.95}
    Hand-chosen thresholds for replacing operations and matrices with library primitives; these choices determine when an operation is declared interpretable.
assumptions (4)
  • domain assumption Linear Layer Norm Assumption: each LayerNorm can be replaced by a linear map (x - mean)gamma' + beta with negligible change (Assumption 3.1).
    Theorem 3.2 and the whole reparameterization depend on it; the paper verifies it empirically via match accuracy, and five length-generalizing formal-language models fail this test.
  • domain assumption GPT-2-style architecture with absolute positional embeddings, softmax attention, one-layer MLPs, and causal masking.
    The D-RASP translation is defined for this architecture only; all experiments use it.
  • domain assumption D-RASP/C-RASP equivalence assumes p-bit rounded semantics and rational tensor entries (Theorem 2.1).
    Used to connect D-RASP to C-RASP and the length-generalization literature; not needed for the central decompilation result but for positioning the dialect.
  • domain assumption The RASP length-generalization conjecture from prior work is accepted as background for interpreting recovered programs.
    The paper says its results 'support and strengthen' this conjecture; the conjecture itself is not re-derived here.
invented entities (1)
  • D-RASP (Decompiled RASP) independent evidence
    purpose: A program representation whose primitives mirror transformer computation while exposing token and position variables; target of the decompilation.
    Fully defined in Sec. 2; D-RASP programs are executable and their predictions can be compared directly against transformer outputs, so the representation itself is checkable.

how reviews work

0 comments
Cite this review

Pith. "Pith review of Discovering Interpretable Algorithms by Decompiling Transformers to RASP." pith.science (2026). https://pith.science/paper/3AFBIADC

@misc{pith2026260208857,
  author       = {Pith},
  title        = {Pith review of: Discovering Interpretable Algorithms by Decompiling Transformers to RASP},
  year         = {2026},
  howpublished = {\url{https://pith.science/paper/3AFBIADC}},
  note         = {Machine review of arXiv:2602.08857}
}
read the original abstract

Recent work has shown that the computations of Transformers can be simulated in the RASP family of programming languages. These findings have enabled improved understanding of the expressive capacity and generalization abilities of Transformers. In particular, Transformers have been suggested to length-generalize exactly on problems that have simple RASP programs. However, it remains open whether trained models actually implement simple interpretable programs. In this paper, we present a general method to extract such programs from trained Transformers. The idea is to faithfully re-parameterize a Transformer as a RASP program and then apply causal interventions to discover a small sufficient sub-program. In experiments on small Transformers trained on algorithmic and formal language tasks, we show that our method often recovers simple and interpretable RASP programs from length-generalizing transformers. Our results provide the most direct evidence so far that Transformers internally implement simple RASP programs.

Figures

Figures reproduced from arXiv: 2602.08857 by the authors.

Figure 1
Figure 1. Program (a) for finding the most frequent character in a string, extracted from a real transformer. An example input is BOS o b r o SEP o ; the model is trained to predict the last token “o”. Line 1 computes, at each position, the relative frequencies of symbols at preceding positions (a1 ∈ R |Σ|×N , in (b). x-axis = input string, y-axis = variable dims., by aggregating over token ∈ R |Σ|×N (Figure 2b). In Line 1, s… view at source ↗
Figure 2
Figure 2. Initial variables on the example input used in [PITH_FULL_IMAGE:figures/full_fig_p003_2.png] view at source ↗
Figure 4
Figure 4. Causal Pruning (Step 2.1): Pareto frontiers over lines of code vs. match accuracy for models satisfying LLNA. Decompiled program for SORT 1. s1 = select(q=token, k=token, op= a ) 2. a1 = aggregate(s=s1, v=token) 3. new_a1 = element_wise_op(a1) 4. logits1 = project(inp=new_a1) 5. prediction = softmax(logits1) 0 1 2 3 4 5 6 7 8 9 ... <sep> <eos> <pad> 0 1 2 3 4 5 6 7 8 9 ... <sep> <eos> <pad> 200 0 200 400 (a) Line 1:… view at source ↗
Figures from the paper (88 more)
Figure 3
Figure 3. Figure 3: An extracted program for copying a string without repeti￾tions: The input BOS 1 3 4 2 SEP is completed with the string 1 3 4 2 EOS . The primitive “k == q-1” (line 1) selects the position immediately preceding the query position; it is given by the matrix in (a) (rows …
Figure 6
Figure 6. Figure 6: See text. Rows denote input dimensions; Columns denote output dimensions. In a counting task (Zhou et al., 2024), the model completes e.g. ⟨bos⟩ 12 16 ⟨sep⟩ with 12 13 14 15 16⟨eos⟩. Incrementing counts while counting is done by a projection matrix acting directly on t…
Figure 7
Figure 7. Figure 7: See text. Rows denote input dimensions; Columns denote output di￾mensions The bench￾mark includes bounded-depth Dyck languages at various depths. The models for D2, D4, D12 were decompiled; the model for D3 failed in the layer norm linearization. The algorithms are sim…
Figure 8
Figure 8. Figure 8: Decompiled program for depth-4 Dyck language, on sam￾ple input BOS a a a a b b b b EOS . The program at each step outputs the set of allowed next char￾acters. a1 contains the relative frequencies of a, b, BOS. Line 2 applies an element-wise operation, whose output is d…
Figure 9
Figure 9. Figure 9: See text. B.6. Size of D-RASP Translation The size of the D-RASP translation given by Theorem 3.2 is given by: def determine_total_line(num_layer, num_head, split_mlps): num_v = 2 num_line = 0 for i in range(num_layer): num_line += (num_v ** 2 + num_v) * num_head num_v…
Figure 10
Figure 10. Figure 10: Each subplot shows pareto frontiers for multiple models trained on the same task. They are trained with different hyperparame￾ters and architectures, resulting in different length-generalization and decompilability. Results are from stage 1 of causal pruning, where la…
Figure 11
Figure 11. Figure 11: The checkpoints saved when training model for Unique Copy task (Left) and Unique Bigram Copy task (right). We show both task accuracy on 3 input ranges and decompilability. LLNA holds if the model can achieve > 90% match accuracy after linearizing Layer Norm. Green do…
Figure 12
Figure 12. Figure 12: We show the pareto frontiers in stage 0 of causal pruning (i.e., component-level circuits with original layer norm enabled, see F.4 ) for all models where LLNA does not hold. The green lines correspond to the 6 models that length-generalize but requires original layer…
Figure 13
Figure 13. Figure 13: Pareto frontiers in stage 1 of causal pruning (i.e., component-level circuits with linearized layer norm.) We find all models that achieves nearly perfect task accuracy in training length (specifically, all are ≥ 99.4), and very low accuracy in test length of [101 − 1…
Figure 14
Figure 14. Figure 14: Heatmaps supporting the program for unique copy model. This is discussed in Main paper, [PITH_FULL_IMAGE:figures/full_fig_p039_14.png]
Figure 15
Figure 15. Figure 15: Heatmaps supporting the program for unique copy model. Heatmaps are only rounded, not replaced with primitives. J. Decompiled Programs on Algorithmic Tasks How to read this section Each subsection below shows a D-RASP decompilation of a trained transformer. We report …
Figure 16
Figure 16. Figure 16: Heatmaps supporting the program for Majority model. (a) The identity matrix (temperature-scaled to create effectively hard attention) for normal tokens, uniform on special tokens. <bos> 0 0 0 1 0 <sep> 0 0 1 <bos> <sep> <eos> <pad> 0.0 0.2 0.4 0.6 0.8 1.0 (a) Line 1: …
Figure 17
Figure 17. Figure 17: Variables Heatmaps for Majority model on an example input. (a) Aggregation computes a histogram of symbols seen so far (x-axis is the input, y-axis are the dimensions of the activation). (b) Output logits are directly obtained from (a) in the case of normal tokens, an…
Figure 18
Figure 18. Figure 18: Heatmaps supporting the program for Majority Interleave model. 44 [PITH_FULL_IMAGE:figures/full_fig_p044_18.png]
Figure 19
Figure 19. Figure 19: Variables Heatmaps for Majority Interleave model on an example input. 45 [PITH_FULL_IMAGE:figures/full_fig_p045_19.png]
Figure 20
Figure 20. Figure 20: Heatmaps supporting the program for Majority Interleave : different arch with same length generalization performance model. <bos> 1 0 1 1 0 1 <sep> 1 0 1 <eos> <bos> 1 0 1 1 0 1 <sep> 1 0 1 <eos> 15 10 5 0 5 (a) Line 1: s1 <bos> 1 0 1 1 0 1 <sep> 1 0 1 <eos> <bos> 1 0…
Figure 21
Figure 21. Figure 21: Variables Heatmaps for Majority Interleave : different arch with same length generalization performance model on an example input. 47 [PITH_FULL_IMAGE:figures/full_fig_p047_21.png]
Figure 22
Figure 22. Figure 22: MLP Input-Output for token: 0 (sorted by logits) Output Token: 1 48 [PITH_FULL_IMAGE:figures/full_fig_p048_22.png]
Figure 23
Figure 23. Figure 23: MLP Input-Output for token: 1 (sorted by logits) Output Token: EOS 49 [PITH_FULL_IMAGE:figures/full_fig_p049_23.png]
Figure 24
Figure 24. Figure 24: MLP Input-Output for token: EOS (sorted by logits) J.4. Count Task Description: ⟨bos⟩ s0, sn ⟨sep⟩ s0s1 . . . sn ⟨eos⟩where s0, sn ∈ {0, 1, . . . , 150}, sn > s0, si+1 = si + 1 Architecture: Layers: 1 Heads: 4 Hidden Dim: 256 LR: 0.0001 Dropout: 0.1 Performance (w/Pru…
Figure 25
Figure 25. Figure 25: Heatmaps supporting the program for Count model. 52 [PITH_FULL_IMAGE:figures/full_fig_p052_25.png]
Figure 26
Figure 26. Figure 26: Variables Heatmaps for Count model on an example input. MLP Input-Output Distributions Explaining per-position operation in Line 6 via its effect on Output Logits in Line 9 Output Token: 1 53 [PITH_FULL_IMAGE:figures/full_fig_p053_26.png]
Figure 27
Figure 27. Figure 27: MLP Input-Output for token: 1 (sorted by logits) Output Token: 10 10 ... 61 ... 72 ... 74 ... 89 90 91 ... 98 99 100 ... 118 ... 133 ... 137 ... 140 ... 142 ... 145 ... 148 149 <bos> Input Features logit:10 2.47 2.35 2.04 1.53 1.11 1.05 0.34 0.24 0.18 0.01 0.00 -0.79 …
Figure 28
Figure 28. Figure 28: MLP Input-Output for token: 10 (sorted by logits) Output Token: 100 57 ... 66 ... 88 ... 94 ... 98 ... 100 ... 110 ... 118 119 120 ... 129 ... 135 ... 144 145 Input Features logit:100 0.93 0.89 0.89 0.84 0.83 0.76 0.75 0.74 0.73 0.71 0.70 0.68 0.63 0.60 0.58 0.55 0.40…
Figure 29
Figure 29. Figure 29: MLP Input-Output for token: 100 (sorted by logits) 54 [PITH_FULL_IMAGE:figures/full_fig_p054_29.png]
Figure 30
Figure 30. Figure 30: MLP Input-Output for token: EOS (sorted by logits) J.5. Count : different arch with same length generalization performance Task Description: ⟨bos⟩ s0, sn ⟨sep⟩ s0s1 . . . sn ⟨eos⟩where s0, sn ∈ {0, 1, . . . , 150}, sn > s0, si+1 = si + 1 Performance (w/Pruning → w/Pri…
Figure 31
Figure 31. Figure 31: Heatmaps supporting the program for Count : different arch with same length generalization performance model. 56 [PITH_FULL_IMAGE:figures/full_fig_p056_31.png]
Figure 32
Figure 32. Figure 32: Variables Heatmaps for Count : different arch with same length generalization performance model on an example input. 57 [PITH_FULL_IMAGE:figures/full_fig_p057_32.png]
Figure 33
Figure 33. Figure 33: MLP Input-Output for token: 1 (sorted by logits) Output Token: 10 14 ... 18 ... 25 ... 30 Input Features logit:10 -0.00 -0.01 -0.01 -0.02 -0.04 -0.05 -0.06 -0.06 -0.06 -0.06 -0.99 -0.99 -0.99 -0.99 -1.00 -1.99 -2.92 -3.72 -4.24 -5.11 -9.26 Output 0.0 0.2 0.4 0.6 0.8 7…
Figure 34
Figure 34. Figure 34: MLP Input-Output for token: 10 (sorted by logits) Output Token: 100 58 [PITH_FULL_IMAGE:figures/full_fig_p058_34.png]
Figure 35
Figure 35. Figure 35: MLP Input-Output for token: 100 (sorted by logits) Output Token: EOS 2 ... 6 ... 13 ... 18 ... 20 ... 24 25 ... 31 ... 40 ... 49 ... 56 ... 60 ... 77 ... 85 ... 89 ... 103 104 ... 110 111 ... 113 ... 116 ... 121 ... 132 ... 143 ... 149<bos> Input Features logit:<eos> …
Figure 36
Figure 36. Figure 36: MLP Input-Output for token: EOS (sorted by logits) Explaining per-position operation in Line 3 via its effect on Output Logits in Line 9 Output Token: 1 59 [PITH_FULL_IMAGE:figures/full_fig_p059_36.png]
Figure 37
Figure 37. Figure 37: MLP Input-Output for token: 1 (sorted by logits) Output Token: 10 3 ... 9 10 ... 25 ... 29 ... 36 37 38 ... 45 ... 141 ... 147 ... <bos> <sep> Input Features logit:10 3.08 2.16 2.05 1.80 1.74 0.69 0.09 0.00 -0.03 -0.05 -0.08 -0.17 -2.05 -2.05 -2.05 -2.05 -4.10 -6.07 -…
Figure 38
Figure 38. Figure 38: MLP Input-Output for token: 10 (sorted by logits) Output Token: 100 60 [PITH_FULL_IMAGE:figures/full_fig_p060_38.png]
Figure 39
Figure 39. Figure 39: MLP Input-Output for token: 100 (sorted by logits) Output Token: EOS 4 ... 17 18 ... 27 ... 39 ... 47 ... 61 ... 130 ... <bos> <sep> Input Features logit:<eos> 6.54 6.25 6.23 6.23 6.20 6.16 6.15 6.08 6.02 6.01 5.88 5.86 5.86 5.85 5.83 5.23 4.58 3.93 3.27 2.62 1.96 1.3…
Figure 40
Figure 40. Figure 40: MLP Input-Output for token: EOS (sorted by logits) Explaining per-position operation in Line 3 via its effect on Output Key in Line 5 See [PITH_FULL_IMAGE:figures/full_fig_p061_40.png]
Figure 41
Figure 41. Figure 41: MLP Input-Output (sorted by logits) J.6. Most Frequent Task Description: ⟨bos⟩ s ⟨sep⟩ Maj(s) where s ∈ {a, b, c, . . . , y, z} ∗ Architecture: Layers: 1 Heads: 4 Hidden Dim: 256 LR: 0.001 Dropout: 0.1 Performance (w/Pruning → w/Primitives): Task Accuracy: 0.99 → 1.00…
Figure 42
Figure 42. Figure 42: Heatmaps supporting the program for Most Frequent model. The identity matrix (temperature-scaled to create effectively hard attention) for normal tokens, uniform on special tokens. 62 [PITH_FULL_IMAGE:figures/full_fig_p062_42.png]
Figure 43
Figure 43. Figure 43: Variables Heatmaps for Most Frequent model on an example input. (a) Aggregation computes a histogram of symbols seen so far (x-axis is the input, y-axis are the dimensions of the activation). (b) Output logits are directly obtained from (a) in the case of normal token…
Figure 44
Figure 44. Figure 44: Heatmaps supporting the program for Most Frequent : different architecture model. <bos> o b r o <sep> o a b c d e f g h i j k l m n o p q r s t u v w x y z <bos> <sep> <eos> <pad> 0.0 0.2 0.4 0.6 0.8 1.0 (a) Line 1: a1 <bos> o b r o <sep> o a b c d e f g h i j k l m n…
Figure 45
Figure 45. Figure 45: Variables Heatmaps for Most Frequent : different architecture model on an example input. J.8. Sort Task Description: ⟨bos⟩ s ⟨sep⟩ sσ(0), sσ(0) . . . sσ(n) ⟨eos⟩where s0 ∈ {0, 1, . . . , 150}, si+1 = si + 1, σsortss Architecture: Layers: 1 Heads: 1 Hidden Dim: 256 LR:…
Figure 46
Figure 46. Figure 46: Heatmaps supporting the program for Sort model. Part of this matrix is shown in [PITH_FULL_IMAGE:figures/full_fig_p065_46.png]
Figure 47
Figure 47. Figure 47: Variables Heatmaps for Sort model on an example input. (a) The selector (rows index query positions, columns index key positions) favors numbers slightly larger than the current one. (b) The resulting weighted histogram. (c) Next-token predictions result from applying…
Figure 48
Figure 48. Figure 48: MLP Input-Output for token: 0 (sorted by logits). The operation hardens the input by promoting the output dimension for “0” when the input has a high entry in this dimension; similarly for the other dimensions. Output Token: 10 10 ... 27 ... 58 ... 60 ... 65 ... 87 ..…
Figure 49
Figure 49. Figure 49: MLP Input-Output for token: 10 (sorted by logits) Output Token: 100 67 [PITH_FULL_IMAGE:figures/full_fig_p067_49.png]
Figure 50
Figure 50. Figure 50: MLP Input-Output for token: 100 (sorted by logits) Output Token: EOS 4 ... 6 ... 14 15 ... 22 ... 26 ... 30 ... 59 ... 66 ... 109 ... 111 112 ... 115 ... 123 ... 129 130 ... 147 ... <bos> Input Features logit:<eos> 16.28 14.55 14.45 13.97 13.62 13.45 13.15 13.10 12.97…
Figure 51
Figure 51. Figure 51: MLP Input-Output for token: EOS (sorted by logits). The operation generates a high logit for EOS when the input activation has a high entry for BOS. J.9. Unique Bigram Copy Task Description: ⟨bos⟩ s0, s1, . . . , sn ⟨sep⟩ s0, s1, . . . , sn ⟨eos⟩where si ∈ {0, 1, . . …
Figure 52
Figure 52. Figure 52: Heatmaps supporting the program for Unique Bigram Copy model. In (c) and (d), the input to the operation is a result of Cartesian product of three variables, all of which have dimension |Σ|, resulting in a total input size of |Σ| × |Σ| × |Σ|. We visualize only the top…
Figure 53
Figure 53. Figure 53: Variables Heatmaps for Unique Bigram Copy model on an example input. In (f), similarly to [PITH_FULL_IMAGE:figures/full_fig_p070_53.png]
Figure 54
Figure 54. Figure 54: Heatmaps supporting the program for Unique Bigram Copy : different checkpoints model. We note that replacement with a primitive was successful in (b,c), and not in (a,d,e). 71 [PITH_FULL_IMAGE:figures/full_fig_p071_54.png]
Figure 55
Figure 55. Figure 55: Variables Heatmaps for Unique Bigram Copy : different checkpoints model on an example input. J.11. Unique Copy Task Description: ⟨bos⟩ s0, s1, . . . , sn ⟨sep⟩ s0, s1, . . . , sn ⟨eos⟩where si ∈ {0, 1, . . . , 150}, si ̸= sj iff i ̸= j Architecture: Layers: 2 Heads: 1…
Figure 56
Figure 56. Figure 56: Heatmaps supporting the program for Unique Copy model. 73 [PITH_FULL_IMAGE:figures/full_fig_p073_56.png]
Figure 57
Figure 57. Figure 57: Variables Heatmaps for Unique Copy model on an example input. 74 [PITH_FULL_IMAGE:figures/full_fig_p074_57.png]
Figure 58
Figure 58. Figure 58: Heatmaps supporting the program for Unique Reverse model. 76 [PITH_FULL_IMAGE:figures/full_fig_p076_58.png]
Figure 59
Figure 59. Figure 59: Variables Heatmaps for Unique Reverse model on an example input. 77 [PITH_FULL_IMAGE:figures/full_fig_p077_59.png]
Figure 60
Figure 60. Figure 60: Heatmaps supporting the program for Unique Reverse : different architecture with same length generalization performance model. 78 [PITH_FULL_IMAGE:figures/full_fig_p078_60.png]
Figure 61
Figure 61. Figure 61: Variables Heatmaps for Unique Reverse : different architecture with same length generalization performance model on an example input. MLP Input-Output Distributions Explaining per-position operation in Line 7 via its effect on Output Logits in Line 8 79 [PITH_FULL_IM…
Figure 62
Figure 62. Figure 62: MLP Input-Output for token: 0 (sorted by logits) Output Token: 10 80 [PITH_FULL_IMAGE:figures/full_fig_p080_62.png]
Figure 63
Figure 63. Figure 63: MLP Input-Output for token: 10 (sorted by logits) Output Token: 100 81 [PITH_FULL_IMAGE:figures/full_fig_p081_63.png]
Figure 64
Figure 64. Figure 64: MLP Input-Output for token: 100 (sorted by logits) Output Token: EOS 13 ... 32 ... 45 ... 48 ... 58 ... 70 ... 99 ... 118 ... 146 ... <bos> Input Features logit:<eos> 39.97 39.79 39.47 39.00 38.79 38.75 38.69 38.69 38.63 38.53 35.93 35.87 35.82 35.80 35.74 31.95 20.74…
Figure 65
Figure 65. Figure 65: MLP Input-Output for token: EOS (sorted by logits) 82 [PITH_FULL_IMAGE:figures/full_fig_p082_65.png]
Figure 66
Figure 66. Figure 66: Heatmaps supporting the program for Dyck-12 model. 84 [PITH_FULL_IMAGE:figures/full_fig_p084_66.png]
Figure 67
Figure 67. Figure 67: Variables Heatmaps for Dyck-12 model on an example input. 85 [PITH_FULL_IMAGE:figures/full_fig_p085_67.png]
Figure 68
Figure 68. Figure 68: MLP Input-Output for token: a (sorted by logits) Output Token: b a b <bos> 0.92 0.00 0.08 0.92 0.00 0.08 0.91 0.00 0.09 0.87 0.07 0.07 0.90 0.00 0.10 0.86 0.07 0.07 0.89 0.00 0.11 0.85 0.08 0.08 0.82 0.12 0.06 0.82 0.12 0.06 0.81 0.12 0.06 0.88 0.00 0.12 0.82 0.09 0.0…
Figure 69
Figure 69. Figure 69: MLP Input-Output for token: b (sorted by logits) Output Token: EOS 86 [PITH_FULL_IMAGE:figures/full_fig_p086_69.png]
Figure 70
Figure 70. Figure 70: MLP Input-Output for token: EOS (sorted by logits) Explaining per-position operation in Line 9 via its effect on Output Logits in Line 12 Output Token: a a b <bos> 0.00 0.00 1.00 0.30 0.00 0.70 0.30 0.00 0.70 0.30 0.00 0.70 0.30 0.00 0.70 0.31 0.00 0.69 0.31 0.00 0.69…
Figure 71
Figure 71. Figure 71: MLP Input-Output for token: a (sorted by logits) 87 [PITH_FULL_IMAGE:figures/full_fig_p087_71.png]
Figure 72
Figure 72. Figure 72: MLP Input-Output for token: b (sorted by logits) Output Token: EOS 88 [PITH_FULL_IMAGE:figures/full_fig_p088_72.png]
Figure 73
Figure 73. Figure 73: MLP Input-Output for token: EOS (sorted by logits) K.2. Dyck-2 Task Description: ⟨bos⟩ (a(ab) ∗ b) ∗ ⟨eos⟩ Architecture: Layers: 1 Heads: 1 Hidden Dim: 16 LR: 0.001 Dropout: 0 Performance (w/Pruning → w/Primitives): Task Accuracy: 1.00 → 1.00; Match Accuracy: 1.00 → 1…
Figure 74
Figure 74. Figure 74: Heatmaps supporting the program for Dyck-2 model. 90 [PITH_FULL_IMAGE:figures/full_fig_p090_74.png]
Figure 75
Figure 75. Figure 75: Variables Heatmaps for Dyck-2 model on an example input. MLP Input-Output Distributions Explaining per-position operation in Line 3 via its effect on Output Logits in Line 7 Output Token: a 91 [PITH_FULL_IMAGE:figures/full_fig_p091_75.png]
Figure 76
Figure 76. Figure 76: MLP Input-Output for token: a (sorted by logits) Output Token: b a b <bos> 0.67 0.00 0.33 0.60 0.20 0.19 0.60 0.20 0.19 0.57 0.29 0.14 0.57 0.29 0.14 0.56 0.34 0.11 0.56 0.34 0.11 0.54 0.37 0.09 0.54 0.37 0.09 0.54 0.37 0.09 0.54 0.37 0.09 0.54 0.39 0.07 0.52 0.44 0.0…
Figure 77
Figure 77. Figure 77: MLP Input-Output for token: b (sorted by logits) Output Token: EOS 92 [PITH_FULL_IMAGE:figures/full_fig_p092_77.png]
Figure 78
Figure 78. Figure 78: MLP Input-Output for token: EOS (sorted by logits) K.3. Dyck-4 Task Description: ⟨bos⟩ (a(a(a(ab) ∗ b) ∗ b) ∗ b) ∗ ⟨eos⟩ Architecture: Layers: 1 Heads: 2 Hidden Dim: 256 LR: 0.0001 Dropout: 0 Performance (w/Pruning → w/Primitives): Task Accuracy: 1.00 → 1.00; Match Ac…
Figure 79
Figure 79. Figure 79: Variables Heatmaps for Dyck-4 model on an example input. (b) shows the logits1 generated by the elementwise operation: “a” is allowed as long as the depth doesn’t exceed 4; “EOS” is allowed at the beginning and end (as the string is balanced there); “b” is allowed exc…
Figure 80
Figure 80. Figure 80: MLP Input-Output for token: a (sorted by logits). A condensed version (with just the output signs, and all three output dimensions together) is shown in [PITH_FULL_IMAGE:figures/full_fig_p094_80.png]
Figure 81
Figure 81. Figure 81: MLP Input-Output for token: b (sorted by logits). A condensed version (with just the output signs, and all three output dimensions together) is shown in [PITH_FULL_IMAGE:figures/full_fig_p094_81.png]
Figure 82
Figure 82. Figure 82: MLP Input-Output for token: EOS (sorted by logits). A condensed version (with just the output signs, and all three output dimensions together) is shown in [PITH_FULL_IMAGE:figures/full_fig_p095_82.png]
Figure 83
Figure 83. Figure 83: Heatmaps supporting the program for aastar model. <bos> a a a a <eos> 0.50 0.25 0.00 0.25 0.50 0 5000 10000 (a) Line 1: s1 <bos> a a a a <eos> a <bos> <sep> <eos> <pad> 10 5 0 5 (b) Line 4: logits1 <bos> a a a a <eos> 0 20 40 60 80 100 120 140 0.0 0.2 0.4 0.6 0.8 1.0 …
Figure 84
Figure 84. Figure 84: Variables Heatmaps for aastar model on an example input. 96 [PITH_FULL_IMAGE:figures/full_fig_p096_84.png]
Figure 85
Figure 85. Figure 85: Heatmaps supporting the program for abcde model. <bos> a b c d d d d e <eos> a b c d e <bos> <sep> <eos> <pad> 10 5 0 5 (a) Line 1: logits1 [PITH_FULL_IMAGE:figures/full_fig_p097_85.png]
Figure 86
Figure 86. Figure 86: Variables Heatmaps for abcde model on an example input. K.6. ab d bc Task Description: ⟨bos⟩ {a, b} ∗ d{b, c} ∗ ⟨eos⟩ Architecture: Layers: 1 Heads: 1 Hidden Dim: 16 LR: 0.001 Dropout: 0.1 Performance (w/Pruning → w/Primitives): Task Accuracy: 1.00 → 1.00; Match Accur…
Figure 87
Figure 87. Figure 87: Heatmaps supporting the program for ab d bc model. 98 [PITH_FULL_IMAGE:figures/full_fig_p098_87.png]
Figure 88
Figure 88. Figure 88: Variables Heatmaps for ab d bc model on an example input. K.7. tomita1 Task Description: ⟨bos⟩ 1 ∗ ⟨eos⟩ Architecture: Layers: 1 Heads: 1 Hidden Dim: 16 LR: 0.001 Dropout: 0 Performance (w/Pruning → w/Primitives): Task Accuracy: 1.0 → 1.0; Match Accuracy: 1.0 → 1.0 Co…
Figure 89
Figure 89. Figure 89: Heatmaps supporting the program for tomita2 model. <bos> 1 0 1 0 <eos> 0 1 <bos> <sep> <eos> <pad> 5 0 5 (a) Line 1: logits1 [PITH_FULL_IMAGE:figures/full_fig_p100_89.png]
Figure 90
Figure 90. Figure 90: Variables Heatmaps for tomita2 model on an example input. K.9. tomita7 Task Description: ⟨bos⟩ 0 ∗ 1 ∗ 0 ∗ 1 ∗ ⟨eos⟩ Architecture: Layers: 2 Heads: 1 Hidden Dim: 16 LR: 0.001 Dropout: 0.1 Performance (w/Pruning → w/Primitives): Task Accuracy: 1.00 → 0.98; Match Accura…
Figure 91
Figure 91. Figure 91: Heatmaps supporting the program for tomita7 model. <bos> 0 0 1 0 0 0 1 1 <eos> <bos> 0 0 1 0 0 0 1 1 <eos> 50 0 50 (a) Line 1: s1 <bos> 0 0 1 0 0 0 1 1 <eos> 0 1 <bos> <sep> <eos> <pad> 0.0 0.2 0.4 0.6 0.8 1.0 (b) Line 2: a1 <bos> 0 0 1 0 0 0 1 1 <eos> <bos> 0 0 1 0 0…
Figure 92
Figure 92. Figure 92: Variables Heatmaps for tomita7 model on an example input. 101 [PITH_FULL_IMAGE:figures/full_fig_p101_92.png]

Discussion (0). Continue with ORCID to comment.

Reference graph

Works this paper leans on

176 extracted references · 1 canonical work pages

  1. [1]

    For eachx∈start,⟨x,⟨⟩⟩ ∈ V

  2. [2]

    For anyl∈[L], h∈[H], wheneverlayer(⟨x, p⟩)< land⟨x, p⟩ ∈ V, then⟨x,⟨(l, h)⟩ ⊕p⟩ ∈ V. where 3.layer(⟨tok, p⟩) :=layer(p) 4.layer(⟨pos, p⟩) :=layer(p) 5.layer(⟨mlp k, p⟩) := max(k, layer(p)) 14 Interpretable Algorithms by Decompiling Transformers In particular, eachv∈ Vis a tuple consisting ofx∈startand a pathp. For each⟨i, p⟩ ∈ V, our D-RASP program will h...

  3. [5]

    Haklay, T., Orgad, H., Bau, D., Mueller, A., and Belinkov, Y

    URL https://openreview.net/forum? id=Pe9WxkN8Ff. Haklay, T., Orgad, H., Bau, D., Mueller, A., and Belinkov, Y . Position-aware automatic circuit discovery. In Che, W., Nabende, J., Shutova, E., and Pilehvar, M. T. (eds.),Pro- ceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2792–2817, Vienna...

  4. [6]

    URL https: //aclanthology.org/2025.acl-long.141/

    doi: 10.18653/v1/2025.acl-long.141. URL https: //aclanthology.org/2025.acl-long.141/. Hanna, M., Liu, O., and Variengien, A. How does gpt-2 compute greater-than?: Interpreting mathematical abili- ties in a pre-trained language model.Advances in Neu- ral Information Processing Systems, 36:76033–76060, 9 Interpretable Algorithms by Decompiling Transformers

  5. [7]

    Huang, X., Yang, A., Bhattamishra, S., Sarrof, Y ., Krebs, A., Zhou, H., Nakkiran, P., and Hahn, M

    URL https://openreview.net/forum? id=p4PckNQR8k. Huang, X., Yang, A., Bhattamishra, S., Sarrof, Y ., Krebs, A., Zhou, H., Nakkiran, P., and Hahn, M. A formal framework for understanding length generalization in transformers. InThe Thirteenth International Conference on Learning Representations, 2025. URL https:// openreview.net/forum?id=U49N5V51rU. Izzo, ...

  6. [9]

    Langosco, L., Baker, W., Alex, N., Bradley, H., Quarel, D., and Krueger, D

    URL https://openreview.net/forum? id=W8K8slZ73R. Langosco, L., Baker, W., Alex, N., Bradley, H., Quarel, D., and Krueger, D. Towards meta-models for automated interpretability, 2024. URL https://openreview. net/forum?id=1zDOkoZAtl. Li, J. and Cotterell, R. Characterizing the expressivity of fixed-precision transformer language models. In The Thirty-ninth ...

  7. [10]

    Liu, B., Ash, J., Goel, S., Krishnamurthy, A., and Zhang, C

    URL https://openreview.net/forum? id=tbbId8u7nP. Liu, B., Ash, J., Goel, S., Krishnamurthy, A., and Zhang, C. Exposing attention glitches with flip-flop language modeling.Advances in Neural Information Process- ing Systems, 36:25549–25583, 2023. URL https: //openreview.net/forum?id=VzmpXQAn6E. Merrill, W. and Sabharwal, A. A logic for express- ing log-pre...

  8. [11]

    nostalgebraist

    URL https://openreview.net/forum? id=uR8TtWCIsr. nostalgebraist. interpreting gpt: the logit lens.LESS- WRONG, 2020. https://www.lesswrong. com/posts/AcKRB8wDpdaN6v6ru/ interpreting-gpt-the-logit-lens. Olsson, C., Elhage, N., Nanda, N., Joseph, N., Das- Sarma, N., Henighan, T., Mann, B., Askell, A., Bai, Y ., Chen, A., Conerly, T., Drain, D., Ganguli, D.,...

Show all 176 references
  1. [12]

    tacl-1.9/

    URL https://aclanthology.org/2025. tacl-1.9/. Thurnherr, H. and Riesen, K.Neural Decompiling of Tracr Transformers, pp. 25–36. Springer Nature Switzer- land, 2024. ISBN 9783031716027. doi: 10.1007/ 978-3-031-71602-7 3. URL http://dx.doi.org/ 10.1007/978-3-031-71602-7_3. Wang, ...

  2. [13]

    Weiss, G., Goldberg, Y ., and Yahav, E

    URL https://openreview.net/forum? id=NpsVSN6o4ul. Weiss, G., Goldberg, Y ., and Yahav, E. Thinking like transformers. InInternational Conference on Machine Learning, pp. 11080–11090. PMLR, 2021. URL http://proceedings.mlr.press/v139/ weiss21a.html. 10 Interpretable Algorithms ...

  3. [14]

    URL https://openreview.net/forum? id=OitmaxSAUu. Yang, A. and Chiang, D. Counting like transformers: Compiling temporal counting logic into softmax trans- formers. InFirst Conference on Language Modeling,

  4. [15]

    Yang, A., Chiang, D., and Angluin, D

    URL https://openreview.net/forum? id=FmhPg4UJ9K. Yang, A., Chiang, D., and Angluin, D. Masked hard- attention transformers recognize exactly the star-free languages.Advances in Neural Information Process- ing Systems, 37:10202–10235, 2024. URL https: //openreview.net/forum?id=...

  5. [16]

    logits5 = project(inp=a1, op= g )

  6. [17]

    How does D-RASP compare to Transformer Programs (Friedman et al., 2023; Lai-Dang et al., 2025) and the Discrete Transformer (Zhang et al., 2026)? On a technical level, there are some similarities; in particular, our definition of separate variables for each path through the re...

  7. [18]

    logits7 = project(inp=is_01_balance_a3, op= i )

  8. [19]

    logits8 = project(inp=pos, op= m )

  9. [25]

    a2 = aggregate(s=s1+s2+s3+s4, v=pos) Defining elementwise operationsWe set Line performing per-position operation v⟨mlpl,⟨⟩⟩ =element wise op(vs(i) :s∈ V − {vmlp,l}, layer(s)≤l,func=f) wherefoutputs the output vector of the original MLPf M LP,lof thel-th layer: f v(s,p)(i) : (...

  10. [26]

    m = element_wise_op(token+pos+a1+a2) Treating Unembedding MatricesWe define the unembedding projections as R⟨i,p⟩ =U   Y ⟨l′,h′⟩∈p Vh′,l′   T(i)(13) for each⟨i, p⟩withlayer(p)≤L, and set 16 Interpretable Algorithms by Decompiling Transformers Line performing per-position o...

  11. [32]

    Line defining a selector

    prediction = softmax(logits1+logits2+logits3+logits4+logits5) B.4. Proof of Theorem 3.2 Theorem B.2(Restated from Theorem 3.2).Consider a GPT-2-style transformer satisfying LLNA. There is a D-RASP program defining the same input-output map; it can be explicitly obtained from t...

  12. [37]

    a1 = aggregate(s=s1+s2+s3+s4, v=token)

  13. [45]

    prediction = softmax(logits1+logits2+logits3+logits4+logits5) After pruning:

  14. [46]

    s1 = select(q=token, k=token)

  15. [47]

    s2 = select(q=token, k=pos)

  16. [48]

    s3 = select(q=pos, k=token)

  17. [49]

    s4 = select(q=pos, k=pos)

  18. [50]

    a1 = aggregate(s=s1 +s2+s3+s4, v=token)

  19. [51]

    a2 = aggregate(s=s1+s2+s3+s4, v=pos)

  20. [52]

    m = elementwise_op(token+pos+a1+a2)

  21. [53]

    logits1 = project(token)

  22. [54]

    logits2 = project(pos)

  23. [55]

    logits3 = project(a1)

  24. [56]

    logits4 = project(a2)

  25. [57]

    logits5 = project(m)

  26. [58]

    define the same functions

    prediction = softmax( logits1+logits2+logits3+logits4+logits5) Figure 9.See text. B.6. Size of D-RASP Translation The size of the D-RASP translation given by Theorem 3.2 is given by: def determine_total_line(num_layer, num_head, split_mlps): num_v = 2 num_line = 0 for i in ran...

  27. [59]

    We can see that very different architectures can all be decompilable (e.g., two green lines in Figure 10(a) correspond to 4 layer vs

    For each task, we show 2-3 models different architectures. We can see that very different architectures can all be decompilable (e.g., two green lines in Figure 10(a) correspond to 4 layer vs. 2 layer models), while similar architectures can exhibit different decompilability (...

  28. [60]

    Columns of v is the result of per-column operation of x, i.e., v(i) only depends on x(i)

    Collect output activations v∈R d×N (see method in Appendix F.2) of the target MLP (which is also activation variables before finding a primitive), and activation variables x∈R d(x)×N (see method in Appendix G.1) of its inputs. Columns of v is the result of per-column operation...

  29. [61]

    Test primitives. For each primitivef j in the single input primitive list, do the following: (a) Obtain the transformed activation variables w∈R d(w)×N by applying fj to x (i.e., w(i) = element wise op(x(i),func=f s)).d(w)depends on the output dimension off j. (b) Obtain a lin...

  30. [62]

    Importantly, to simplify the generated program, we favor replacing MLP with linear operation, i.e., fno−op

    Select the best primitive. Importantly, to simplify the generated program, we favor replacing MLP with linear operation, i.e., fno−op. We first try fno−op, if match accuracy is above a threshold then we match fno−op with the MLP and skip all other primitives. In our experiment...

  31. [63]

    In this case, we store the variables and visualize them so that one can still interpret the MLP manually (Section G.4)

    However, if all primitives fail to match original model’s output — that is, the match accuracy of all primitives is lower than a threshold (we use 0.9) — we conclude that no primitive in our library matches the MLP. In this case, we store the variables and visualize them so th...

  32. [64]

    , xs, we collect them all

    There are multiple input activation variables,x 1, . . . , xs, we collect them all

  33. [65]

    , xs,func=f i), and is from a different list (see below)

    The tested fi operates over multiple inputs w=element wise op(x1, . . . , xs,func=f i), and is from a different list (see below). Library of Multiple-input primitives 1.f keep−i(x(1), . . . , x(i), . . . , x(s)) :=x (i), where hyperparameter i∈ {1, . . . , s}, x(i) is a vector...

  34. [66]

    Collect its input activation variable samples vinp and corresponding output of this MLP vout

    Given a path containing unexplained MLP (i.e., MLP not replaced with a primitive from the library) and ending with unembedding in the pruned graph, we first identify the first unexplained MLP in the path (in earliest layer). Collect its input activation variable samples vinp a...

  35. [67]

    Formally, we iterate over downstream components afterwards on the path

    We absorb all matrices acting on the MLP output throughout the downstream path into the MLP output. Formally, we iterate over downstream components afterwards on the path. For each attention head in the path, we update it 35 Interpretable Algorithms by Decompiling Transformers...

  36. [68]

    We replace the original project operation by project(vout, I|Σ|×|Σ|), that is, the project operation uses the identity matrix

    In terms of the D-RASP program, we add a per-position operation mapping vinp to an output of dimension d(vout) = |Σ|. We replace the original project operation by project(vout, I|Σ|×|Σ|), that is, the project operation uses the identity matrix

  37. [69]

    We emphasize the token promoted most

    To aid interpretation, we subtract each column of vout with its second largest value, since this is equivalent under softmax. We emphasize the token promoted most. When using BCE loss, we do not do this. ExampleFor example, in the pruned model, if an unexplained MLP is in a pa...

  38. [70]

    Collect its input activation variable samplesv (q) inp and corresponding output of this MLPv (q) out

    Given a QK product whose query or key contains at least one unexplained MLP in the pruned graph, we first identify the first unexplained MLP in the path (in earliest layer) for both query and key. Collect its input activation variable samplesv (q) inp and corresponding output ...

  39. [71]

    When only one of query and key contains unexplained MLP, we apply the method in Appendix G.1 for the other to get these two variables easily

    Similar to previous method, we iterate over downstream components afterwards on the path to get final v(q) out and v(k) out. When only one of query and key contains unexplained MLP, we apply the method in Appendix G.1 for the other to get these two variables easily

  40. [72]

    Each entry in this matrix describes how each pair of columns in v(k) inp and v(q) inp is associated

    We do (v(q) out)T ·Q T l,h ·K l,h ·v (k) out. Each entry in this matrix describes how each pair of columns in v(k) inp and v(q) inp is associated. So We make vout interpretable by tracing downstream effect on attention. In other words, we inspect what are the input variable pa...

  41. [73]

    36 Interpretable Algorithms by Decompiling Transformers

    In terms of the D-RASP program, we add a per-position operation mapping to this output, and replace the select operation by one where theAmatrix is the identity matrix. 36 Interpretable Algorithms by Decompiling Transformers

  42. [74]

    side-effect

    To aid interpretation, we center the products of the same query, since this is equivalent under softmax. Moreover, we apply K-means clustering to query’s activation variables, and show what are the keys associated with each “type” (cluster) of query. G.5. Remark on Logit Lens ...

  43. [77]

    a1 holds counts of the relative frequencies of 0, 1, BOS, SEP (Figure 17a)

    prediction = softmax(logits1) InterpretationThe program is essentially equivalent to the program shown for the non-binary version in Figure 1 of the main paper. a1 holds counts of the relative frequencies of 0, 1, BOS, SEP (Figure 17a). Line 2 then projects the counts of 0, 1 ...

  44. [81]

    s3 = select(q=pos, k=pos, op= c ) # layer 0 head 1

  45. [82]

    a2 = aggregate(s=s3, v=token) # layer 0 head 1

  46. [83]

    s4 = select(q=pos, k=token, op= j ) # layer 1 head 0

  47. [84]

    s5 = select(q=pos, k=pos, op=(k==q-2)) # layer 1 head 0

  48. [85]

    a3 = aggregate(s=s4+s5, v=token) # layer 1 head 0

  49. [86]

    a4 = aggregate(s=s4+s5, v=pos) # layer 1 head 0

  50. [87]

    is_pure_token = is_pure(token) # layer 1 mlp

  51. [88]

    is_01_balance_a3 = is_01_balance(a3) # layer 1 mlp

  52. [89]

    logits1 = project(inp=a4, op= k )

  53. [90]

    logits2 = project(inp=token, op= e ) 42 Interpretable Algorithms by Decompiling Transformers

  54. [91]

    logits3 = project(inp=pos, op= l )

  55. [92]

    logits4 = project(inp=is_pure_token, op= f )

  56. [94]

    logits6 = project(inp=a2, op= h )

  57. [97]

    prediction = softmax(logits1+ logits2+ logits3+ logits4+ logits5+ logits6+ logits7+ logits8) InterpretationIn this task, the model is tasked with solving three binary majority tasks in succession, with the three input strings presented in interleaved order. The main algorithm ...

  58. [99]

    s2 = select(q=pos, k=pos, op=(k%3==q%3==0)) # layer 0 head 0

  59. [104]

    Line 1 defines a selector ensuring that, at SEP, attention specifically goes to the non-special tokens (Figure 21a)

    prediction = softmax(logits1+ logits2) InterpretationIn this task, the model is tasked with solving three binary majority tasks in succession, with the three input strinfs presented in interleaved order. Line 1 defines a selector ensuring that, at SEP, attention specifically g...

  60. [107]

    s2 = select(q=token, k=token, op= b ) # layer 0 head 1

  61. [108]

    s3 = select(k=token, op= c )

  62. [109]

    a2 = aggregate(s=s2+s3, v=token) # layer 0 head 1

  63. [110]

    new_a2 = element_wise_op(a2) # layer 0 mlp

  64. [111]

    logits1 = project(inp=token, op= d )

  65. [112]

    logits2 = project(inp=a1, op= e )

  66. [113]

    logits3 = project(inp=new_a2, op=(inp==out))

  67. [114]

    So each number would attend to the previous largest number, which the terminating number

    prediction = softmax(logits1+ logits2+ logits3) InterpretationLine 1 defines a selector favoring weight to numbers larger than the present one. So each number would attend to the previous largest number, which the terminating number. In contrast, we also notice this pattern is...

  68. [115]

    s1 = select(q=token, k=token, op=(uniform selection), special op=(k is last)) # layer 0 head 2

  69. [116]

    a1 = aggregate(s=s1, v=token) # layer 0 head 2

  70. [118]

    s2 = select(q=token, k=token, op=(k==q), special op=(uniform selection)) # layer 1 head 3

  71. [119]

    s3 = select(q=token, k=new_a1, op=(q==k)) # layer 1 head 3

  72. [120]

    a2 = aggregate(s=s2+s3, v=new_a1) # layer 1 head 3

  73. [121]

    logits1 = project(inp=a2, op=(inp==out))

  74. [122]

    logits2 = project(inp=token, op= c )

  75. [123]

    logits3 = project(inp=new_a1, op=(inp==out))

  76. [124]

    logits4 = project(inp=token, op= d )

  77. [125]

    In line 1, SEP attends to the smallest number, which is the starting number

    prediction = softmax(logits1+ logits2+ logits3+ logits4) InterpretationThis program uses a similar strategy to the other version, but with a few differences. In line 1, SEP attends to the smallest number, which is the starting number. Line 1, 2, 3, and 9 forms the mechanism to...

  78. [126]

    a1 = aggregate(s=[], v=token) # layer 0 head 1

  79. [128]

    prediction = softmax(logits1) InterpretationThis program is interpreted in Main Paper, Figure 1. a b c d e f g h i j k l mn o p q r s t u v w x y z <bos><sep><eos><pad> a b c d e f g h i j k l m n o p q r s t u v w x y z <bos> <sep> <eos> <pad> 0 2000 4000 6000 8000 10000 (a) ...

  80. [130]

    logits1 = project(inp=a1, op=(inp==out), special op=(uniform selection))

  81. [131]

    prediction = softmax(logits1) InterpretationThe program is essentially the same as in App. J.6. 63 Interpretable Algorithms by Decompiling Transformers a b c d e f g h i j k l mn o p q r s t u v w x y z <bos><sep><eos><pad> a b c d e f g h i j k l m n o p q r s t u v w x y z <...

  82. [133]

    a1 = aggregate(s=s1, v=token) # layer 0 head 0 64 Interpretable Algorithms by Decompiling Transformers

  83. [136]

    Line 1 assigns weight to input numbers that are a little larger than the current token

    prediction = softmax(logits1) InterpretationThis is discussed in Main paper, Figure 5. Line 1 assigns weight to input numbers that are a little larger than the current token. Line 2 then creates a histogram of larger numbers, with the biggest weight given to the smallest one. ...

  84. [138]

    a1 = aggregate(s=s1, v=token) # layer 0 head 0 68 Interpretable Algorithms by Decompiling Transformers

  85. [141]

    token_x_a1_x_a2 = Cartesian_product(token, a1, a2) # layer 0 mlp

  86. [142]

    s3 = select(q=token_x_a1_x_a2, k=token_x_a1_x_a2, op= c ) # layer 1 head 2

  87. [143]

    a3 = aggregate(s=s3, v=token_x_a1_x_a2) # layer 1 head 2

  88. [144]

    logits1 = project(inp=a3, op= d )

  89. [145]

    Lines 1–4 retrieve the two preceding symbols; Line 5 creates a joint (nonlinear) representation of the trigram ending with the current symbol

    prediction = softmax(logits1) InterpretationThis is an extension of the induction head program discussed in Main Paper Figure 3; it crucially involves a joint nonlinear representation of trigrams. Lines 1–4 retrieve the two preceding symbols; Line 5 creates a joint (nonlinear)...

  90. [146]

    s1 = select(q=pos, k=pos, op= a ) # layer 0 head 1

  91. [147]

    a1 = aggregate(s=s1, v=token) # layer 0 head 1

  92. [148]

    s2 = select(q=pos, k=pos, op=(k==q-1)) # layer 0 head 2

  93. [149]

    a2 = aggregate(s=s2, v=token) # layer 0 head 2

  94. [150]

    s3 = select(q=token, k=a2, op=(k==q), special op=(k==BOS)) # layer 1 head 1

  95. [151]

    s4 = select(q=a2, k=a1, op= d ) # layer 1 head 1

  96. [152]

    a3 = aggregate(s=s3+s4, v=token) # layer 1 head 1

  97. [153]

    logits1 = project(inp=a3, op= e )

  98. [154]

    Similar to the previous Unique Bigram program, the model takes the previous previous token t−2 (s1 and a1), and the previous token t−1 (s2 and a2)

    prediction = softmax(logits1) InterpretationThis is a different extension of the induction head program discussed in Main Paper, Figure 3; it relies only on select and aggregate operations. Similar to the previous Unique Bigram program, the model takes the previous previous to...

  99. [155]

    s1 = select(q=pos, k=pos, op=(k==q-1)) # layer 0 head 0

  100. [157]

    s2 = select(q=token, k=a1, op=(k==q), special op=(k==BOS)) # layer 1 head 0

  101. [158]

    a2 = aggregate(s=s2, v=token) # layer 1 head 0

  102. [159]

    logits1 = project(inp=a2, op=(inp==out), special op=(uniform selection))

  103. [161]

    prediction = softmax(logits1+ logits2) InterpretationThis is discussed in Main paper, Figure 3. 72 Interpretable Algorithms by Decompiling Transformers 0 50 100 150 200 250 300 0 50 100 150 200 250 300 0 2000 4000 6000 8000 10000 (a) Line 1: op=(k==q-1) 01234567891011121314151...

  104. [163]

    s2 = select(q=pos, k=pos, op= b ) # layer 0 head 0

  105. [164]

    s3 = select(k=token, op= d )

  106. [165]

    s4 = select(k=pos, op= e )

  107. [166]

    a1 = aggregate(s=s1+s2+s3+s4, v=token) # layer 0 head 0

  108. [167]

    s5 = select(q=token, k=token, op=(k==q), special op=(k==SEP)) # layer 1 head 0

  109. [168]

    a2 = aggregate(s=s5, v=a1) # layer 1 head 0

  110. [169]

    logits1 = project(inp=a2, op= f )

  111. [170]

    (Figure 58a)

    prediction = softmax(logits1) InterpretationLine 1 defines a selector that assigns increased weight to SEP, with strength varying with the query. (Figure 58a). Line 2 defines a selector assigning increased weight to the immediately preceding position (Figure 58b). Line 3 defin...

  112. [171]

    s1 = select(q=pos, k=pos, op= a ) # layer 0 head 0

  113. [172]

    s2 = select(k=token, op= d )

  114. [173]

    a1 = aggregate(s=s1+s2, v=token) # layer 0 head 0

  115. [174]

    s3 = select(q=token, k=token, op=(k==q), special op=(uniform selection)) # layer 2 head 0

  116. [175]

    s4 = select(q=token, k=a1, op= c ) # layer 2 head 0

  117. [176]

    a2 = aggregate(s=s3+s4, v=a1) # layer 2 head 0

  118. [177]

    new_a2 = element_wise_op(a2) # layer 3 mlp

  119. [178]

    logits1 = project(inp=new_a2, op=(inp==out))

  120. [179]

    s1 defines a selector that looks at the previous token in the input string, and s2 puts increased attention on SEP (Figure 60a,d)

    prediction = softmax(logits1) InterpretationComparing the activations in Figure 61 with those of the other program on the same task (Figure 59) shows some commonalities, and indeed the algorithm is similar. s1 defines a selector that looks at the previous token in the input st...

  121. [181]

    a2 = aggregate(s=[], v=pos) # layer 0 head 0

  122. [182]

    s1 = select(q=token, k=token, op= a ) # layer 0 head 1

  123. [183]

    s2 = select(q=pos, k=token, op= c ) # layer 0 head 1

  124. [184]

    s3 = select(k=token, op= b )

  125. [185]

    a3 = aggregate(s=s1+s2+s3, v=token) # layer 0 head 1

  126. [186]

    a4 = aggregate(s=s1+s2+s3, v=pos) # layer 0 head 1

  127. [188]

    new_a3 = element_wise_op(a3) # layer 0 mlp

  128. [190]

    logits2 = project(inp=a2, op= d )

  129. [191]

    logits3 = project(inp=new_a3, op=(inp==out))

  130. [192]

    logits4 = project(inp=a4, op= e )

  131. [193]

    imperfections

    prediction = sigmoid(logits1+ logits2+ logits3+ logits4) InterpretationThis program is a more complex version of the D4 program discussed in the main paper Figure 8. Similar to Figure 8, a1 aggregates all the tokens in the input string, and then feeds into the MLP in Line 8, w...

  132. [197]

    logits1 = project(inp=token, op= b )

  133. [198]

    logits2 = project(inp=a1, op= c )

  134. [199]

    logits3 = project(inp=token, op= d )

  135. [200]

    logits4 = project(inp=new_a1, op=(inp==out))

  136. [201]

    logits5 = project(op= e )

  137. [202]

    a” and “b

    prediction = sigmoid(logits1+ logits2+ logits3+ 89 Interpretable Algorithms by Decompiling Transformers logits4+ logits5) InterpretationThis program is a more complex version of the D4 program discussed in Figure 8 the main paper. Of note, the selector in Line 1 assigns unequa...

  138. [203]

    a1 = aggregate(s=[], v=token) # layer 0 head 0

  139. [204]

    new_a1 = element_wise_op(a1) # layer 0 mlp

  140. [205]

    logits1 = project(inp=new_a1, op=(inp==out))

  141. [206]

    a” is allowed as long as the depth doesn’t exceed 4; “EOS

    prediction = sigmoid(logits1) InterpretationThis program is discussed in the main paper, Figure 8. We provide further examples of the elementwise operation below. <bos> a a a a b b b b <eos> a b <bos> <sep> <eos> <pad> 0.0 0.2 0.4 0.6 0.8 1.0 (a) Line 1: a1 <bos> a a a a b b b...

  142. [207]

    s1 = select(k=token, op=(k==BOS))

  143. [208]

    a1 = aggregate(s=s1, v=pos) # layer 0 head 1

  144. [209]

    m1 = element_wise_op(pos+a1) # layer 0 mlp

  145. [210]

    logits1 = project(inp=m1, op=(inp==out))

  146. [211]

    Line 3 now jointly processes the current position with the position of BOS in an elementwise operation

    prediction = sigmoid(logits1) InterpretationLines 1–2 retrieve the position of BOS (note that, while the position is 0 in this example, this does not generally hold due to the use of random offsets in positional encoding during training). Line 3 now jointly processes the curre...

  147. [213]

    a b c d e <bos><sep><eos><pad> a b c d e <bos> <sep> <eos> <pad> 10 5 0 5 (a) Line 1: op= a in logits1 Figure 85.Heatmaps supporting the program for abcde model

    prediction = sigmoid(logits1) InterpretationThis program is discussed in the main paper. a b c d e <bos><sep><eos><pad> a b c d e <bos> <sep> <eos> <pad> 10 5 0 5 (a) Line 1: op= a in logits1 Figure 85.Heatmaps supporting the program for abcde model. <bos> a b c d d d d e <eos...

  148. [214]

    s1 = select(k=token, op= b )

  149. [215]

    a1 = aggregate(s=s1, v=token) # layer 0 head 0 97 Interpretable Algorithms by Decompiling Transformers

  150. [216]

    logits1 = project(inp=a1, op= a )

  151. [217]

    logits2 = project(op= c )

  152. [218]

    d” has occurred so far: if it hasn’t, {a, b, d}are valid; if it has, {b, c, EOS}are valid. Indeed, lines 1–2 encode this information by assigning weight to “d

    prediction = sigmoid(logits1+ logits2) InterpretationEssentially, the model needs to check if “d” has occurred so far: if it hasn’t, {a, b, d}are valid; if it has, {b, c, EOS}are valid. Indeed, lines 1–2 encode this information by assigning weight to “d” if it has occurred. Li...

  153. [219]

    prediction = sigmoid(bias) K.8. tomita2 Task Description: ⟨bos⟩(10) ∗ ⟨eos⟩ Architecture:Layers: 1 Heads: 1 Hidden Dim: 16 LR: 0.001 Dropout: 0 Performance (w/Pruning→w/Primitives):Task Accuracy:1.00→1.00; Match Accuracy:1.00→1.00 Code

  154. [220]

    logits1 = project(inp=token, op= a )

  155. [221]

    prediction = sigmoid(logits1) InterpretationThis program straightforwardly describes next-token expectations in terms of the current token: BOS is followed by 1 or EOS; 1 is followed by 0; 0 is followed by 1 or EOS. 99 Interpretable Algorithms by Decompiling Transformers 0 1 <...

  156. [222]

    s1 = select(q=token, k=token, op= a ) # layer 0 head 0

  157. [223]

    a1 = aggregate(s=s1, v=token) # layer 0 head 0

  158. [224]

    s2 = select(q=token, k=a1, op=(k==q), special op=(uniform selection)) # layer 1 head 0

  159. [225]

    a2 = aggregate(s=s2, v=a1) # layer 1 head 0

  160. [226]

    logits1 = project(inp=a2, op= c )

  161. [227]

    logits2 = project(op= d )

  162. [228]

    In s1 (Figure 91a) q=0 pays attention to 1’s and q=1 to 0’s, and thus a1 (Figure 92b) holds the count of 0’s (for q=1) and 1’s (for q=0) before the current token

    prediction = sigmoid(logits1+ logits2) InterpretationThe model essentially prohibits generating a 0 if a 1∗0∗1∗ subsequence is detected in Lines 1-4. In s1 (Figure 91a) q=0 pays attention to 1’s and q=1 to 0’s, and thus a1 (Figure 92b) holds the count of 0’s (for q=1) and 1’s ...

  163. [2020]

    emnlp-main.576/

    URL https://aclanthology.org/2020. emnlp-main.576/. Butoi, A., Khalighinejad, G., Svete, A., Valvoda, J., Cot- terell, R., and DuSell, B. Training neural networks as recognizers of formal languages. InThe Thirteenth Inter- national Conference on Learning Representations, Sin- ...

  164. [2021]

    Most Frequent

    URL https://aclanthology.org/2021. acl-long.292/. Yin, K. and Steinhardt, J. Which attention heads matter for in-context learning? InForty-second International Conference on Machine Learning, 2025. URL https: //openreview.net/forum?id=C7XmEByCFv. Zhang, Y ., Bi, W., Zhang, K.,...

  165. [2022]

    acl-long.527/

    URL https://aclanthology.org/2022. acl-long.527/. Conmy, A., Mavor-Parker, A., Lynch, A., Heimersheim, S., and Garriga-Alonso, A. Towards automated circuit discovery for mechanistic interpretability.Advances in Neural Information Processing Systems, 36:16318– 16352, 2023. URL ...

  166. [2023]

    io/Inverse_Tracr.pdf

    URL https://william-baker.github. io/Inverse_Tracr.pdf. Baroni, L., Khara, G., Schaeffer, J., Subkhankulov, M., and Heimersheim, S. Transformers don’t need LayerNorm at inference time: Scaling LayerNorm removal to GPT-2 XL and the implications for mechanistic interpretability....

  167. [2024]

    Bhattamishra, S., Ahuja, K., and Goyal, N

    URL https://openreview.net/forum? id=8oSY3rA9jY. Bhattamishra, S., Ahuja, K., and Goyal, N. On the ability and limitations of transformers to rec- ognize formal languages. InProceedings of the 2020 Conference on Empirical Methods in Natu- ral Language Processing (EMNLP), pp. 7...

  168. [2025]

    Lai-Dang, Q.-V ., Kang, T., and Son, S

    URL https://openreview.net/forum? id=Huw15LqglI. Lai-Dang, Q.-V ., Kang, T., and Son, S. Adaptive trans- former programs: Bridging the gap between performance and interpretability in transformers. InThe Thirteenth International Conference on Learning Representations,

Pith tools

Reviewed August 3, 2026 · model on record in the stance chip above.