arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.21564cs.LG
收藏

LIG:用于Transformer层内流分析的逐层积分梯度

LIG: Layer-wise Integrated Gradients for Within-Layer Flow Analysis in Transformers

Waseda University(早稻田大学);The Institute of Statistical Mathematics(统计数理研究所);Fujitsu Limited(富士通株式会社)

Eight Suzuki, Hideitsu Hino, Noboru Murata

AI总结:

提出LIG方法,在Transformer模块边界应用集合到集合的积分梯度,通过L2标量化扩展IG,实现层内贡献分解与信息流分析,揭示注意力与MLP模块的独立贡献。

摘要:

Transformer模型性能强大,但其内部计算仍不透明。我们将每个Transformer层视为一个动态图,其节点为token表示和每个注意力头的输出,多头注意力(ATT)和MLP作为模块边界。在此图上,我们使用LIG(逐层积分梯度),它在非线性模块边界应用集合到集合的积分梯度(IG)。集合到集合的IG将IG应用于从一组输入token表示到一组输出表示的映射,评估token到token的贡献,这在先前的IG应用中并不标准。这通过L2标量化将IG从通常的标量目标设置扩展到集合到集合的映射,并按照逐层相关性传播(LRP)的精神组合层内贡献,其中IG完备性在每个边界扮演LRP式守恒的角色。我们使用LIG分析:(i)在L2准则下模块级组合与层整体归因之间的一致性,以及(ii)通过追踪分离的ATT和MLP贡献来分析层内信息流。在BERT-base和PTB上,最能保持层内一致性的配置使用目标token的嵌入作为ATT基线,并使用a=0时的ATT输出或零作为MLP基线。因此,我们将LIG作为一种模块边界粒度的诊断性XAI工具,无需模型特定的重新训练或每操作解释器设计。代码可在该URL获取。

英文摘要:

Transformers achieve strong performance, but their internal computations remain opaque. We view each Transformer layer as a dynamic graph whose nodes are token representations and per-head attention outputs, with Multi-Head Attention (ATT) and MLP as module boundaries. On this graph we use LIG (Layer-wise Integrated Gradients), which applies set-to-set Integrated Gradients (IG) at nonlinear module boundaries. Set-to-set IG applies IG to a map from a set of input token representations to a set of output representations, evaluating token-to-token contributions, which is not standard in prior IG applications. This extends IG from the usual scalar-objective setting to set-to-set maps via an L2 scalarization, and composes within-layer contributions in the spirit of Layer-wise Relevance Propagation (LRP), with IG completeness playing the role of LRP-style conservation at each boundary. We use LIG to analyze (i) the agreement between module-wise composition and layer-whole attribution under an L2 criterion, and (ii) within-layer information flow by tracing separated ATT and MLP contributions. On BERT-base and PTB, configurations that best preserved within-layer consistency used the target token's embedding as the ATT baseline and either the ATT output at a=0 or Zero as the MLP baseline. We therefore present LIG as a diagnostic XAI tool at module-boundary granularity, without model-specific retraining or per-operation interpreter design. Code is available at https://github.com/eightsuzuki/layer-wise-integrated-gradients.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