arXiv:2609.05074cs.CLSep 2026

Manuscript Offprint

arXiv:2609.05074

Influence Score and Transformers interpretability: Measure of the Effective Impact of Attention Heads at inference time

Lisa Bouger, Yannick Teglia, Philippe Loubet Moundi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Lisa Bouger¹,²,³ Yannick Teglia¹ Philippe Loubet Moundi¹

(1) Thales CDI, France

(2) Inria Paris, France

(3) Sorbonne Université, France

lisa.bouger@thalesgroup.com, yannick.teglia@thalesgroup.com, philippe.loubet-moundi@thalesgroup.com

ABSTRACT : We propose an influence score to quantify the contribution of attention heads to classification decisions in Transformer-based models designed for prompt injection detection. The score combines directional influence on the logits with structural contribution within the residual stream, enabling a multi-scale analysis at the head, layer, and network levels. Applied to a DeBERTa model specialized for prompt injection detection, our framework reveals distinct decision behaviours between correct and erroneous predictions. Our method provides an effective compromise between fine-grained circuit analysis and global output-based methods, and offers a systematic way to study decision mechanisms in Transformer classifiers.

KEYWORDS : Transformer interpretability, attention heads, prompt injection detection, LLM security, residual stream analysis, decision mechanisms.

1 Introduction

The increasing deployment of large language models comes with new vulnerabilities, notably prompt injection and jailbreak attacks aimed at manipulating their behavior. To mitigate these risks, classification models are commonly deployed upstream to detect and block malicious queries (Liu et al., 2023). These systems predominantly rely on Transformer architectures (Vaswani et al., 2017). In this context, understanding the internal mechanisms of these models has become an important challenge for ensuring their reliability and transparency. This issue is particularly critical for classifiers whose training data are not fully accessible or controllable. Interpretability can then be used to analyze their behavior, identify potential biases, and better understand their internal decision-making mechanisms. While these architectures achieve remarkable performance, their continuously increasing scale and the complexity of their internal interactions make their interpretation particularly demanding in terms of time and computational resources.

Current interpretability research operates at different levels, ranging from fine-grained analyses of internal circuits (Bricken et al., 2023; Conneau et al., 2018) to more global approaches relying solely on model outputs (Liu et al., 2023; Wei et al., 2022). While the former provide a high level of granularity, they often require complex instrumentation of the network; the latter enable large-scale evaluation but provide no direct access to the internal mechanisms responsible for the model's decisions.

In this paper, we propose an approach that explicitly connects the internal mechanisms of a Transformer to its classification decisions. We introduce an influence score that estimates the contribution of each attention head to the final prediction by combining its impact on the logits with its relative importance within the internal representation.

Our approach provides a trade-off between analytical granularity and computational cost. It enables the identification of mechanisms contributing to different categories of predictions while maintaining a global view of the model's behavior. We show that this framework enables the automated analysis of the Transformer's decision-making mechanisms and internal dynamics.

Figure

FIGURE 1 – Overview of the influence score. The impact of each head is measured by its directional influence on the logit (Δk,h\Delta_{k,h}) weighted by its contribution to the residual stream (Ck,hαkC_{k,h}\alpha_k).