betaFeedback

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.

Entropy-based layer selection and layer–prompt response patterns

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.

Overview of CLASP

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 DID={xi}i=1N\mathcal{D}_{\mathrm{ID}} = \{x_i\}_{i=1}^{N} denote the unlabeled ID calibration set and P={pk}k=1K\mathcal{P} = \{p_k\}_{k=1}^{K} the predefined ID textual prompts. Given a frozen VLM with visual and text encoders fvf_v and ftf_t, we extract projected visual embeddings {vℓ(x)}ℓ=1L\{v_{\ell}(x)\}_{\ell=1}^{L} from all LL visual layers and text embeddings tk=ft(pk)t_k = f_t(p_k). Their image–text similarity is defined as

Zℓk(x)=sim⁡(vℓ(x),tk),(1)Z_{\ell k}(x) = \operatorname{sim}\left(v_{\ell}(x), t_k\right), \tag*{(1)}

where sim⁡(⋅,⋅)\operatorname{sim}(\cdot,\cdot) follows the VLM-specific projection and normalization conventions. Collecting these responses yields the layer–prompt similarity matrix Z(x)∈RL×K\mathbf{Z}(x) \in\mathbb{R}^{L \times K}, where each row zℓ(x)∈RK\mathbf{z}_{\ell}(x) \in\mathbb{R}^{K} retains the individual similarities of layer ℓ\ell 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 a(x)∈Rdv\mathbf{a}(x) \in\mathbb{R}^{d_v} denote the final-layer visual embedding compressed using ID-fitted, unwhitened PCA, with dv=32d_v = 32. Starting from the mandatory final-layer anchor R1={L}\mathcal{R}_1 = \{L\}, we evaluate each remaining candidate layer ℓ\ell using

I(ℓ∣R)=1KI(zℓ;a∣ZR)=12Klog⁡det⁡(Σ^ℓ∣R)det⁡(Σ^ℓ∣R,a),(2)\begin{aligned} \mathcal{I}(\ell\mid\mathcal{R}) = \frac{1}{K} I\left(\mathbf{z}_{\ell}; \mathbf{a} \mid\mathbf{Z}_{\mathcal{R}}\right) \\ &= \frac{1}{2K} \log\frac{\det\left(\widehat{\boldsymbol{\Sigma}}_{\ell\mid\mathcal{R}}\right)}{\det\left(\widehat{\boldsymbol{\Sigma}}_{\ell\mid\mathcal{R},\mathbf{a}}\right)}, \tag*{(2)} \end{aligned}

where ZR\mathbf{Z}_{\mathcal{R}} 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:

ℓ∗=arg⁡max⁡ℓ∉R I(ℓ∣R),R←R∪{ℓ∗}.(3)\ell^{*} = \underset{\ell\notin\mathcal{R}}{\arg\max}\ \mathcal{I}(\ell\mid\mathcal{R}), \qquad\mathcal{R} \leftarrow\mathcal{R} \cup\{\ell^{*}\}. \tag*{(3)}

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 dv=32d_v = 32. We first construct the final-layer visual anchor using ID-fitted, unwhitened PCA:

a(x)=ULT(vL(x)−v‾L)∈Rdv,(4)\mathbf{a}(x) = \mathbf{U}_{L}^{\mathsf{T}}\left(\mathbf{v}_{L}(x) - \overline{\mathbf{v}}_{L}\right) \in\mathbb{R}^{d_v}, \tag*{(4)}

where UL\mathbf{U}_{L} contains the leading ID principal directions. To identify empirically stable anchor coordinates, we compare the full-calibration covariance Σ^a\widehat{\boldsymbol{\Sigma}}_{a} with covariances estimated after deleting each calibration source group g∈Gg \in\mathcal{G}. We define the perturbation radius as

τa=max⁡g∈G∥Σ^a−Σ^a(−g)∥F.(5)\tau_a = \max_{g \in\mathcal{G}} \left\lVert\widehat{\boldsymbol{\Sigma}}_{a} - \widehat{\boldsymbol{\Sigma}}_{a}^{(-g)} \right\rVert_{F}. \tag*{(5)}

Anchor directions whose covariance eigenvalues exceed τa\tau_a form the protected set J\mathcal{J}, leaving dv−∣J∣d_v - |\mathcal{J}| dimensions available for complementary visual directions.

For each candidate layer ℓ\ell examined in CMI order, we obtain its ID-fitted PCA representation bℓ(x)∈Rdv\mathbf{b}_{\ell}(x) \in\mathbb{R}^{d_v} and remove the information linearly predictable from protected anchor coordinates and previously admitted visual residuals. Let ψS(x)\boldsymbol{\psi}_{S}(x) denote the previously admitted residual coordinates and cS(x)=[aJ(x);ψS(x)]\mathbf{c}_{S}(x) = [\mathbf{a}_{J}(x); \boldsymbol{\psi}_{S}(x)] their conditioning vector. The conditional visual residual is

