Score Combining for Contrastive OOD Detection

Edward T. Reehorst, Philip SchniterarXiv 2025 · DOI

Abstract

Detecting Out-of-Distribution (OOD) samples is a fundamental challenge in machine learning. While contrastive learning methods like Contrastive Shifted Instances (CSI) have set new benchmarks, they often rely on heuristic rules to combine multiple pretext task scores. This paper presents a principled statistical framework that replaces these heuristics with a Generalized Likelihood Ratio Test (GLRT). By standardizing diverse scores into empirical $z$-values and applying a "negative-means" hypothesis test, the proposed approach achieves state-of-the-art performance with rigorous false-alarm-rate guarantees.

Introduction

Out-of-Distribution (OOD) detection, also known as novelty or anomaly detection, is the task of identifying whether a test sample belongs to the training distribution (inliers) or represents a novel category. Modern state-of-the-art methods, such as CSI, leverage various image transformations to generate multiple "inlier scores." However, these scores often reside on different scales—for instance, feature norms can range into the hundreds while cosine similarities are bounded between 0 and 1. Previous methods typically combined these signals using heuristic formulas, which lack a formal statistical justification and may not optimally weight the available information.

Methodology

The proposed framework transitions from heuristic ensembling to a rigorous statistical testing pipeline consisting of three primary stages:

1. Standardization via Empirical $z$-values

To handle scores with disparate distributions, the authors first convert raw pretext task scores into $p$-values based on the empirical distribution of the training data. These $p$-values are then mapped to $z$-values following a standard normal distribution. This standardization ensures that for inlier data, scores are centered at zero with unit variance, making them directly comparable.

Transformation of raw scores to standardized z-values and the resulting separation between inliers and novelty samples.

2. The Negative-Means (NM) GLRT

The core of the detection mechanism is a hypothesis test. The null hypothesis ($H_0$) assumes the $z$-values are standard normal. The alternative hypothesis ($H_1$) posits that for OOD samples, the $z$-values will exhibit a negative mean shift of at least $\epsilon$. Because the magnitude of this shift is unknown, a Generalized Likelihood Ratio Test (GLRT) is employed to estimate the most likely shift and produce a single, combined test statistic.

3. Conformal False-Alarm Guarantees

To ensure reliability in practical applications, the system utilizes conformal prediction based on a validation set. This provides a statistical guarantee that the false-alarm rate (FAR) remains below a user-defined threshold with high probability.

Experimental Evaluation

The method was evaluated on standard computer vision benchmarks, including CIFAR-10 and SVHN as inlier sets, against OOD datasets such as LSUN, ImageNet, and CIFAR-100. The researchers conducted both "dataset-vs-dataset" and "leave-one-class-out" experiments.

Key Results

The GLRT-based variants, glrt-CSI and glrt-SupCSI, consistently outperformed their heuristic counterparts. On CIFAR-10, glrt-CSI improved the average AUROC from 0.9528 to 0.9552. More significantly, the Detection Rate (DR) at a 5% False-Alarm Rate for SVHN inliers saw a substantial increase from 75.0% to 84.7%.

Discussion and Insights

A critical finding of this work is the "Negative-Means" intuition: OOD samples tend to perform poorly across most pretext tasks simultaneously. The GLRT effectively captures this consistent downward trend.

Comparison of the GLRT test statistic against classical methods like Stouffer and Fisher, showing the effect of calibration.

Furthermore, the authors observed a "Covariance Paradox." Assuming independence between scores (using an Identity covariance matrix) yielded better results than using the empirical covariance matrix. The analysis suggests that empirical covariance can inadvertently suppress informative "eigen-scores" by over-weighting noise, whereas the Identity matrix preserves the strongest signals.

Conclusion

This research demonstrates that a principled statistical approach to score ensembling can significantly enhance OOD detection performance. While the method's efficacy depends on the quality of the underlying base scores and specific image transformations, it provides a robust foundation for future work. Potential extensions include learning optimal score combinations or developing more complex models for the OOD distribution that move beyond the independence assumption.

Summary updated

BibTeX
@misc{reehorst2025score,
  author = {Edward T. Reehorst and Philip Schniter},
  title = {{Score Combining for Contrastive OOD Detection}},
  year = {2025},
  eprint = {2501.12204},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.12204},
}
Figure