arXiv:2609.08524cs.CVSep 2026

Manuscript Offprint

arXiv:2609.08524

Layer Selection in VLMs for Zero-Shot OOD Detection via Multi-Resolution Entropy Estimation

Shyam Nandan Rai, Francesco Di Salvo, Sebastian Doerrich, Christian Ledig

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

Shyam Nandan Rai, Francesco Di Salvo, Sebastian Doerrich, Christian Ledig

xAILab Bamberg, University of Bamberg, Bamberg, Germany

Out-of-distribution (OOD) detection is crucial for safe deployment of medical AI systems, where domain shifts arise across institutions, acquisition protocols, and patient populations. VLMs enable zero-shot OOD detection by embedding images into a language-aligned latent space, where cross-modal similarity serves as a non-parametric confidence signal for identifying in-distribution samples. Yet existing methods rely almost exclusively on final-layer embeddings, implicitly assuming that the deepest representations are universally optimal. We first show that this assumption does not hold in medical imaging: intermediate layers provide complementary OOD signals, and the optimal representational depth depends on the respective image modality. While prior work selects layer combinations via entropy minimization of normalized histograms, we demonstrate that single-resolution entropy estimation is highly sensitive to binning choices, leading to performance variations of up to 19.3% AUROC. To address this instability, we propose a multi-resolution entropy estimation strategy that aggregates histogram statistics across multiple discretization scales, enabling robust and stable intermediate-layer selection. Across two medical OOD benchmarks, namely MIDOG and OASIS, covering distinct imaging modalities, diverse shift types, and different VLM backbones, our method consistently outperforms state-of-the-art approaches, offering a lightweight and stable solution for zero-shot OOD detection.

Keywords: Out-of-Distribution Detection · Medical VLMs

Website: https://shyam671.github.io/layer-selection-ood/

Contact: shyam.rai@uni-bamberg.de

Figure

1 Introduction

Out-of-distribution (OOD) detection [26] is a critical research problem in healthcare, where models are deployed across diverse institutions, imaging devices, acquisition protocols, and heterogeneous patient populations [23,6,9]. Vision-Language Models (VLMs) [19,27,14] enable zero-shot OOD detection by measuring the alignment between image and text embeddings. This is particularly beneficial because the in-distribution manifold can be characterized through semantically rich textual descriptions, while cross-modal similarity serves as a proxy for prediction confidence. However, existing zero-shot OOD detection methods based on VLMs [18,12] primarily rely on final-layer representations, implicitly assuming that they are universally optimal for OOD detection. This assumption has recently been challenged for VLMs [10], as well as in other domains [25,11,4,16]. De la Jara et al. [10] show for the natural image domain that OOD-discriminative signals are distributed across multiple representational depths within VLMs, rather than being confined to the final layer. In particular, intermediate layers have been shown to capture diverse visual features [20] that complement high-level semantic representations. Despite these findings, a systematic investigation into whether aggregating layer-wise OOD scores can substantially improve detection performance in the context of medical image analysis remains unexplored. We therefore revisit the problem of zero-shot medical

Rai et al.

OOD detection and ask: Can intermediate layer representations be systematically utilized to enhance zero-shot OOD detection across modalities?

To answer this question, we perform a systematic layer-wise analysis of zero-shot OOD detection across multiple medical imaging datasets, presented in Figure 1. Our results reveal that the optimal representational depth is modality-dependent: texture-driven shifts in histopathology [15] are primarily captured in earlier layers, whereas semantic and anatomical shifts in brain MRI [5] benefit from the global contextual representations encoded in deeper layers.

Motivated by these observations, we revisit entropy-based intermediate-layer selection [10] in the context of medical imaging. While originally developed for large-scale natural image benchmarks, we find that its reliance on single-resolution histogram entropy leads to unstable performance in small-scale medical datasets, where discretization sensitivity can degrade AUROC by up to 19.3% (cf. Figure 3). To address this limitation, we propose a multi-resolution entropy estimation strategy that aggregates entropy estimates across multiple discretization scales of histogram, enabling robust and stable layer selection. We evaluate our method on two medical OOD benchmarks using two VLM backbones, covering distinct imaging modalities and varying degrees of distribution shift. Our approach substantially reduces bin-size sensitivity and consistently improves OOD detection performance over state-of-the-art zero-shot baselines, demonstrating strong generalization across backbones and modalities. In summary:

– To the best of our knowledge, we provide the first systematic layer-wise analysis of VLMs for zero-shot OOD detection in medical image analysis, revealing that OOD-discriminative signals emerge at modality-dependent representational depths.

– We identify the instability of single-resolution entropy-based layer selection in data-scarce medical settings and introduce a multi-resolution entropy estimation strategy that yields robust layer selection.

– Extensive experiments across two medical OOD benchmarks and two VLM backbones demonstrate consistent performance improvements over state-of-the-art zero-shot baselines, spanning multiple imaging modalities and distribution shifts.

Figure

Fig. 1. Layer-wise zero-shot OOD detection performance (AUROC, %), using UniMedCLIP. Left: OASIS (brain MRI). Right: MIDOG (histopathology). Each bar corresponds to the OOD detection performance using Maximum Concept Matching (MCM) for the corresponding encoder layer, averaging for both near- and far-OOD shifts. The results demonstrate that the best layer depends on the dataset, i.e., imaging modality. Notably, the final layer does not exhibit the best performance in either case.

References (27)