rℓ(x)=bℓ(x)−bˉℓ−Σ^bcΣ^cc−1(cS(x)−cˉS),(6)\mathbf{r}_{\ell}(x) = \mathbf{b}_{\ell}(x) - \bar{\mathbf{b}}_{\ell} - \hat{\boldsymbol{\Sigma}}_{bc}\hat{\boldsymbol{\Sigma}}_{cc}^{-1}\left(\mathbf{c}_{S}(x) - \bar{\mathbf{c}}_{S}\right), \tag*{(6)}

where the regression coefficients are estimated exclusively from unlabeled ID data. The residual covariance is eigendecomposed as Σ^rℓ=Qℓdiag⁡(γℓ)QℓT\hat{\boldsymbol{\Sigma}}_{\mathbf{r}_{\ell}} = \mathbf{Q}_{\ell}\operatorname{diag}(\boldsymbol{\gamma}_{\ell})\mathbf{Q}_{\ell}^{\mathsf{T}}. Analogously to Eq. (5), we estimate a source-deletion perturbation radius τℓ\tau_{\ell} 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 γℓj>τℓ\gamma_{\ell j} > \tau_{\ell} 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 S⋆S^\star 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 S⋆S^\star denote the spectrally admitted layers, with M=∣S⋆∣M = |S^\star|. We construct the matched layer–prompt representation by retaining all KK prompt responses from each admitted layer:

ϕp(x)=vec⁡r(ZS⋆(x))∈RMK.(7)\phi_p(x) = \operatorname{vec}_{r}\left(Z_{S^\star}(x)\right) \in\mathbb{R}^{MK}. \tag*{(7)}

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 vS⋆(x)\mathbf{v}_{S^\star}(x), we obtain

ϕv(x)=US⋆⊤(vS⋆(x)−vˉS⋆)∈Rdv,dv=32,(8)\phi_v(x)=\mathbf{U}_{S^\star}^{\top}\left(\mathbf{v}_{S^\star}(x)-\bar{\mathbf{v}}_{S^\star}\right)\in\mathbb{R}^{d_v},\qquad d_v=32, \tag*{(8)}

where US⋆\mathbf{U}_{S^\star} 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

h(x)=[ϕp(x)ϕv(x)]∈RD,D=MK+dv.(9)\mathbf{h}(x)=\begin{bmatrix}\phi_p(x)\\\phi_v(x)\end{bmatrix}\in\mathbb{R}^{D},\qquad D=MK+d_v. \tag*{(9)}

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 h(x)\mathbf{h}(x) using its ID calibration mean μh\boldsymbol{\mu}_h and standard deviation σh\boldsymbol{\sigma}_h, obtaining h~(x)=(h(x)−μh)/(σh+ϵ)\widetilde{\mathbf{h}}(x)=(\mathbf{h}(x)-\boldsymbol{\mu}_h)/(\boldsymbol{\sigma}_h+\epsilon). We then fit a single Gaussian N(μ,Σ)\mathcal{N}(\boldsymbol{\mu},\mathbf{\Sigma}) to the standardized ID representations. Given their empirical covariance S\mathbf{S}, we apply Ledoit–Wolf shrinkage [14] with numerical ridge regularization:

Σ^=(1−ρ^)S+ρ^tr⁡(S)DID+λID,(10)\widehat{\mathbf{\Sigma}}=(1-\hat{\rho})\mathbf{S}+\hat{\rho}\frac{\operatorname{tr}(\mathbf{S})}{D}\mathbf{I}_D+\lambda\mathbf{I}_D, \tag*{(10)}

where ρ^∈[0,1]\hat{\rho}\in[0,1] is the shrinkage coefficient and λ>0\lambda>0 ensures numerical stability. For an unseen image xx, the OOD anomaly score is its squared Mahalanobis distance from the learned ID distribution:

sCLASP(x)=(h~(x)−μ)⊤Σ^−1(h~(x)−μ).(11)s_{\mathrm{CLASP}}(x)=\left(\widetilde{\mathbf{h}}(x)-\boldsymbol{\mu}\right)^{\top}\widehat{\mathbf{\Sigma}}^{-1}\left(\widetilde{\mathbf{h}}(x)-\boldsymbol{\mu}\right). \tag*{(11)}

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 (↑\uparrow) and FPR@95 (↓\downarrow), 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 ↑\uparrow / FPR@95 ↓\downarrow (in %).

Ranking criterionMIDOG near Selected layersMIDOG near AUROC/FPR@95Chest L5 semantic Selected layersChest 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 ↑\uparrow and FPR@95 ↓\downarrow 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.

