让Transformer模型自动生成可读代码,突破符号逻辑提取瓶颈。
Weights to Code: Extracting Interpretable Algorithms from the Discrete Transformer
- 通过温度退火采样引入离散性,解耦复杂特征表示
- 在离散任务上性能媲美RNN基线,支持连续中间计算的代码提取
- 架构先验提供对生成代码的精细控制,适合可解释性研究
算法提取旨在从训练过的模型中直接合成可执行程序,实现无需人工编写目标程序即可恢复可执行机制。然而,由于表示纠缠(如超位置)导致特征编码在重叠方向上难以解析,将该范式应用于Transformer面临挑战。本文提出离散Transformer,一种显式连接连续表示与离散符号逻辑的架构。通过温度退火采样注入离散性,框架有效结合假设检验与符号回归,实现人类可读程序的提取。实证表明,离散Transformer在共享离散任务上性能接近基于RNN的MIPS基线,同时拓展至包含连续值中间计算的任务。此外,架构的归纳偏置可对合成程序进行细粒度控制,使离散Transformer成为算法提取与Transformer可解释性的可控测试平台。
原文摘要 · Abstract (English)
Algorithm extraction aims to synthesize executable programs directly from models trained on algorithmic tasks, enabling de novo recovery of executable mechanisms from weights without relying on human-written target programs. However, applying this paradigm to Transformer is complicated by representation entanglement (e.g., superposition), where features encoded in overlapping directions substantially hinder the recovery of symbolic expressions. We propose the Discrete Transformer, an architecture explicitly designed to bridge the gap between continuous representations and discrete symbolic logic. By injecting discreteness through temperature-annealed sampling, our framework effectively leverages hypothesis testing and symbolic regression to extract human-readable programs. Empirically, the Discrete Transformer achieves performance comparable to the RNN-based MIPS baseline on shared discrete tasks, while broadening extraction to tasks with continuous-valued intermediate computations. Finally, we show that architectural inductive biases provide fine-grained control over synthesized programs, establishing the Discrete Transformer as a controllable testbed for algorithm extraction and Transformer interpretability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。