arXiv:2610.21638cs.CVOct 2026

Manuscript Offprint

arXiv:2610.21638

Spurious Attention Heads in Vision Transformers: Mechanistic Identification of Annotation-Driven Bias in Medical Chest X-Ray Analysis

Joshua Muhumuza, Cornelius Kalenzi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Vision Transformers deployed in medical imaging exploit spurious correlations, yet the internal mechanisms remain unidentified and impossible to fix. We apply mechanistic interpretability to locate one such mechanism in ViT-Base/16: a single attention head (L8H10) that functions as a dedicated annotation-reader on chest X-rays, attending to corner text rather than lung pathology in 62% of 200 COVID-19 images. Causal validation via inpainting confirms annotation content rather than luminance or edge density drives the behaviour, increasing lung attention 1.52×1.52\times upon removal in affected images (p<0.0001). The finding replicates across NIH ChestX-ray14 (79%), DeiT-Base (88%), and ViT-Large/16 (80%), establishing spurious annotation-attending heads as a consistent property of ViT-family architectures across two datasets and three architectures. Full fine-tuning does not suppress the behaviour and may entrench it: 98.4% of spurious images remain spurious and the spurious rate rises marginally, as the shortcut is reinforced rather than removed. Critically, single-head ablation produces p=0.340 and multi-head ablation of all three identified carriers produces p=0.532, meaning a causally verified annotation-reading circuit is completely invisible to output-level evaluation. Mechanistic auditing finds what behavioural testing cannot.

1 Introduction

A chest X-ray classifier can learn to read the hospital code stamped in the corner of every image rather than the pathology in the lungs. The model will perform well in-distribution and fail silently the moment it encounters a new institution. This is not a hypothetical failure mode. DeGrave et al. [DeGrave et al., 2021] documented it concretely for COVID-19 classifiers, and Zech et al. [Zech et al., 2018] showed the same pattern for pneumonia detection. What neither work could answer is which components implement the shortcut internally, and whether removing them would help or simply degrade performance.

Existing explainability tools like Grad-CAM, attention rollout, and LIME show where a model attended. They do not identify which specific component caused it, and they cannot establish causation. The difference matters for intervention: you cannot fix a mechanism you have not located.

This failure mode is acutely consequential in the African and broader global health context. ViT-based chest X-ray classifiers are increasingly deployed for tuberculosis and pneumonia screening in low-resource clinical settings [Vanitha et al., 2025], typically as models pretrained at a high-resource referral centre and transferred directly to district hospitals or mobile screening units with different X-ray equipment, different PACS software, and different annotation conventions. A model trained at a large teaching hospital, where the scanner software stamps a facility code in the top-left corner of every image, may silently read that code rather than the lung pathology and produce systematically degraded performance the moment it is deployed at a clinic whose scanner stamps nothing, or stamps a different code at a different location. This transfer happens routinely and without mechanistic re-auditing. Standard accuracy benchmarks, evaluated on held-out data from the same institution, will not detect it.

We apply mechanistic interpretability, a toolkit developed for dissecting language models, to a medical Vision Transformer. We identify one attention head, L8H10, as a dedicated corner-contrast detector that reliably attends to annotation text across two datasets and three architectures. We verify its behaviour causally. We then ablate it and find no measurable downstream effect at either the single-head or multi-head level. The head is safety-relevant and evaluation-invisible. This gap is the central finding. The three-stage analysis pipeline is summarised in Figure 1.