Manuscript Offprint

arXiv:2609.39704

When Masking Helps or Hurts Robustness in Compressed CLIP: A Pre-Deployment Diagnostic

Muhammad Zawish, Steven Davy

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

Abstract

This paper demonstrate that whether masking-based token pruning helps or hurts worst-group robustness can be predicted before deployment, without labels or fine-tuning. A systematic study of semantic masking across 8 spurious-correlation benchmarks shows its effect on worst-group accuracy is highly unstable: it improves accuracy by up to 82.5% relative on some datasets and degrades it by up to 100% on others. We trace this instability to spurious inversion: background patches receive higher CLIP text-similarity than the true object when the spurious attribute is background-separable, inverting the assumption every text- and attention-guided pruning method relies on. We introduce the Spurious Inversion Metric (SIM), a label-free, pre-deployment diagnostic whose sign predicts this effect with statistical significance (binomial p=0.035p = 0.035) across all 8 datasets, and remains dependable across 6 CLIP architectures with a clean foreground/background split. Naive masking is itself a major source of risk: it causes the largest average-accuracy loss of any method we evaluate, and its own per-image segmentation step is a significant runtime bottleneck. To address this, we design a batched, synchronization-free GPU segmentation routine that cuts this overhead from 3.5×3.5 \times to 1.75×1.75 \times baseline. Gating deployment by SIM's sign recovers masking's benefits while avoiding its worst failures, matching or exceeding a strong pruning baseline on 7 of 8 datasets.

1 Introduction

CLIP (Contrastive Language-Image Pre-training) [1] and other contrastively pretrained image-text models now underlie image classification and retrieval systems deployed under real compute budgets. Token pruning is among the most direct routes to compressing them: dropping a fraction of a vision transformer's patch tokens before the transformer body reduces quadratic attention cost, with only a modest drop in clean accuracy. Prior work has approached this through attention-based pruning at an intermediate layer [2], token merging and fusion [3], and learned importance scores [9], typically evaluated on clean, in-distribution accuracy alone. A parallel line of work targets a different goal: not efficiency, but robustness. The spurious-correlation literature [4] has established that a model's errors are often driven by non-causal background context rather than the object itself, with Waterbirds [4] and CelebA [5] as standard benchmarks, later extended by UrbanCars [6], MetaShifts [7], and ImageNet-9 [8]. Semantic masking, zeroing out image regions identified as background before encoding, is a natural response: removing the background should also remove the model's reliance on it.

None of the pruning methods above target worst-group robustness, and none of the masking methods above target efficiency. Because masking also reduces the number of tokens that must be processed, it is natural to ask whether a single mechanism can deliver both at once. We call our own construction MARS (Masking And Reduction for Spurious-correlation robustness): it segments each image into foreground and background without supervision, masks out the background pixels, and prunes the remaining tokens. As far as we know, no prior published method combines unsupervised segmentation

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: LIGHT: Lightweight Trustworthy Foundation Models.

with pixel-level masking and evaluates it for worst-group robustness on CLIP; MARS is built to test this premise directly, not a reproduction of an existing technique.

Effective use of masking as a compression mechanism entails two core challenges: (1) its effect on worst-group accuracy must be predictable before deployment, since masking can substantially degrade accuracy, and (2) any mechanism used to make this prediction, or to apply masking itself, must be efficient enough that its overhead does not offset the compression it delivers. We show that this combination is not free, and that its failure mode is silent. Across 8 standard spurious-correlation benchmarks, a representative semantic masking method (mask, then prune to half the tokens) improves worst-group accuracy by as much as 82.5% relative on UrbanCars and 25.6% on Waterbirds, while degrading it by 70.0% relative on ImageNet-9 and 39.7% on MetaShifts. There is no signal at inference time that distinguishes these two regimes: the method is applied identically, and only the eventual worst-group evaluation reveals which outcome occurred. For a paradigm centered on deploying compact models into regulated or safety-relevant settings, an intervention whose sign is unknown in advance is a liability rather than a solution.

We locate the source of this instability in a specific, measurable property of CLIP's joint embedding space: on datasets where the spurious attribute is a separable background region, background patches have higher cosine similarity to a generic class-level text prompt than the patches covering the true object, inverting the assumption every text- or attention-guided pruning method relies on (higher text-relevance as evidence for the object). We call this spurious inversion: a measurable, dataset-conditional signal, not a property of one benchmark.

Because the underlying quantity (per-patch text similarity, split by an unsupervised foreground/background segmentation) requires no downstream task label and no model evaluation, it can be computed for any candidate deployment dataset before a single classification is scored. We formalize this as the Spurious Inversion Metric (SIM): a diagnostic, not a corrective mechanism, that tells a practitioner in advance whether masking is likely to help or hurt on their data. Section 3 makes this precise: our implementation samples images according to the same group structure (label × spurious attribute) worst-group evaluation itself uses, so it presumes that structure is known, though it needs neither correctness labels nor a trained classifier.

Contributions. (1) We document spurious inversion, a measurable, mechanistically grounded property of CLIP representations, distinct from the known fact that attention alone is a biased importance signal. (2) We introduce SIM, a diagnostic requiring no downstream task label and no model evaluation, whose sign predicts the direction of masking's effect on worst-group accuracy with statistical significance across 8 datasets (binomial p=0.035p = 0.035; Spearman ρ=0.78\rho = 0.78). (3) We show gating deployment by SIM's sign matches or exceeds blind masking on every dataset, and a strong fixed pruning baseline on all but the one dataset where SIM's blind spot misfires, recovering most of masking's benefit without most of its worst failures. (4) We extend the analysis to 6 CLIP variants and characterize where the diagnostic holds and where it does not: dependable with a clean foreground/background separation, with a specific, reproducible blind spot on multi-context spurious structure (MetaShifts), which we report rather than obscure. (5) We separate two costs prior framings of masking-based compression conflate: SIM is a dataset-level diagnostic amortized to zero at inference time, while MARS's own segmentation step is a genuine per-inference cost; we document two unsuccessful attempts to remove this cost and one that succeeds, reducing MARS's overhead from 3.5×3.5 \times to roughly 1.75×1.75 \times baseline and leaving the remaining gap as an explicit open problem.

References (35)