Influence Score and Transformers interpretability: Measure of the Effective Impact of Attention Heads at inference time
Organizations: Thales CDI, France · Inria Paris, France · Sorbonne Université, France
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.
Figures & tables
| Cat. | Top (pro- Inj ) | Score | Top (pro- Ben ) | Score |
|---|---|---|---|---|
| TP | , , | 0.03, 0.03, 0.01 | , , | -0.01, -0.01, -0.01 |
| TN | , , | 0.06, 0.01, 0.01 | , , | -0.04, -0.01, -0.01 |
| FP | , , | 0.13, 0.01, 0.01 | , , | -0.02, -0.01, -0.01 |
| FN | , , | 0.07, 0.01, 0.01 | , , | -0.06, -0.01, -0.04 |
| Group | Criterion | F1 | Acc. | |||
|---|---|---|---|---|---|---|
| TP | Score | 0.898 | 0.944 | 0.014 | 257 | |
| Logit only | 0.904 | 0.947 | 0.009 | 161 | ||
| Contrib only | 0.905 | 0.948 | 0.007 | 117 | ||
| TN | Score | 0.903 | 0.946 | 0.009 | 138 | 9 |
| Logit only | 0.897 | 0.944 | 0.015 | 273 | ||
| Contrib only | 0.904 | 0.947 | 0.009 | 130 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Source | Proportion (%) |
| Instruction / assistant datasets (Alpaca 12 12 12 https://huggingface.co/datasets/tatsu-lab/alpaca Taori and others (2023) , OpenOrca 13 13 13 https://huggingface.co/datasets/Open-Orca/OpenOrca , UltraChat 14 14 14 https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k Ding and others (2023) , Open-Instruct 15 15 15 https://huggingface.co/datasets/VMware/open-instruct Wang and others (2023) ) | 62.8 |
| Prompt collections (Awesome ChatGPT Prompts 16 16 16 https://github.com/f/awesome-chatgpt-prompts ) | 2.6 |
| Jailbreak Classification Dataset (jackhhao/jailbreak-classification 17 17 17 https://huggingface.co/datasets/jackhhao/jailbreak-classification ) | 3.2 |
| Microsoft TaskTracker Injection Datasets (TaskTracker Prompt Injection Dataset 18 18 18 https://github.com/microsoft/TaskTracker/tree/main/data/prompt_injection ) | 30.2 |
| JailbreakBench (JailbreakBench Dataset 19 19 19 https://huggingface.co/datasets/JailbreakBench/JBB-Behaviors Chao and others (2024) ) | 1.2 |
| Total | 100 |
| Cluster | #ex. | Duplication (%) | Median char. length | Median words | % 1000 car. |
|---|---|---|---|---|---|
| C0 | 2 112 | 0.52 | 2 103 | 366 | 74.6 |
| C1 | 11 377 | 0.26 | 313 | 53 | 8.9 |
| C2 | 6 942 | 4.78 | 115 | 19 | 14.3 |
Transformer Interpretability
Transformer interpretability studies how attention, feed-forward layers, and hidden representations support model predictions and behavior.
See all 339 papers