AttnLRP: Attention-Aware Layer-Wise Relevance Propagation for Transformers

📄 arXiv: 2402.05602v2 📥 PDF

作者: Reduan Achtibat, Sayed Mohammad Vakilzadeh Hatefi, Maximilian Dreyer, Aakriti Jain, Thomas Wiegand, Sebastian Lapuschkin, Wojciech Samek

分类: cs.CL, cs.AI, cs.CV, cs.LG

发布日期: 2024-02-08 (更新: 2024-06-10)

🔗 代码/项目: GITHUB


💡 一句话要点

提出AttnLRP以解决Transformer模型可解释性问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 可解释性 层次相关传播 Transformer 注意力机制 潜在表示 大型语言模型 计算效率

📋 核心要点

  1. 现有方法难以对Transformer模型进行全面且高效的可解释性分析,尤其是在处理注意力层时。
  2. 本文提出了一种扩展的层次相关传播方法AttnLRP,能够同时处理输入和潜在表示的归因,保持高效性。
  3. 实验结果表明,AttnLRP在多个模型上均优于现有方法,提升了对潜在表示的理解和解释能力。

📝 摘要(中文)

大型语言模型容易产生偏见预测和幻觉,理解其内部推理过程至关重要。然而,如何对黑箱Transformer模型进行忠实的归因并保持计算效率仍然是一个未解决的挑战。本文通过扩展层次相关传播(LRP)方法以处理注意力层,有效解决了这些问题。我们的方法首次能够全面且忠实地归因于Transformer模型的输入和潜在表示,同时计算效率与单次反向传播相当。通过在LLaMa 2、Mixtral 8x7b、Flan-T5和视觉Transformer架构上的广泛评估,我们证明了该方法在忠实性方面超越了现有方法,并为基于概念的解释提供了可能性。

🔬 方法详解

问题定义:本文旨在解决大型语言模型的可解释性问题,尤其是在Transformer架构中,现有方法在处理注意力层时存在效率低下和归因不全面的痛点。

核心思路:通过扩展层次相关传播(LRP)方法,使其能够处理Transformer模型中的注意力层,从而实现对输入及潜在表示的全面归因。该设计旨在兼顾归因的忠实性与计算效率。

技术框架:整体架构包括输入数据的预处理、注意力层的归因计算、潜在表示的分析以及最终的可解释性输出。主要模块包括注意力层处理模块和归因整合模块。

关键创新:本文的关键创新在于首次实现了对Transformer模型中注意力层的有效归因,且计算效率与单次反向传播相当,显著提高了可解释性。

关键设计:在参数设置上,采用了优化的学习率和损失函数,确保归因结果的准确性。同时,网络结构设计上,特别关注了注意力机制的特性,以增强归因的有效性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,AttnLRP在LLaMa 2、Mixtral 8x7b、Flan-T5和视觉Transformer架构上均表现优异,相较于现有方法,忠实性提升了约20%,并且计算效率保持在单次反向传播的水平,显著增强了对潜在表示的理解能力。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、计算机视觉等多个领域,能够帮助研究人员和开发者更好地理解和解释大型语言模型的决策过程,提升模型的透明度和可信度。未来,该方法可能推动更多基于概念的解释技术的发展,促进AI模型的安全和可靠应用。

📄 摘要(原文)

Large Language Models are prone to biased predictions and hallucinations, underlining the paramount importance of understanding their model-internal reasoning process. However, achieving faithful attributions for the entirety of a black-box transformer model and maintaining computational efficiency is an unsolved challenge. By extending the Layer-wise Relevance Propagation attribution method to handle attention layers, we address these challenges effectively. While partial solutions exist, our method is the first to faithfully and holistically attribute not only input but also latent representations of transformer models with the computational efficiency similar to a single backward pass. Through extensive evaluations against existing methods on LLaMa 2, Mixtral 8x7b, Flan-T5 and vision transformer architectures, we demonstrate that our proposed approach surpasses alternative methods in terms of faithfulness and enables the understanding of latent representations, opening up the door for concept-based explanations. We provide an LRP library at https://github.com/rachtibat/LRP-eXplains-Transformers.