BOOSTING OUT-OF-DISTRIBUTION DETECTION WITH MULTIPLE PRE-TRAINED MODELS Anonymous

Abstract

Out-of-Distribution (OOD) detection, i.e., identifying whether an input is sampled from a novel distribution other than the training distribution, is a critical task for safely deploying machine learning systems in the open world. Recently, post hoc detection utilizing pre-trained models has shown promising performance and can be scaled to large-scale problems. This advance raises a natural question: Can we leverage the diversity of multiple pre-trained models to improve the performance of post hoc detection methods? In this work, we propose a detection enhancement method by ensembling multiple detection decisions derived from a zoo of pretrained models. Our approach uses the p-value instead of the commonly used hard threshold and leverages a fundamental framework of multiple hypothesis testing to control the true positive rate of In-Distribution (ID) data. We focus on the usage of model zoos and provide systematic empirical comparisons with current state-ofthe-art methods on various OOD detection benchmarks. The proposed ensemble scheme shows consistent improvement compared to single-model detectors and significantly outperforms the current competitive methods. Our method substantially improves the relative performance by 65.40% and 26.96% on the CIFAR10 and ImageNet benchmarks.

1. INTRODUCTION

Deep neural networks have achieved empirical success in many applications, but generalization robustness has always been a thorny problem in deep learning. A sophisticated and well-trained deep neural network can provide excellent test performance on identically distributed (ID) test data but may fail to make accurate predictions on inputs from outside the training distribution Nguyen et al. (2015) . This poses a big obstacle to the generalization of deep neural network models. Especially in safety-critical applications, it is better to identify out-of-distribution (OOD) inputs ahead of time rather than letting the model make predictions that may be unreliable. On the basis of pre-trained deep neural networks, many recent works on post hoc OOD detection have proposed diverse score functions to distinguish OOD samples utilizing the output probability, logits, gradients, and features of the pre-trained classifier. At the same time, some works also propose new training strategies to encourage the network to learn more features that may not be relevant to the OOD classification task. For example, MSP (Hendrycks & Gimpel, 2017) uses the maximum softmax probability, Energy score (Liu et al., 2020) considers the logits, and GradNorm (Huang et al., 2021) employs the vector norm of gradients. Based on these frameworks, several improved methods such as ODIN (Liang et al., 2018) , Adjusted Energy Score (Lin et al., 2021 ), ReAct (Sun et al., 2021) are proposed to enhance the performance of OOD detection. These score functions above measure the similarity between a test input and the training (ID) data through pretrained feature extractors or classifiers. There are also many distance-based algorithms that directly quantify the distance of samples in the embedding space extracted from a pre-trained model and regard a test input as an OOD sample when it is far from the ID data. In general, the pre-trained models focus on the features related to classification tasks and the learnt representation may be insufficiently rich for OOD detection. Therefore, researchers have proposed ideas such as contrastive learning (Winkens et al., 2020; Tack et al., 2020) et al., 2018; Papadopoulos et al., 2021) or other auxiliary artificially synthesized data (Lee et al., 2017) and auxiliary loss function (Vyas et al., 2018) to encourage models to learn high-level, taskagnostic and comprehensive features, which makes the model more robust and efficient in the downstream detection task. These models trained with different architectures and training strategies can extract diverse features that may complement each other well. So, a natural question is raised: Can we leverage the diversity of multiple pre-trained models to improve the performance of post hoc OOD detectors? To answer this question, we first build a model zoo that captures as many properties of the input as possible and remains sensitive to distributional changes. Then we reformulate the OOD detection task to check whether there exists a model in the model zoo that can identify the test input as an OOD sample. Section 3.1 shows that the naive ensemble of multiple OOD detection decisions cannot maintain the true positive rate of the ID data (TPR). Therefore, we propose an ensemble scheme to integrate the results of multiple OOD detectors and provide theoretical guarantees that our method can keep TPR at the target level. In Section 4, we also report the empirical TPR of our method, which is close to the target TPR level. Ensembling is not new to OOD detection. et al., 1999) . In this work, we develop a simple and fundamental ensemble scheme for using model zoos in OOD detection and name our method Zoo-based OOD Detection Enhancement (ZODE). Our method directly estimates the p-values according to its definition and employs the Benjamini-Hochberg procedure (Benjamini & Hochberg, 1995) to control TPR. Then, we provide theoretical guarantees and empirical validation to show that ZODE can maintain the TPR close to its target level. On the other hand, we focus on the settings of the model zoo and conduct systematic experiments to demonstrate the superiority of our approach. First, we show that ZODE can consistently improve current OOD detectors. Second, by comparing single-model detectors with the ZODE-ensembled detector, we find that ZODE can exploit the diversity of multiple pretrained models and leverage complementarity among single-model detectors. Finally, our approach significantly improves current SOTA performance. We summarize our contributions as follows: • We provide novel insights into OOD detection from the perspective of the model zoo. We propose an enhancement scheme, ZODE, for OOD detection by exploiting the diversity of pre-trained models. The proposed method is inspired by a simple and fundamental framework of multiple hypothesis testing. Our theoretical results and experiments clearly show that ZODE can leverage the complementarity among single-model detectors to improve performance. • We point out that the naive ensemble of multiple OOD detectors leads to lower TPR. Then we provide theoretical analysis and empirical validation to demonstrate that our proposed method can maintain TPR well under the settings of the model zoo. • Extensive experiments show that our method can effectively and consistently improve the power of identifying OOD samples. On a commonly used CIFAR10 benchmark, our method significantly improves the SOTA result of the average false positive rate from 11.07% to 3.83%. For a challenging OOD detection task based on ImageNet, we show



Lee et al. (2018) assumes the conditional distribution of features given the class label is a Gaussian distribution and derives a confidence score based on the Mahalanobis distance. SSD (Sehwag et al., 2020) considers selfsupervised pre-training and a Mahalanobis distance. Tack et al. (2020) uses contrastive learning with distributionally-shifted augmentations for pre-training and proposes a detection score specific to their training scheme. Sun et al. (2022) studies the nearest-neighbor distance and demonstrates the efficacy of non-parametric modeling of the feature distribution for OOD detection tasks.The performance of post hoc detection highly depends on the quality of pre-training. The most commonly used model architectures in OOD detection include convolutional networks such as ResNet(He et al., 2016), DenseNet (Huang et al., 2017)  andWide-ResNet (Zagoruyko & Komodakis, 2016), and of course Transformer models such as Swin(Liu et al., 2022)  orViT (Dosovitskiy et al., 2021).

, adversarial training Biggio & Roli (2018); Miller et al. (2020); Chalapathy & Chawla (2019) , outlier exposure (Hendrycks

