WorksComputer Science
CLASP: Complementary Layer Selection and Profiling for Zero-Shot OOD Detection using Vision-Language Models
Abstract
Vision-language models (VLMs) enable zero-shot out-of-distribution (OOD) detection in medical imaging, yet existing approaches often rely on final-layer confidence or entropy-based layer selection, potentially missing complementary information. We show that low in-distribution (ID) confidence entropy does not reliably predict OOD discrimination. We introduce CLASP (Complementary Layer Selection and Profiling), an ID-only framework that jointly models layer–prompt responses and visual features. CLASP ranks visual encoder layers using Gaussian conditional mutual information and selects a compact subset through anchored spectral selection, without fixing the number of layers. It then combines the selected layer–prompt profiles with PCA-compressed visual embeddings and fits a single shrinkage-regularized Gaussian. OOD scores are computed using squared Mahalanobis distance, without fine-tuning, OOD training data, or test-time adaptation. Across histopathology, chest X-ray, and brain MRI benchmarks with UniMedCLIP and BioMedCLIP, CLASP performs strongly under varied distribution shifts. On MIDOG near-OOD, it achieves 87.54% AUROC with UniMedCLIP, outperforming confidence-based baselines; with BioMedCLIP, it remains competitive but trails visual-only Mahalanobis modeling. Ablations highlight the value of layer–prompt interactions and cross-feature dependencies, while exposing shift-dependent contributions and limitations under semantic shifts.
Introduction
Deep learning has demonstrated considerable potential in medical image analysis, including disease classification, segmentation, and computer-aided diagnosis. However, its reliability remains challenged by distribution shifts arising from variations in imaging devices, acquisition protocols, and patient populations. Such shifts can lead to unreliable predictions, even when models exhibit high confidence [8, 30]. Out-of-distribution (OOD) detection seeks to identify inputs that deviate from the in-distribution (ID) population before their predictions are used for clinical decision-making. Vision-language models (VLMs), particularly medical adaptations such as BioMedCLIP and UniMed-CLIP [13, 32], offer a promising direction by enabling zero-shot OOD detection through image–text alignment without requiring additional task-specific classifier training.
Existing VLM-based OOD detection methods typically rely on confidence scores derived from similarities between image representations and textual descriptions of known ID concepts. Maximum Concept Matching (MCM) [21], for instance, estimates confidence using the maximum softmax-normalized image–text similarity. While such approaches predominantly exploit final-layer representations, recent studies have investigated intermediate visual encoder layers and introduced entropy-guided strategies for selecting informative representations [20, 25]. However, their effectiveness can vary substantially across distribution shifts and VLM backbones, with approaches that perform well in one setting often deteriorating in another. These limitations raise three fundamental questions. tions concerning how to select complementary visual layers, preserve their prompt-conditioned information, and jointly exploit visual and textual representations for OOD detection.
Q1: Can complementary visual layers be selected more effectively than through entropy minimization? Existing entropy-guided approaches favor layers exhibiting concentrated confidence-score distributions on unlabeled ID samples. However, low ID entropy does not necessarily imply strong discrimination against unseen OOD samples. As illustrated in Figure 1(a), our analysis reveals only a weak association between ID histogram entropy and near-OOD detection performance across candidate layer subsets. Beyond identifying informative layers, determining how many layers to retain is equally important. Figure 2 illustrates that the preferred number of layers differs across distribution shifts: incorporating additional layers improves near-OOD detection on MIDOG before performance largely stabilizes, whereas fewer layers are preferable for Chest X-ray semantic OOD. These observations motivate a complementarity-aware selection strategy that automatically determines a compact set of visual layers without relying on entropy minimization or a predefined layer budget.

Figure 1. Motivation for Layer–Prompt Profiles (LPP). (a) Relationship between ID histogram entropy and near-OOD AUROC across candidate layer subsets on MIDOG using UniMedCLIP. The weak correlation suggests that minimizing ID entropy does not necessarily identify the most OOD-discriminative representations. (b) Two illustrative images exhibit identical layer-wise maximum similarity scores despite different layer–prompt response patterns. Reducing these responses to scalar confidence scores discards information preserved by the complete layer–prompt profile.
Figure 2. Impact of layer selection and representation choice on OOD detection. UniMedCLIP AUROC across selected-layer budgets for Chest X-ray L5 semantic OOD and MIDOG near-OOD. LPP stands for layer-prompt profiling and LPP-V combines LPP with visual representations.
Q2: Does scalar confidence aggregation discard useful layer–prompt information? Conventional confidence-based approaches reduce image–text similarities to a single score, potentially discarding individual responses to different textual descriptions. As illustrated in Figure 1(b), two images can exhibit identical layer-wise maximum similarities despite substantially different layer–prompt response patterns. Such differences may contain information relevant to identifying distribution shifts that cannot be recovered from the maximum scores alone. This motivates preserving the structured image–text similarity responses, or layer–prompt profiling (LPP) across selected visual layers and ID textual prompts, rather than collapsing them into scalar confidence estimates.
Q3: Can visual and prompt-conditioned representations be jointly exploited for OOD detection? Vision-language models provide two complementary sources of information: visual embeddings encode image characteristics, while image–text similarities capture their alignment with predefined semantic descriptions. Although layer–prompt profiles preserve structured semantic responses, they may not fully capture visual variations that are weakly reflected in the available textual prompts. Conversely, visual embeddings alone do not explicitly represent the relationships between images and ID concepts. This motivates jointly modeling visual features and matched layer–prompt profiles, allowing both representation types to contribute to a unified OOD detection framework across heterogeneous distribution shifts.
Motivated by these observations, we propose CLASP (Complementary Layer Selection and Profiling), a zero-shot OOD detection framework built around three components. First, CLASP employs Gaussian conditional mutual information (CMI) to rank visual encoder layers according to their complementary information relative to an ID-fitted visual reference, followed by anchored spectral admission to automatically determine which layers to retain without a predefined layer budget. Second, the selected layers define a matched layer–prompt profile that preserves their individual image–text similarity responses. Third, CLASP combines this structured profile with compact visual representations from the same selected layers and models their joint distribution using a single multivariate Gaussian with Ledoit–Wolf shrinkage-regularized covariance, fitted exclusively on unlabeled in-distribution (ID) calibration images. During inference, squared Mahalanobis distance from the estimated ID distribution serves as the OOD anomaly score. CLASP requires no VLM fine-tuning, external OOD data, or test-time adaptation. Our main contributions are as follows:
We introduce a complementarity-aware layer-selection strategy that replaces entropy-guided ranking with Gaussian Visual CMI and employs anchored spectral admission to automatically determine a compact subset of visual encoder layers using only unlabeled ID data, without requiring a predefined layer budget.
We propose matched layer–prompt profiling, preserving the structured image–text similarity responses of selected layers instead of reducing them to scalar confidence estimates. Our analysis demonstrates that these response patterns retain information that maximum confidence aggregation discards.
We develop a unified visual–prompt OOD detector that jointly models matched layer–prompt profiles and compact visual representations using an ID-fitted Gaussian. Evaluations across histopathology, chest X-ray, and brain MRI benchmarks with two medical VLMs demonstrate competitive performance across heterogeneous shifts, while ablations and calibration stability experiments characterize the contributions and robustness of the framework.
Related Work
Out-of-Distribution Detection. Conventional OOD detection methods rely on predictive confidence, feature statistics, or distances in learned representation spaces. Early approaches include Maximum Softmax Probability (MSP) [9], ODIN [18], and energy-based scoring [19], while feature-based approaches employ Mahalanobis distance [15], activation rectification (ReAct) [26], virtual-logit matching (ViM) [28], and nearest-neighbor distances [27]. These methods typically operate on representations obtained from supervised classification models. Their effectiveness under medical distribution shifts has been investigated in OpenMIBOOD [8], highlighting the challenges of generalization across imaging domains.
Zero-Shot OOD Detection with Vision–Language Models. Pretrained VLMs such as CLIP [24] enable OOD detection by measuring image–text similarity against descriptions of known ID concepts, without task-specific classifier training. Maximum Concept Matching (MCM) [21] estimates ID confidence from the maximum softmax-normalized similarity, while GL-MCM [23] incorporates local visual information. However, confidence-based scoring may overlook unknown concepts that exhibit strong semantic similarity to the ID classes. To address this limitation, several approaches introduce negative or unknown concepts through generated descriptions or external textual knowledge, including ZOC [6], NegLabel [11], and EOE [2]. Other approaches, such as CLIPScore [7], explore alternative scoring mechanisms to improve ID–OOD discrimination.
A complementary direction improves OOD detection through prompt learning and model adaptation. Building on prompt optimization approaches such as CoOp [34], methods including CLIPN [29] and Neg-Prompt [16] learn negative or negation-aware textual representations. Few-shot methods such as LoCoOp [22], ID-like Prompt Learning [1], and Local-Prompt [31] further exploit local information or synthetic outlier representations to improve detection. AdaNeg [33] instead constructs adaptive negative proxies using test-time observations. While these methods improve semantic discrimination through additional concepts, learned prompts, or adaptation, they do not explicitly preserve the joint similarity responses across visual encoder layers and ID textual prompts.
Medical VLM-Based OOD Detection. Domain-specific models such as BiomedCLIP [32] and UniMed-CLIP [13] have extended vision–language learning to medical imaging. Ju et al. [12] investigated semantic and covariate shifts in medical VLMs and introduced hierarchical prompting. PROTON and PROTON+ [3, 4] combine image–text confidence with prototype-based distances using test-time memory updates.
Intermediate Representations for OOD Detection. Recent studies suggest that intermediate encoder layers contain complementary OOD-relevant information. Beyond VLMs, BLOOD [10] exploits between-layer transformation smoothness for OOD detection in transformers. Meza De la Jara et al. [20] investigated entropy-guided layer selection in CLIP, while Rai et al. [25] introduced multi-resolution entropy estimation for medical VLMs. More recently, Voyager [5] proposed learned input-dependent layer routing using weak OOD supervision, whereas SeTAR [17] modifies pretrained weight matrices through selective low-rank approximation. Unlike approaches that select, aggregate, or modify individual layer representations, LPP retains the complete layer–prompt similarity matrix and models its joint ID distribution using a single shrinkage-regularized Gaussian, with squared Mahalanobis distance providing the OOD anomaly score.
Method
We propose CLASP (Complementary Layer Selection and Profiling), a zero-shot OOD detection framework that combines CMI-guided layer ranking, anchored spectral admission, and matched visual–prompt modeling. Their prompt responses are combined with complementary visual features and modeled using a single Gaussian fitted exclusively on unlabeled ID calibration images. An overview is presented in Figure 3.

