TL;DR
What if you could crack open a black-box Transformer and translate its dense matrix multiplications directly into crisp, human-readable logical rules? By exploiting a deep theoretical connection between Transformer layers and temporal logic, the authors introduce a layer-by-layer distillation algorithm that turns trained sequence models into stacks of logical decision trees. They use this to extract succinct, biologically meaningful rules directly from a protein language model with minimal loss in accuracy.
What Problem Does This Paper Address?
Transformers are brilliant at finding patterns in sequences—whether words in a sentence or amino acids in a protein—but they are notoriously opaque. When a biological language model flags a peptide as toxic, a scientist doesn't just want a high-dimensional activation vector; they want to know the rule driving that classification.
Existing mechanistic interpretability tools, like sparse autoencoders, are great at isolating individual "concepts" (sparse features) inside a network's activations. However, they struggle to show compositionality—how those features interact and depend on order across a sequence. Rather than reverse-engineering individual neurons, the authors ask: can we distill the entire Transformer encoder into an explicit, readable symbolic formula that captures sequence-wide patterns?
Methods
The magic here bridges formal logic and machine learning. Recent theoretical work proved that hard-attention Transformer encoders have the exact expressive power of Linear Temporal Logic (LTL)—a formal language for describing sequence order using operators like Next ($X$, meaning "true at the very next step") and Until ($U$, meaning "this stays true until that becomes true"). Crucially, theory shows a tight hierarchy: each layer in a Transformer adds at most one unit of temporal nesting depth.
Guided by this, the authors introduce a novel symbolic surrogate model called the Iterated Temporal Decision Tree (ITDT), paired with a layer-wise distillation algorithm:
- Temporal Decision Trees (TDTs): Standard decision trees, except the split conditions at internal nodes are LTL formulas evaluated at specific positions in a sequence. Each leaf naturally corresponds to a logical formula representing the path taken to reach it.
- Stacking and Temporal Expansion: An ITDT stacks $k$ trees to mirror a $k$-layer Transformer. After Tree $i$ is trained, its leaf formulas are harvested and "temporally expanded" (wrapped in $X$ and $U$ operators) to create deeper logical features for Tree $i+1$.
- Layer-wise Distillation: Instead of training the trees solely on the final label, Layer $i$ of the trained Transformer supervises Tree $i$ via standard multi-output regression—the tree learns splits that best approximate the Transformer's hidden token representations at that specific depth.
- Practical Tweaks: Because generating all possible logical combinations explodes combinatorially, the practical algorithm only expands the formulas actually discovered at the tree leaves. For real-world biology tasks, the authors also add Count features (tracking how often a motif occurs), skip regressing on the final Transformer layer to avoid over-compressed representations, and slap a simple linear threshold (ridge or Lasso regression) on top for the final sequence prediction.
Datasets
The authors do not introduce new benchmarks, instead testing on two established domains:
- Synthetic LTL Benchmarks: Nine standard formal-methods tasks covering existence, absence, and universality properties across synthetic string traces (lengths 10 to 100).
- Real-World Protein Classification: Four binary peptide classification datasets—CPP924 (cell-penetrating), ToxinPred 3.0 (toxicity), ACP740 (anticancer), and AMP Scanner V2 (antimicrobial)—used to fine-tune and distill the 8M-parameter ESM-2-T6 protein language model.
Key Insights and Ideas
- Theory works in soft-attention practice: The layer-by-layer LTL correspondence was proven for idealized hard-attention Transformers. Yet, using it as an inductive bias works remarkably well on standard, messy soft-attention Transformers.
- Intermediate Transformer states are superior teachers: When the authors replaced the Transformer's intermediate hidden states with random vectors or even the ground-truth labels broadcast across every layer, performance dropped. The Transformer's internal layer-wise representations genuinely guide the trees toward better intermediate concepts.
- Order matters, not just counts: Stripping away the temporal operators ($X$, $U$) and leaving only amino-acid counts caused accuracy to drop across every single protein benchmark, proving that sequential order and motif arrangement are vital to what the Transformer learned.
Key Results
- Near-perfect logic recovery: On all nine synthetic LTL benchmarks, ITDTs matched the teacher Transformer with near-perfect accuracy, recovering compact trees of depth 2 to 4 and temporal depth $\le 1$.
- High fidelity on proteins: Distilling ESM-2-T6 into ITDTs preserved almost all of the neural network's predictive power: 0.92 vs. 0.92 accuracy on CPP924, 0.84 vs. 0.86 on ACP740, 0.85 vs. 0.88 on ToxinPred 3.0, and 0.87 vs. 0.92 on AMP Scanner V2.
- Biochemical alignment: Using Lasso regression to extract the top sparse rules, the authors ran a blind "LLM-as-expert" test (via GPT-5.5), giving it only a distilled logical rule and asking which biological class it described. The evaluator guessed right 90.0% of the time on AMP, 76.7% on ToxinPred 3.0, and 70.0% on ACP740 and CPP924—showing the distilled rules align with real biochemical priors rather than arbitrary statistical quirks.
Limitations and Future Work
The main bottleneck is vocabulary scaling. Even with their restricted temporal expansion, the pool of candidate logical formulas grows quadratically with the number of formulas being expanded. While totally manageable for the 20-letter amino acid alphabet in proteins, scaling this current implementation to large-vocabulary domains like natural language (with tens of thousands of tokens) remains an open challenge. However, once an ITDT is distilled, evaluating its fixed LTL formulas scales linearly with sequence length—beating the quadratic self-attention cost of the original Transformer.
Summary updated