MethodExplicit class-identity useExt. OODAdditional TrainingUniMedCLIP Near-OOD AUROC ↑\uparrowUniMedCLIP Near-OOD FPR@95 ↓\downarrowUniMedCLIP Far-OOD AUROC ↑\uparrowUniMedCLIP Far-OOD FPR@95 ↓\downarrowBioMedCLIP Near-OOD AUROC ↑\uparrowBioMedCLIP Near-OOD FPR@95 ↓\downarrowBioMedCLIP Far-OOD AUROC ↑\uparrowBioMedCLIP Far-OOD FPR@95 ↓\downarrow
MCM [21]✗✗✗47.2591.9581.6451.5640.0897.6136.95100.00
SRE [20]✗✗✗29.1099.7097.1016.6032.1097.3099.801.30
MRE [25]✗✗✗54.6094.4097.4013.4036.40100.0099.502.70
GL-MCM [23]✗✗✗47.5392.9881.2953.3142.1996.5554.2797.08
PROTON+ [4]✓✗✗47.0095.1474.9267.0248.8895.7324.3199.92
Voyager [5]✓✓✓––––––––
V-Mahalanobis✗✗✗80.4847.0199.990.1072.9762.2499.671.07
CLASP (ours)✗✗✗87.5430.88100.000.0070.6366.4799.461.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 ↑\uparrow / FPR@95 ↓\downarrow (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.

BackboneMethodChest X-ray: L1 (2 ID prompts) SemanticChest X-ray: L1 (2 ID prompts) CovariateChest X-ray: L1 (2 ID prompts) Far-OODChest X-ray: L5 (8 ID prompts) SemanticChest X-ray: L5 (8 ID prompts) CovariateChest X-ray: L5 (8 ID prompts) Far-OODBrain MRI Near-OOD
UniMedCLIPMCM [21]54.20/89.6746.76/87.5027.56/99.6754.18/77.5078.43/46.5084.62/43.0038.90/100.00
SRE [20]64.32/87.5020.17/99.6782.81/86.3359.51/89.0093.10/30.33100.00/0.0011.50/100.00
MRE [25]64.32/87.5020.17/99.6782.81/86.3360.37/89.7588.25/48.08100.00/0.0015.20/100.00
GL-MCM [23]55.36/92.8347.71/91.0033.18/99.3354.46/79.3381.18/55.3391.52/34.0040.40/95.00
PROTON+ [4]61.39/88.1393.88/29.0091.52/37.9349.90/92.1388.50/36.5396.86/9.5335.90/100.00
Voyager [5]52.42/92.8325.29/98.1731.08/98.3352.63/88.5072.47/74.6774.33/71.17–
V-Mahalanobis62.00/86.6799.97/0.00100.00/0.0062.00/86.6799.97/0.00100.00/0.0051.60/92.50
CLASP (ours)66.44/85.0099.91/0.17100.00/0.0065.40/87.8399.89/0.00100.00/0.0099.97/0.00
BioMedCLIPMCM [21]54.50/94.6756.44/79.0056.10/91.1757.05/91.5054.50/89.3369.58/71.3356.30/100.00
SRE [20]51.50/93.8316.21/99.8399.41/0.8355.72/93.8362.75/79.5099.84/0.3314.10/100.00
MRE [25]51.50/93.8316.21/99.8399.41/0.8357.24/92.2580.24/50.5099.97/0.0814.10/100.00
GL-MCM [23]55.79/95.5054.39/82.3351.05/93.1754.90/92.8350.42/92.8376.18/57.5057.90/95.00
PROTON+ [4]55.57/93.9375.79/67.6391.81/15.2758.00/92.3076.86/56.9091.98/12.7043.00/95.00
Voyager [5]55.88/91.0063.16/75.0017.86/99.8357.81/92.0070.07/80.0019.38/100.00–
V-Mahalanobis53.16/94.8395.67/19.67100.00/0.0053.16/94.8395.67/19.67100.00/0.0072.70/62.50
CLASP (ours)57.34/94.6795.96/20.67100.00/0.0056.75/94.1797.29/14.33100.00/0.00100.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 modelMIDOG nearChest L5 semantic
Full Ledoit–Wolf covariance (ours)87.54/30.8865.40/87.83
Diagonal covariance80.16/49.8258.24/92.83
Identity covariance80.16/49.8258.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.

BenchmarkReference layersAgreement (%)JaccardAUROC/FPR@95
MIDOG near-OOD{3, 8, 12}50.000.7286.74 ±\pm 0.64 / 32.41 ±\pm 1.76
Chest L5 semantic{4, 12}30.000.5465.02 ±\pm 0.84 / 88.20 ±\pm 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 ±\pm 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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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. [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

Paper details

vlnc:W_ke6fk6fm
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents