菜单

关于 🐙 GitHub
arXiv 提交日期: 2026-06-17
📄 Abstract - Explaining Attention with Program Synthesis

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.

顶级标签: llm machine learning
详细标签: interpretability attention heads program synthesis mechanistic interpretability reverse engineering 或 搜索:

用程序合成来解释注意力机制 / Explaining Attention with Program Synthesis


1️⃣ 一句话总结

本文提出了一种通过自动生成简单Python程序来模拟和替代Transformer模型中注意力头行为的方法,使得我们既能用人类可读的代码理解模型内部运作,又能在替换大量注意力头后几乎不损害模型性能,从而实现神经网络的可解释性突破。

源自 arXiv: 2606.19317