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

Reduan Achtibat, Sayed Mohammad Vakilzadeh Hatefi, Maximilian Dreyer, Aakriti Jain, Thomas Wiegand, S. Lapuschkin, Wojciech Samek

arXiv:2402.05602 · 2026-07-27 공개 · arXiv · PDF

transformer vision-transformer llama-2 model-interpretation latent-representations attention-layers attnlrp layer-wise-relevance-propagation

Abstract

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.

한국어 요약

한 줄 요약

AttnLRP는 Transformer 모델의 주의 계층을 처리하는 Layer-wise Relevance Propagation을 확장하여, 계산 효율성과 신뢰도를 동시에 달성한 새로운 해석 방법이다.

핵심 기여도

핵심 아이디어

기존 LRP는 Transformer의 주의 계층 및 비선형 함수(예: softmax, FFN)에 적용 시 수치 불안정성과 신뢰도 저하를 겪었다. 이에 반해, AttnLRP는 Layer-wise Relevance Propagation을 Transformer의 고유한 구조에 맞게 확장하여, query-key matrix multiplication, softmax, FFN, MoE 라우팅 네트워크 등 비선형 성분을 정확히 해석할 수 있도록 새로운 규칙을 제안한다. 특히, Deep Taylor Decomposition 기반의 γ-규칙을 적용하여 노이즈 제거 효과를 얻는다. 이는 기존의 rollout 기반 attention 해석 방법이 checkerboard 아티팩트를 유발하는 문제를 해결하는 데 기여한다.

기술적 접근법

주요 결과

의의 및 한계

AttnLRP는 Transformer 모델의 잠재 표현을 실시간으로 해석할 수 있는 기반을 제공하며, 모델 내부의 비선형 성분을 정확히 추적할 수 있어 개념 기반 해석(Concept-based Explanation)을 가능하게 한다. 또한, 단일 backward pass로 전체 모델을 해석할 수 있어 기존 perturbation 방법 대비 계산 효율성이 높다. 그러나, 모든 비선형 함수에 대한 규칙 확장이 필요하며, 특정 모델 구조(예: 복잡한 MoE)에 따라 추가적인 규칙 조정이 요구될 수 있다.

실용적 활용

AttnLRP는 대형 언어 모델과 Vision Transformer 모두에 적용 가능하며, 모델의 내부 작동 원리를 실시간으로 이해하고, 오류나 편향을 진단하는 데 활용할 수 있다. 특히, 모델의 신뢰성 향상과 사용자-모델 상호작용을 위한 실용적 도구로 활용 가능하다.