Auditing Attention Head Masking for Out-of-Distribution Detection: Cross-Architecture Failures and Polarity Inversions
Abstract
Post-hoc scoring functions for out-of-distribution (OOD) detection in transformer models are typically validated on a single architecture and a single modality, leaving cross-architecture behavior largely uncharted. We report a cross-modality empirical study of attention-head-masking-based OOD detection across 2,000 per-seed AUROC measurements, spanning LayoutLMv3 on document classification, ViT-B/16 on natural images, and RoBERTa-base and RoBERTa-large on text. Each setting evaluates the AHM-augmented distance methods of Constantinou et al. (2024) and an Attention Head Sensitivity Score (AHSS) computed under the same head masking against up to twelve baseline groups under a uniform protocol, including the recent X-Mahalanobis from NeurIPS 2025 with uniform layer weights. Paired statistical tests, with multiple-comparison corrections, are run on every head-to-head claim. Four architecture-dependent phenomena surface that current evaluation practice tends to miss: Monte Carlo Dropout collapses to chance-level AUROC across all four ViT settings, because ViT-B/16 has no dropout; the AHSS displacement score inverts polarity on RoBERTa-base (mean AUROC 0.296), but not with long inputs or on RoBERTa-large; near-OOD degradation depends on modality, class and method, from 13.0 and 14.4 AUROC points for Mahalanobis on vision and text to 0.5–9.6 points on documents; and on RoBERTa-large the AHM-augmented distance scores collapse (mahAHM 0.925 to 0.345) unless their reference statistics are fit under the test-time masks. In head-to-head comparisons at n = 15 seeds, mahAvgAvg_AHM beats X-Mahalanobis on Tobacco-Cross, a controlled ablation of the masks (+0.0136), and on RoBERTa SST-2 → 20-Newsgroups (+0.0577), both surviving Bonferroni correction over 23 tests; on standard CIFAR vision benchmarks it does not beat the strongest baseline. We release per-seed measurements, AHM masks, checkpoints, and code to support replication.