mlsanityData to 14 Oct 2026

Explaining Attention with Program Synthesis

arXiv 2606.19317 ↗First posted 17 Jun 2026cs.LG cs.AIcited by 1

Not on the map. Why?

Abstract (arXiv)

A longstanding goal of research on interpretable deep learning is to replace opaque neural computations with human-meaningful symbolic descriptions. In this paper, we propose an approach for approximating the behavior of components of deep networks with executable programs. We focus on attention heads in transformer language models. For a given head, we first compute its associated attention matrices on a collection of randomly selected training examples. Next, we prompt a pre-trained language model with a summary of these matrices, and instruct it to generate a set of Python programs that can reproduce the associated attention patterns given only text from the input sentence. Finally, we re-rank programs according to how well our final set of programs predict behavior on held-out inputs. We demonstrate that a set of fewer than 1,000 such generated programs can reproduce the attention patterns of heads in GPT-2, TinyLlama-1.1B, and Llama-3B, achieving an average Intersection-over-Union similarity above 75% on TinyStories. Moreover, the best-fit programs can replace neural attention heads without substantially affecting model behavior: replacing 25% of attention heads with programmatic surrogates across the three models incurs only a 16% average perplexity increase, while maintaining performance on a variety of downstream question answering benchmarks. This work contributes a scalable pipeline for reverse-engineering attention heads in transformer models using human-readable, executable code, advancing a path toward symbolic transparency in neural models.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 33 of its 42 references that are in the map. First posted on arXiv 17 Jun 2026.

Builds on

33 of 42 references.

References · 33

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2024The Llama 3 Herd of Modelscited by 14,715
  4. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  5. 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 4,886
  6. 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,100
  7. 2021Program Synthesis with Large Language Modelscited by 3,637
  8. 2019PIQA: Reasoning about Physical Commonsense in Natural Languagecited by 2,883
  9. 2013Visualizing and Understanding Convolutional Networkscited by 2,290
  10. 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,420
  11. 2019BERT Rediscovers the Classical NLP Pipelinecited by 1,059
  12. 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 1,003
21 more
  1. 2019Attention is not Explanationcited by 929
  2. 2019Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Prunedcited by 856
  3. 2023Progress measures for grokking via mechanistic interpretabilitycited by 839
  4. 2019Are Sixteen Heads Really Better than One?cited by 816
  5. 2017Crowdsourcing Multiple Choice Science Questionscited by 765
  6. 2017Network Dissection: Quantifying Interpretability of Deep Visual Representationscited by 708
  7. 2019Attention is not not Explanationcited by 636
  8. 2024TinyLlama: An Open-Source Small Language Modelcited by 618
  9. 2023TinyStories: How Small Can Language Models Be and Still Speak Coherent English?cited by 449
  10. 2015Illuminating search spaces by mapping elitescited by 425
  11. 2019A Multiscale Visualization of Attention in the Transformer Modelcited by 292
  12. 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 197
  13. 2021Thinking Like Transformerscited by 184
  14. 2020Compositional Explanations of Neuronscited by 172
  15. 2019The Bottom-up Evolution of Representations in the Transformer: A Study with Machine Translation and Language Modeling Objectivescited by 139
  16. 2022Natural Language Descriptions of Deep Visual Featurescited by 137
  17. 2018What Is One Grain of Sand in the Desert? Analyzing Individual Neurons in Deep NLP Modelscited by 124
  18. 2025Which Attention Heads Matter for In-Context Learning?cited by 61
  19. 2023Learning Transformer Programscited by 41
  20. 2024Opening the AI black box: program synthesis via mechanistic interpretabilitycited by 20
  21. 2025Can Interpretation Predict Behavior on Unseen Data?cited by 8

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.