Figure 3. Overview of CLASP. A frozen VLM extracts visual embeddings and layer–prompt similarities. Gaussian conditional mutual information (CMI) ranks candidate layers, while anchored spectral admission determines how many ranked layers to retain within a fixed visual capacity. The admitted layers define a matched layer–prompt profile, which is jointly modeled with complementary visual features using an ID-fitted Gaussian. Squared Mahalanobis distance serves as the OOD anomaly score.
Layer–Prompt Similarity Representation
Let denote the unlabeled ID calibration set and the predefined ID textual prompts. Given a frozen VLM with visual and text encoders and , we extract projected visual embeddings from all visual layers and text embeddings . Their image–text similarity is defined as
where follows the VLM-specific projection and normalization conventions. Collecting these responses yields the layer–prompt similarity matrix , where each row retains the individual similarities of layer to all ID prompts. Unlike confidence-based approaches, CLASP preserves these responses without maximum aggregation.
Layer Ranking and Selection
CMI layer ranking. We employ Gaussian conditional mutual information (CMI) to rank encoder layers according to the additional information their prompt responses provide about a visual reference. Let denote the final-layer visual embedding compressed using ID-fitted, unwhitened PCA, with . Starting from the mandatory final-layer anchor , we evaluate each remaining candidate layer using
where concatenates prompt responses from previously ranked layers, and the conditional covariances are computed through Schur complements of an ID-fitted Ledoit–Wolf covariance. At each step, the highest-scoring candidate is appended to the ranking:
This greedy procedure produces a complete layer ranking conditioned on all previously ranked layers, which remains fixed during subsequent spectral admission. Importantly, CMI determines only the candidate ordering, not the final layer subset or its size.
Anchored Spectral Layer Selection. Given the frozen CMI ranking, we determine which layers to retain using an anchored spectral admission procedure with a fixed visual capacity of . We first construct the final-layer visual anchor using ID-fitted, unwhitened PCA:
where contains the leading ID principal directions. To identify empirically stable anchor coordinates, we compare the full-calibration covariance with covariances estimated after deleting each calibration source group . We define the perturbation radius as
Anchor directions whose covariance eigenvalues exceed form the protected set , leaving dimensions available for complementary visual directions.
For each candidate layer examined in CMI order, we obtain its ID-fitted PCA representation and remove the information linearly predictable from protected anchor coordinates and previously admitted visual residuals. Let denote the previously admitted residual coordinates and their conditioning vector. The conditional visual residual is
where the regression coefficients are estimated exclusively from unlabeled ID data. The residual covariance is eigendecomposed as . Analogously to Eq. (5), we estimate a source-deletion perturbation radius for the conditional residual covariance, re-estimating the conditional regression after each deletion while retaining the full-fit PCA bases and normalization conventions. Residual directions satisfying are eligible for admission, subject to the remaining visual capacity. A candidate layer is retained if it contributes at least one admitted direction.
The procedure terminates when the first candidate contributes no admissible directions or the visual capacity is exhausted; any unused capacity is filled with remaining final-layer anchor coordinates. The resulting layer subset is therefore determined by spectral admission along the frozen CMI ranking, without requiring a predefined number of layers. The deletion criterion measures empirical stability under observed ID-source perturbations rather than guaranteeing OOD-optimal layer selection.
Matched Layer–Prompt and Visual Representation
Let denote the spectrally admitted layers, with . We construct the matched layer–prompt representation by retaining all prompt responses from each admitted layer:
For the visual representation, we concatenate the normalized visual embeddings of the admitted layers in a fixed order, with the original selected-layer scaling, and apply unwhitened PCA fitted exclusively on ID calibration images. Denoting this concatenated representation by , we obtain
where contains the leading ID principal directions. Thus, anchored spectral admission determines the retained layers, whereas ordinary PCA constructs their compact visual representation. The matched prompt and visual features are concatenated to form
The resulting representation preserves the individual prompt responses of the admitted layers alongside their compact visual embeddings, which are jointly modeled using the ID-fitted Gaussian described in the following subsection.
ID Distribution Modeling and OOD Scoring
We standardize each coordinate of using its ID calibration mean and standard deviation , obtaining . We then fit a single Gaussian to the standardized ID representations. Given their empirical covariance , we apply Ledoit–Wolf shrinkage [14] with numerical ridge regularization:
where is the shrinkage coefficient and ensures numerical stability. For an unseen image , the OOD anomaly score is its squared Mahalanobis distance from the learned ID distribution:
Higher scores indicate greater deviations from the ID distribution.
Experiments and Analysis
Datasets and Experimental Settings
Datasets. We evaluate our approach on three medical imaging benchmarks spanning histopathology, chest X-ray, and brain MRI. For histopathology, we follow the MIDOG benchmark protocol of OpenMIBOOD [8, 25], using domain 1a as ID with 1,815 unlabeled calibration images and 513 held-out ID images. Seven domains (2–5, 6a, 6b, and 7) are considered near-OOD, exhibiting semantic and acquisition-related shifts, while CCAgT and FNAC 2019 serve as far-OOD datasets. For chest X-ray evaluation, we follow the radiology benchmark protocol of PROTON+ [4], using RSNA normal and pneumonia images as ID, NIH ChestXray14 images with other findings as semantic OOD, pediatric chest radiographs as covariate OOD, and Imagenette as far-OOD. The benchmark construction explicitly de-duplicates NIH images against RSNA to prevent overlap between ID and semantic-OOD samples. For brain MRI, we evaluate OASIS-3 versus BraTS-GLI, using healthy brain MR images from OASIS-3 as ID and glioma-containing MR volumes from BraTS-GLI as near-OOD. The MRI benchmark comprises 848 ID calibration volumes, 181 held-out ID volumes, and 1,125 OOD volumes.
Experimental Setup. We employ UniMedCLIP [13] and BioMedCLIP [32], keeping both visual and textual encoders frozen. For the volumetric MRI benchmark, representations are aggregated across nine axial slices per volume. We report AUROC () and FPR@95 (), with OOD as the positive class. MIDOG results are reported as unweighted macro averages across the seven near-OOD and two far-OOD domains. All feature normalization statistics, PCA projections, Gaussian parameters, and covariance regularization are estimated exclusively from unlabeled ID calibration samples and remain fixed during inference.
Main Results
Tables 1 and 2 show that CLASP substantially outperforms confidence-based methods on MIDOG near-OOD, particularly with UniMedCLIP, while V-Mahalanobis remains competitive and performs better with BioMedCLIP. On Chest X-ray, CLASP achieves strong covariate- and far-OOD detection, whereas semantic shifts remain considerably more challenging. The results also demonstrate near-perfect discrimination between OASIS-3 and BraTS-GLI across both backbones. Overall, although individual baselines can outperform CLASP under specific distribution shifts or VLM backbones, CLASP maintains competitive performance across the evaluated settings without OOD-specific adaptation or method selection, suggesting a more broadly applicable detection framework rather than one optimized for a particular shift.
Analysis and Ablations
Layer-ranking ablation. Table 3 that Gaussian Visual CMI provides an effective ordering of complementary layers, particularly on MIDOG. The results show that typically a combination of last layer along with intermediate layers gives better OOD detection performance, while the resulting performance remains depen-
Table 3. Ablation of layer-ranking criteria using UniMed-CLIP. Each ranking is followed by the same spectral admission. Results report AUROC / FPR@95 (in %).
| Ranking criterion | MIDOG near Selected layers | MIDOG near AUROC/FPR@95 | Chest L5 semantic Selected layers | Chest L5 semantic AUROC/FPR@95 |
| Gaussian Visual CMI (ours) | {3, 8, 12} | 87.54/30.88 | {4, 12} | 65.40/87.83 |
| Entropy ordering | {7, 12} | 80.31/51.43 | {11, 12} | 63.24/88.33 |
| Conditional covariance | {5, 8, 12} | 85.14/36.73 | {5, 12} | 65.54/88.17 |
| Marginal visual MI | {11, 12} | 78.70/55.67 | {11, 12} | 63.24/88.33 |
Table 1. MIDOG OOD detection: unweighted macro averages across seven near-OOD and two far-OOD domains. AUROC and FPR@95 are in %. Explicit class-identity use denotes class-specific assignments or modeling beyond predefined ID text descriptions. Voyager is not reported because MIDOG contains only one semantic ID class, described by ten synonymous prompts, making its class-based layer-expert scores degenerate. PROTON+ results are averaged over five balanced online streams due to its test-time adaptation protocol, whereas the other methods are evaluated on complete test populations. Best results are highlighted in bold.
| Method | Explicit class-identity use | Ext. OOD | Additional Training | UniMedCLIP Near-OOD AUROC | UniMedCLIP Near-OOD FPR@95 | UniMedCLIP Far-OOD AUROC | UniMedCLIP Far-OOD FPR@95 | BioMedCLIP Near-OOD AUROC | BioMedCLIP Near-OOD FPR@95 | BioMedCLIP Far-OOD AUROC | BioMedCLIP Far-OOD FPR@95 |
| MCM [21] | ✗ | ✗ | ✗ | 47.25 | 91.95 | 81.64 | 51.56 | 40.08 | 97.61 | 36.95 | 100.00 |
| SRE [20] | ✗ | ✗ | ✗ | 29.10 | 99.70 | 97.10 | 16.60 | 32.10 | 97.30 | 99.80 | 1.30 |
| MRE [25] | ✗ | ✗ | ✗ | 54.60 | 94.40 | 97.40 | 13.40 | 36.40 | 100.00 | 99.50 | 2.70 |
| GL-MCM [23] | ✗ | ✗ | ✗ | 47.53 | 92.98 | 81.29 | 53.31 | 42.19 | 96.55 | 54.27 | 97.08 |
| PROTON+ [4] | ✓ | ✗ | ✗ | 47.00 | 95.14 | 74.92 | 67.02 | 48.88 | 95.73 | 24.31 | 99.92 |
| Voyager [5] | ✓ | ✓ | ✓ | – | – | – | – | – | – | – | – |
| V-Mahalanobis | ✗ | ✗ | ✗ | 80.48 | 47.01 | 99.99 | 0.10 | 72.97 | 62.24 | 99.67 | 1.07 |
| CLASP (ours) | ✗ | ✗ | ✗ | 87.54 | 30.88 | 100.00 | 0.00 | 70.63 | 66.47 | 99.46 | 1.66 |
Table 2. Chest X-ray and Brain MRI OOD detection under the L1 (2 prompts) and L5 (8 prompts) settings. Each cell reports AUROC / FPR@95 (in %). The Brain MRI column reports the OASIS-3 versus BraTS-GLI benchmark using four ID prompts. Bold denotes the best reported result for each backbone and OOD category.
| Backbone | Method | Chest X-ray: L1 (2 ID prompts) Semantic | Chest X-ray: L1 (2 ID prompts) Covariate | Chest X-ray: L1 (2 ID prompts) Far-OOD | Chest X-ray: L5 (8 ID prompts) Semantic | Chest X-ray: L5 (8 ID prompts) Covariate | Chest X-ray: L5 (8 ID prompts) Far-OOD | Brain MRI Near-OOD |
| UniMedCLIP | MCM [21] | 54.20/89.67 | 46.76/87.50 | 27.56/99.67 | 54.18/77.50 | 78.43/46.50 | 84.62/43.00 | 38.90/100.00 |
| SRE [20] | 64.32/87.50 | 20.17/99.67 | 82.81/86.33 | 59.51/89.00 | 93.10/30.33 | 100.00/0.00 | 11.50/100.00 | |
| MRE [25] | 64.32/87.50 | 20.17/99.67 | 82.81/86.33 | 60.37/89.75 | 88.25/48.08 | 100.00/0.00 | 15.20/100.00 | |
| GL-MCM [23] | 55.36/92.83 | 47.71/91.00 | 33.18/99.33 | 54.46/79.33 | 81.18/55.33 | 91.52/34.00 | 40.40/95.00 | |
| PROTON+ [4] | 61.39/88.13 | 93.88/29.00 | 91.52/37.93 | 49.90/92.13 | 88.50/36.53 | 96.86/9.53 | 35.90/100.00 | |
| Voyager [5] | 52.42/92.83 | 25.29/98.17 | 31.08/98.33 | 52.63/88.50 | 72.47/74.67 | 74.33/71.17 | – | |
| V-Mahalanobis | 62.00/86.67 | 99.97/0.00 | 100.00/0.00 | 62.00/86.67 | 99.97/0.00 | 100.00/0.00 | 51.60/92.50 | |
| CLASP (ours) | 66.44/85.00 | 99.91/0.17 | 100.00/0.00 | 65.40/87.83 | 99.89/0.00 | 100.00/0.00 | 99.97/0.00 | |
| BioMedCLIP | MCM [21] | 54.50/94.67 | 56.44/79.00 | 56.10/91.17 | 57.05/91.50 | 54.50/89.33 | 69.58/71.33 | 56.30/100.00 |
| SRE [20] | 51.50/93.83 | 16.21/99.83 | 99.41/0.83 | 55.72/93.83 | 62.75/79.50 | 99.84/0.33 | 14.10/100.00 | |
| MRE [25] | 51.50/93.83 | 16.21/99.83 | 99.41/0.83 | 57.24/92.25 | 80.24/50.50 | 99.97/0.08 | 14.10/100.00 | |
| GL-MCM [23] | 55.79/95.50 | 54.39/82.33 | 51.05/93.17 | 54.90/92.83 | 50.42/92.83 | 76.18/57.50 | 57.90/95.00 | |
| PROTON+ [4] | 55.57/93.93 | 75.79/67.63 | 91.81/15.27 | 58.00/92.30 | 76.86/56.90 | 91.98/12.70 | 43.00/95.00 | |
| Voyager [5] | 55.88/91.00 | 63.16/75.00 | 17.86/99.83 | 57.81/92.00 | 70.07/80.00 | 19.38/100.00 | – | |
| V-Mahalanobis | 53.16/94.83 | 95.67/19.67 | 100.00/0.00 | 53.16/94.83 | 95.67/19.67 | 100.00/0.00 | 72.70/62.50 | |
| CLASP (ours) | 57.34/94.67 | 95.96/20.67 | 100.00/0.00 | 56.75/94.17 | 97.29/14.33 | 100.00/0.00 | 100.00/0.00 |
Covariance modeling ablation. Table 4 demonstrates the importance of modeling cross-feature dependencies. Full Ledoit–Wolf covariance achieves the best performance on both benchmarks, improving AUROC over diagonal covariance by 7.38 percentage points on MIDOG and 7.15 points on Chest L5. Diagonal and identity covariance yield identical results, highlighting the importance of cross-coordinate correlations in the joint visual–prompt representation.
Table 4. Ablation of covariance modeling using UniMed-CLIP. All variants use identical CLASP representations. Results report AUROC/FPR@95 (%).
| Covariance model | MIDOG near | Chest L5 semantic |
| Full Ledoit–Wolf covariance (ours) | 87.54/30.88 | 65.40/87.83 |
| Diagonal covariance | 80.16/49.82 | 58.24/92.83 |
| Identity covariance | 80.16/49.82 | 58.24/92.83 |
Layer–prompt aggregation. Figure 4 shows that preserving the complete layer–prompt profile substantially improves MIDOG near-OOD AUROC, achieving 87.54% compared with 79.75% and 80.09% for layer-wise maximum and mean aggregation, respectively. On Chest L5 semantic OOD, all three approaches perform similarly, with mean aggregation achieving a marginally higher. These results suggest that preserving individual prompt responses is particularly beneficial for histopathology domain shifts, while its advantage is less pronounced for Chest X-ray semantic shifts.
Figure 4. Effect of layer–prompt aggregation. Comparison of layer-wise maximum, mean, and complete layer–prompt profiling (LPP) using UniMedCLIP.
Matched profiling and joint representation. Figure 5 shows that matched profiling improves the joint representation over full LPP on both benchmarks, increasing AUROC from 87.21% to 87.54% on MIDOG and from 60.44% to 65.40% on Chest L5. However, the individual branches exhibit shift-dependent behavior: matched LPP performs best on MIDOG (87.95%), characterized by acquisition and cell-type shifts, whereas visual PCA32 performs best on Chest L5 (66.46%), involving previously unseen pathological
Figure 5. Ablation of matched profiling and joint representation. Comparison of matched LPP, visual PCA32, full LPP with visual PCA32, and CLASP with anchored spectral admission selected layers.
findings. These findings highlight the complementary but shift-dependent contributions of prompt and visual representations.
ID calibration stability. Table 5 evaluates CLASP under reduced ID calibration data. Although the exact selected layers vary across repetitions, the number of retained layers remains unchanged, with three layers on MIDOG and two on Chest L5. Despite moderate selection agreement, AUROC exhibits limited variation across repetitions, suggesting that CLASP’s detection performance is less sensitive to calibration changes than the identities of individual selected layers. This indicates robustness in downstream detection while highlighting variability in the automatic layer selection.
| Benchmark | Reference layers | Agreement (%) | Jaccard | AUROC/FPR@95 |
| MIDOG near-OOD | {3, 8, 12} | 50.00 | 0.72 | 86.74 0.64 / 32.41 1.76 |
| Chest L5 semantic | {4, 12} | 30.00 | 0.54 | 65.02 0.84 / 88.20 0.97 |
Table 5. ID calibration stability of CLASP using UniMedCLIP across ten repetitions with approximately 80% calibration data. Agreement measures recovery of the full-calibration layer set, while Jaccard measures pairwise overlap between selected sets. AUROC and FPR@95 are reported as mean standard deviation (%).
Conclusion
We presented CLASP, a zero-shot OOD detection framework that combines Gaussian conditional mutual information for layer ranking, anchored spectral selection, and joint modeling of matched layer–prompt profiles and visual representations. By leveraging unlabeled ID calibration data, CLASP automatically determines a compact set of complementary layers and models their joint distribution using a single shrinkage-regularized Gaussian. Experiments across three medical imaging benchmarks and two VLM backbones demonstrate competitive and often improved OOD detection, particularly under acquisition-related distribution shifts, while highlighting the importance of preserving structured layer–prompt information and cross-feature dependencies.
Limitations and future work. CLASP’s effectiveness remains dependent on the distribution shift and VLM backbone, with semantic OOD detection posing particular challenges. Furthermore, although detection performance remains relatively stable under calibration subsampling, the identities of selected layers can vary. Future work will investigate more robust layer-selection strategies and adaptive integration of visual and prompt representations.
References
- [1]Yichen Bai, Zongbo Han, Bing Cao, Xiaoheng Jiang, Qinghua Hu, and Changqing Zhang. Id-like prompt learning for few-shot out-of-distribution detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 17480–17489, 2024. 3arxiv.org/abs/2311.15243
- [2]Chentao Chen, Zhuh Zhong, Zhanke Zhou, Yang Liu, Tongliang Liu, and Bo Han. Envisioning outlier exposure by large language models for out-of-distribution detection. In Proceedings of the 41st International Conference on Machine Learning, pages 5629–5659. PMLR, 2024. 3
- [3]Abhijit Das, Nichula Wasalathilaka, Yifan Lu, Adinath Dukre, Dwarikanath Mahapatra, Shadab Khan, and Imran Razzak. Proton: Prototype-based test-time online ood detection for medical vlms. In Medical Image Computing and Computer Assisted Intervention, 2026. 4arxiv.org/abs/2606.20913
- [4]Abhijit Das, Nichula Wasalathilaka, Yifan Lu, Adinath Dukre, Dwarikanath Mahapatra, Shadab Khan, and Imran Razzak. Proton+: Contamination-robust prototype banks for test-time online ood detection with medical vlms, 2026. Preprint. 4, 6, 7
- [5]Ignacio M. De la Jara, Cristian Rodriguez-Opazo, and Damith Ranasינגhe. Not all layers are equal: Dynamic layer routing for reliable clip ood detection, 2026. 4, 7
- [6]Sepideh Esmaeilpour, Bing Liu, Eric Robertson, and Lei Shu. Zero-shot out-of-distribution detection based on the pre-trained model clip. In Proceedings of the AAAI Conference on Artificial Intelligence, pages 6568–6576, 2022. 3
- [7]Hao Fu, Naman Patel, Prashanth Krishnamurthy, and Farshad Khorrami. Clipscope: Enhancing zero-shot ood detection with bayesian scoring. In Proceedings of the Winter Conference on Applications of Computer Vision, pages 5346–5355, 2025. 3arxiv.org/abs/2405.14737
- [8]Max Gutbrod, David Rauber, Danilo Weber Nunes, and Christoph Palm. Openmibood: Open medical imaging benchmarks for out-of-distribution detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 25874–25886, 2025. 1, 3, 6arxiv.org/abs/2503.16247
- [9]Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In International Conference on Learning Representations, 2017. 3
- [10]Fran Jelenić, Josip Jukić, Martin Tutek, Mate Puljić, and Jan Šnajder. Out-of-distribution detection by leveraging between-layer transformation smoothness. In International Conference on Learning Representations, 2024. 4arxiv.org/abs/2310.02832
- [11]Xue Jiang, Feng Liu, Zhen Fang, Hong Chen, Tongliang Liu, Feng Zheng, and Bo Han. Negative label guided ood detection with pretrained vision-language models. In International Conference on Learning Representations, 2024. 3arxiv.org/abs/2403.20078
- [12]Lie Ju, Sijin Zhou, Yukun Zhou, Huimin Lu, Zhuoting Zhu, Pearse A. Keane, and Zongyuan Ge. Delving into out-of-distribution detection with medical vision-language models. In Medical Image Computing and Computer Assisted Intervention, pages 133–143, 2025. 4arxiv.org/abs/2503.01020
- [13]Muhammad Uzair Khattak, Shahina Kunhimon, Muzammal Naseer, Salman Khan, and Fahad Shahbaz Khan. Unimed-clip: Towards a unified image-text pre-training paradigm for diverse medical imaging modalities, 2024. 1, 4, 6
- [14]Olivier Ledoit and Michael Wolf. A well-conditioned estimator for large-dimensional covariance matrices. Journal of multivariate analysis, 88(2):365–411, 2004. 6
- [15]Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In Advances in Neural Information Processing Systems, 2018. 3arxiv.org/abs/1807.03888
- [16]Tianqi Li, Guansong Pang, Xiao Bai, Wenjun Miao, and Jin Zheng. Learning transferable negative prompts for out-of-distribution detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 17584–17594, 2024. 3arxiv.org/abs/2404.03248
- [17]Yixia Li, Boya Xiong, Guanhua Chen, and Yun Chen. Setar: Out-of-distribution detection with selective low-rank approximation. In Advances in Neural Information Processing Systems, 2024. 4arxiv.org/abs/2406.12629
- [18]Shiyu Liang, Yixuan Li, and R. Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks. In International Conference on Learning Representations, 2018. 3arxiv.org/abs/1706.02690
- [19]Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based out-of-distribution detection. In Advances in Neural Information Processing Systems, 2020. 3arxiv.org/abs/2010.03759
- [20]Ignacio Meza De la Jara, Cristian Rodriguez-Opazo, Damien Teney, Damith Ranasinghe, and Ehsan Abbasnejad. Mysteries of the deep: Role of intermediate representations in out of distribution detection. In Advances in Neural Information Processing Systems, 2025. 1, 4, 7arxiv.org/abs/2510.05782
- [21]Yifei Ming, Ziyang Cai, Jixiang Gu, Yiyou Sun, Wei Li, and Yixuan Li. Delving into out-of-distribution detection with vision-language representations. In Advances in Neural Information Processing Systems, 2022. 1, 3, 7arxiv.org/abs/2211.13445
- [22]Atsuyuki Miyai, Qing Yu, Go Irie, and Kiyoharu Aizawa. Locoop: Few-shot out-of-distribution detection via prompt learning. In Advances in Neural Information Processing Systems, 2023. 3arxiv.org/abs/2306.01293
- [23]Atsuyuki Miyai, Qing Yu, Go Irie, and Kiyoharu Aizawa. Gl-mcm: Global and local maximum concept matching for zero-shot out-of-distribution detection. International Journal of Computer Vision, 133:3586–3596, 2025. 3, 7arxiv.org/abs/2304.04521
- [24]Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In Proceedings of the 38th International Conference on Machine Learning, pages 8748–8763, 2021. 3arxiv.org/abs/2103.00020
- [25]Shyam Nandan Rai, Francesco Di Salvo, Sebastian Doerrich, and Christian Ledig. Layer selection in vlms for zero-shot ood detection via multi-resolution entropy estimation. In Medical Image Computing and Computer Assisted Intervention – MICCAI 2026 Workshops and Challenges, 2026. 1, 4, 6, 7arxiv.org/abs/2609.08524
- [26]Yiyou Sun, Chuan Guo, and Yixuan Li. React: Out-of-distribution detection with rectified activations. In Advances in Neural Information Processing Systems, 2021. 3arxiv.org/abs/2111.12797
- [27]Yiyou Sun, Yifei Ming, Xiaojin Zhu, and Yixuan Li. Out-of-distribution detection with deep nearest neighbors. In International Conference on Machine Learning, pages 20827–20840. PMLR, 2022. 3arxiv.org/abs/2204.06507
- [28]Haoqi Wang, Zhizhong Li, Litong Feng, and Wayne Zhang. Vim: Out-of-distribution with virtual-logit matching. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4921–4930, 2022. 3arxiv.org/abs/2203.10807
- [29]Hualiang Wang, Yi Li, Huifeng Yao, and Xiaomeng Li. Clipn for zero-shot ood detection: Teaching clip to say no. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1802–1812, 2023. 3arxiv.org/abs/2308.12213
- [30]John R. Zech, Marcus A. Badgeley, Manway Liu, Anthony B. Costa, Joseph J. Titano, and Eric Karl Oermann. Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: A cross-sectional study. PLOS Medicine, 15 (11):e1002683, 2018. 1DOI
- [31]Fanhu Zheng, Zhen Cheng, Fei Zhu, Hongxin Wei, and Xu-Yao Zhang. Local-prompt: Extensible local prompts for few-shot out-of-distribution detection. In International Conference on Learning Representations, 2025. 3
- [32]Sheng Zhang, Yanbo Xu, Naoto Usuyama, Hanwen Xu, Jaspreet Bagga, Robert Tinn, Sam Preston, Rajesh Rao, Mu Wei, Naveen Valluri, et al. A multimodal biomedical foundation model trained from fifteen million image-text pairs. NEJM AI, 2(1):AIAo2400640, 2025. 1, 4, 6DOI
- [33]Yabin Zhang and Lei Zhang. Adaneg: Adaptive negative proxy guided ood detection with vision-language models. In Advances in Neural Information Processing Systems, 2024. 3arxiv.org/abs/2410.20149
- [34]Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. International Journal of Computer Vision, 130(9):2337–2348, 2022. 3DOI


