Source-linked AI summary
Exploring the Limits of Out-of-Distribution Detection
Stanislav Fort, Jie Ren, Balaji Lakshminarayanan
TL;DR
Near-OOD detection remains difficult because semantically close outliers are hard to distinguish reliably. The paper evaluates fine-tuned pre-trained transformers and outlier-exposure variants across modalities, including a zero-shot CLIP approach using outlier class names. These methods improve reported near-OOD performance, including CIFAR-100 versus CIFAR-10 from 85% to 96% AUROC without outlier exposure and 99% with it.
Problem
Near-OOD detection has low reported performance despite its importance for safely deploying neural networks under distribution shift.
Method
The paper fine-tunes large-scale pre-trained transformers and studies few-shot, labeled-outlier, and class-name-only outlier exposure for OOD detection.
Results
Pre-trained transformers improve near-OOD benchmarks across vision and genomics, while CLIP uses outlier class names alone for zero-shot OOD detection.
Takeaways & Limitations
The findings support pre-trained transformers and limited outlier information as effective ways to raise OOD detection performance toward ideal results.
Takeaways & Limitations
The baseline training setting assumes no access to OOD data, while few-shot exposure assumes a small number of known outlier examples.
Abstract
from arXiv · showhide
Near out-of-distribution detection (OOD) is a major challenge for deep neural networks. We demonstrate that large-scale pre-trained transformers can significantly improve the state-of-the-art (SOTA) on a range of near OOD tasks across different data modalities. For instance, on CIFAR-100 vs CIFAR-10 OOD detection, we improve the AUROC from 85% (current SOTA) to more than 96% using Vision Transformers pre-trained on ImageNet-21k. On a challenging genomics OOD detection benchmark, we improve the AUROC from 66% to 77% using transformers and unsupervised pre-training. To further improve performance, we explore the few-shot outlier exposure setting where a few examples from outlier classes may be available; we show that pre-trained transformers are particularly well-suited for outlier exposure, and that the AUROC of OOD detection on CIFAR-100 vs CIFAR-10 can be improved to 98.7% with just 1 image per OOD class, and 99.46% with 10 images per OOD class. For multi-modal image-text pre-trained transformers such as CLIP, we explore a new way of using just the names of outlier classes as a sole source of information without any accompanying images, and show that this outperforms previous SOTA on standard vision OOD benchmark tasks.
1 Introduction
Near-OOD detection is especially difficult when outliers are semantically close to in-distribution classes, limiting safe deployment. The paper shows that pre-trained transformers and outlier exposure substantially improve detection across modalities.
- Challenge: Near-OOD detection is harder than far-OOD detection because outliers are semantically closer to in-distribution classes.For CIFAR-100, CIFAR-10 is a near-OOD task, whereas SVHN is far-OOD.
- Core approach: Pre-trained transformers improve near-OOD detection, with fine-tuned representations better suited than those from a ResNet trained only on CIFAR-100.The paper attributes this suitability intuitively to reduced vulnerability to shortcut learning.
- Core approach: Few-shot outlier exposure further improves detection by using a small number of known outlier examples, including outlier class labels when available.The paper also explores using only outlier class names with CLIP, without accompanying images.
- Results: 96% AUROC is achieved on CIFAR-100 versus CIFAR-10 with ViT, compared with 85% current SOTA; genomics improves from 66% to 77% with BERT.With 10 labeled examples per class, the reported AUROC reaches 99% on CIFAR-100 versus CIFAR-10 and 86% on genomics.
2 Background and Related work
The paper frames OOD detection through in-distribution and out-of-distribution datasets, distinguishes near- from far-OOD settings, and reviews confidence, embedding-distance, outlier-exposure, and transformer-based approaches.
- Problem setup: The framework separates in-distribution data D_in from out-of-distribution data D_out, whose label sets are disjoint.Near-OOD and far-OOD tasks differ according to how different D_out is from D_in.
- Problem setup: The baseline training scenario uses only D_in, while few-shot outlier exposure adds a small number of OOD examples to training.The test set evaluates OOD performance using AUROC.
- OOD methods: Maximum softmax probability uses the largest predicted class probability as the OOD confidence score and serves as an ideal baseline because of its simplicity.The passage describes MSP as slightly worse than other techniques while retaining useful performance.
- OOD methods: Mahalanobis detection fits Gaussian distributions to class-conditional embeddings and uses distance from those distributions to detect OOD inputs.The embedding can be taken from the penultimate layer before logits are computed.
- OOD methods: Outlier exposure trains classifiers using known outliers, commonly assigning them a uniform label distribution or a separate outlier class.Using known outlier labels rather than assigning all outliers to one class can further improve detection.
- Pre-trained transformers: Pre-training followed by fine-tuning is used across transformer architectures, including ViT for images and CLIP for image-text representations.CLIP enables the paper’s zero-shot OOD method using shared image-text embeddings.
- Pre-trained transformers: Prior work reports that pre-trained transformers improve OOD detection in NLP, while this paper focuses on vision and genomics near-OOD benchmarks.The related-work discussion also situates the paper among studies of transformer robustness to perturbations and distribution shift.
3 Near-OOD detection on image classification benchmarks
Pre-trained ViTs improve near-OOD detection on CIFAR benchmarks, and few-shot outlier exposure further raises performance when only a small number of known outliers are available.
- Fine-tuning the Vision Transformer: ViT achieves higher AUROC than BiT in both CIFAR OOD directions, while MLP-Mixer also outperforms BiT.These comparisons use ImageNet-21k-pre-trained models fine-tuned on the in-distribution task.
- Fine-tuning the Vision Transformer: Near-OOD detection is emphasized because semantic similarity makes CIFAR-100 versus CIFAR-10 difficult, whereas far-OOD benchmarks reach around 98% AUROC or higher.The paper reports an estimated human performance of 96% AUROC for the CIFAR-100 versus CIFAR-10 task.
- Few-shot outlier exposure using ViT: Few-shot outlier exposure trains a simple classifier on pretrained embeddings using in-distribution classes and either labeled or collapsed OOD classes.The OOD confidence score is the sum of probabilities assigned to the in-distribution classes.
- Few-shot outlier exposure using ViT: 99% AUROC is reached on CIFAR-100 versus CIFAR-10 with only 1–10 known outliers per class, with fine-tuned embeddings reducing the importance of outlier labels.The method varies the number of known outliers from 1 to 10 examples per OOD class and evaluates both fine-tuned and unfine-tuned transformers.
4 Near OOD detection of genomic sequences
Transformer pre-training and fine-tuning improve near-OOD detection for genomic sequences, and few-shot exposure to known outliers provides an additional performance gain.
- Genomics OOD benchmark: The genomics benchmark targets near-OOD detection for bacteria identification, where 60–80% of real sequencing data may come from unknown classes.Previous 1D CNN results reached 66.14% AUROC with MSP and 62.41% with Mahalanobis distance.
- Unsupervised BERT pre-training and supervised fine-tuning: Unsupervised BERT pre-training masks 15% of characters in unlabeled genomic sequences and predicts them before supervised fine-tuning.The transformer uses 8 heads, 6 layers, and embedding dimension 512.
- Unsupervised BERT pre-training and supervised fine-tuning: 77.49% AUROC with Mahalanobis distance improves on 64.75%, while MSP rises from 65.84% to 73.53% after transformer pre-training and fine-tuning.In-distribution accuracy also increases from 85.93% to 89.84%.
- Genetic distance and OOD performance: AUROC is evaluated against minimum genetic distance across 60 OOD classes, with stronger positive distance–AUROC relationships for pre-train-plus-fine-tune methods than the baseline.The distance is computed between each OOD class and its nearest in-distribution class.
- Few-shot outlier exposure: OOD AUROC increases from 76.73% to 88.48% when the genomics model is exposed to a small number of OOD examples.Embeddings from the fine-tuned model outperform embeddings from the model without fine-tuning.
5 Using candidate labels with multi-modal text-image models such as CLIP
The paper introduces zero-shot OOD detection with CLIP by adding candidate labels for OOD classes alongside in-distribution labels. Image–label similarities become probabilities whose in-distribution mass serves as the OOD confidence score, outperforming prior SOTA without image fine-tuning.
- Zero-shot outlier exposure: CLIP uses image–text embeddings to compare each image with candidate in-distribution and OOD class labels.The method uses the similarity between an image embedding and each candidate text embedding as components of an image representation.
- Zero-shot outlier exposure: Zero-shot outlier exposure adds OOD class names as candidate labels even when no OOD images are available.This is proposed as a weaker form of outlier exposure based only on semantic knowledge of OOD classes.
- Scoring procedure: Each image’s candidate-label similarities are converted with softmax into probabilities split between in-distribution and OOD label groups.The score uses the summed probability assigned to the in-distribution group.
- Scoring procedure: The OOD confidence score is scoreoe(x) = p(in|x), where p(in|x) is the summed probability over in-distribution labels.The complementary OOD probability satisfies p(in|x) + p(out|x) = 1.
- Results: CLIP with OOD candidate labels outperforms previous SOTA in zero-shot OOD detection without fine-tuning on either dataset.The comparison uses a baseline with only in-distribution class names and a proposed variant that also uses OOD class names.
6 Conclusion
The paper addresses near-OOD detection with fine-tuned pre-trained transformers, few-shot outlier exposure, and multimodal label-based exposure. These approaches improve results across visual and genomics benchmarks and achieve 94.7% AUROC in CLIP’s zero-shot setting.
- Conclusion: Fine-tuned pre-trained transformers and few-shot outlier exposure improve near-OOD detection across visual and genomics benchmarks.The paper reports improvements both without outlier exposure and when known outliers are used.
- Conclusion: 99% AUROC is achieved on CIFAR-100 versus CIFAR-10 with outlier exposure, compared with 96% without outlier exposure.The conclusion describes the 99% result as essentially closing the gap between SOTA and ideal performance.
- Conclusion: 88% AUROC is achieved on the genomics benchmark with outlier exposure, compared with 77% using BERT without outlier exposure.The reported SOTA baseline for this benchmark is 66%.
- Conclusion: CLIP enables a weaker form of outlier exposure using only OOD input names and achieves 94.7% AUROC in zero-shot classification.This setting uses no accompanying OOD images.
A Measuring human performance on CIFAR-100 vs CIFAR-10 OOD task
The paper measures human performance on near-OOD detection by asking users to identify CIFAR-10 images among randomly presented CIFAR-10 and CIFAR-100 test images. Users select images by familiar class semantics without training examples, reaching 95.90% weighted AUROC.
- Human benchmarking: The human benchmark presents randomly chosen CIFAR-10 and CIFAR-100 test images and asks users to select images they believe are in-distribution.Users view a fixed number of images through a graphical user interface.
- Human benchmarking: Users may select images belonging to any of the 10 CIFAR-10 in-distribution classes.The interface shows 20 images at a time and then presents another randomly chosen group.
- Human benchmarking: Participants perform the task without training-set exposure or class examples, relying on class names and familiarity with their semantic concepts.The CIFAR-10 labels include airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck.
- Results: 95.90% weighted AUROC is obtained for the CIFAR-10 / CIFAR-100 distinguishing task.The average is weighted by the number of images in each trial.
B Visualizing the effect of outlier exposure on fine-tuned pre-trained models
The paper visualizes how outlier exposure changes the embedding space and Mahalanobis OOD scores for a ViT fine-tuned on CIFAR-100. Increasing known outlier exposure improves alignment of OOD scoring with the embedding structure.
- Interpretation: Fine-tuned pre-trained-transformer embeddings are well-clustered, allowing a handful of known outliers to improve OOD detection.This interpretation is given as the intuition for the visualization.
- Visualization: Figure 9 visualizes Mahalanobis OOD scores in a two-dimensional PCA embedding space for CIFAR-100 inliers and CIFAR-10 outliers.The examples include CIFAR-100 bus and pickup truck classes and the CIFAR-10 automobile class.
- Visualization: Increasing outlier exposure makes the OOD outlier scores better aligned in the embedding visualization.The figure compares progressively greater amounts of outlier exposure from left to right.
C Additional results for visual OOD detection
Additional visual OOD results show strong performance across datasets, with especially high AUROC on far-OOD tasks and substantial gains on harder Places365 and CIFAR-100 versus CIFAR-10 benchmarks. Higher in-distribution accuracy and larger ViT models are associated with better OOD performance.
- The visual evaluation uses AUROC, AUPRC, and false positive rate at N% true positive rate, treating OOD examples as positives.The benchmark suite includes CIFAR, DTD, Places365, and SVHN test sets.
- Around 98% or higher AUROC is achieved on the far-OOD SVHN and Textures tasks.
- 93.9% AUROC is achieved on CIFAR-100 versus Places365, compared with 82% reported by Winkens et al.
- 98.5% AUROC is achieved on CIFAR-10 versus Places365, compared with 95% reported by Winkens et al.
- Scaling of OOD performance with in-distribution test accuracy: Higher in-distribution test accuracy corresponds to higher OOD detection AUROC during ViT fine-tuning.The relationship also holds for larger ViT models; augmentation produces the same relationship but slower convergence.
- Scaling of OOD performance with in-distribution test accuracy: Larger ViT models and ensembles improve CIFAR-100 versus CIFAR-10 AUROC from 96.23% to approximately 98%.
C.2 Additional results for zero-shot OOD detection using CLIP
The CLIP zero-shot analysis compares in-distribution class names with opposite concatenated prompts using no accompanying outlier images. This alternative is above random but does not significantly improve over using only in-distribution names.
- CLIP zero-shot OOD detection using opposite concatenated prompts is above random but not significantly better than using only in-distribution names.
- Table 9 reports zero-shot results for image-text multimodal models using class names as candidate labels.The comparison extends the setup in Table 5.
C.3 Qualitative analysis of OOD detection using ViT
Qualitative analyses indicate that ViT OOD mistakes often reflect mislabeled data, semantic overlap, or visually plausible similarities rather than arbitrary errors. CIFAR-10 and SVHN provide distinct examples of these failure modes.
- CIFAR-10 mistakes include mislabeled fox and kangaroo images, plus vehicles whose classes overlap with CIFAR-100 categories.Some vehicle distinctions may be unclear even to humans.
- SVHN digits with wiggly, worm-like shapes can resemble CIFAR-100 images in the learned embedding space.Some mistakes also arise from cloud-like appearance caused by deep blue backgrounds and low resolution.
- Overall, the model’s CIFAR-10 and SVHN mistakes are described as semantically meaningful and plausible to humans.CIFAR vehicle categories are harder to distinguish at 32×32 resolution.
- The most confusing CIFAR-10 and CIFAR-100 examples are selected by low Mahalanobis distance and closest embedding vectors.
D Additional results for genomics OOD detection
The genomics appendix reports additional OOD results and few-shot outlier-exposure evaluations, alongside qualitative visualizations of difficult CIFAR class pairs. The accompanying tables summarize repeated-run variability for the genomics experiments.
- Tables 10 and 11 report additional genomics OOD detection and few-shot outlier-exposure results.
- Table 10 evaluates genomics OOD detection with pre-trained BERT fine-tuned on the in-distribution training set.Error bars are standard deviations over three runs.
- Table 11 reports few-shot outlier exposure for genomics, with error bars representing standard deviations over three runs.
- Figures 13 and 14 visualize hard-to-distinguish vehicle and animal class pairs between CIFAR-10 and CIFAR-100.