解决Transformer梯度解释失真问题,提升模型可解释性。
LibraGrad: Balancing Gradient Flow for Universally Better Vision Transformer Attributions
- 通过剪枝与缩放反向路径修正梯度流动不均。
- 在8种架构、4个数据集上统一提升解释准确性。
- 适用于CLIP、ImageNet微调等复杂场景,适合研究可解释性者。
为何基于梯度的解释方法在Transformer中表现不佳?我们发现Transformer存在梯度流不平衡,违背了确保归因忠实性的全梯度完备性(FullGrad-completeness),而这一性质卷积网络天然具备。为此,我们提出LibraGrad——一种理论严谨的后处理方法,通过剪枝和缩放反向路径纠正梯度不平衡,不改变前向计算,无额外计算开销。我们在三个指标族上评估:忠实性(扰动关键/非关键特征时预测变化)、完整性误差(归因与模型输出的保真度)、分割平均精度(与人类感知对齐程度)。在8种架构、4种模型尺寸、4个数据集上的广泛实验表明,LibraGrad普遍提升梯度方法性能,优于现有白盒方法,包括针对Transformer设计的方法。定性验证显示其在CLIP模型上实现精准文本提示区域定位,在微调ImageNet模型上准确区分共现动物类别,而现有方法常失效。即使在无注意力的MLP-Mixer上也有效,表明可推广至其他现代架构。代码已开源。
原文摘要 · Abstract (English)
Why do gradient-based explanations struggle with Transformers, and how can we improve them? We identify gradient flow imbalances in Transformers that violate FullGrad-completeness, a critical property for attribution faithfulness that CNNs naturally possess. To address this issue, we introduce LibraGrad -- a theoretically grounded post-hoc approach that corrects gradient imbalances through pruning and scaling of backward paths, without changing the forward pass or adding computational overhead. We evaluate LibraGrad using three metric families: Faithfulness, which quantifies prediction changes under perturbations of the most and least relevant features; Completeness Error, which measures attribution conservation relative to model outputs; and Segmentation AP, which assesses alignment with human perception. Extensive experiments across 8 architectures, 4 model sizes, and 4 datasets show that LibraGrad universally enhances gradient-based methods, outperforming existing white-box methods -- including Transformer-specific approaches -- across all metrics. We demonstrate superior qualitative results through two complementary evaluations: precise text-prompted region highlighting on CLIP models and accurate class discrimination between co-occurring animals on ImageNet-finetuned models -- two settings on which existing methods often struggle. LibraGrad is effective even on the attention-free MLP-Mixer architecture, indicating potential for extension to other modern architectures. Our code is freely available at https://github.com/NightMachinery/LibraGrad.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。