Fast Decision Boundary based Out-of-Distribution Detector

Litian Liu, Yao Qin

Efficient and effective Out-of-Distribution (OOD) detection is essential for the safe deployment of AI systems. When machine learning models are deployed in the real world, they inevitably encounter data that looks nothing like their training set. Because classifiers will often confidently make meaningless predictions on these OOD samples, detecting them is critical for AI safety in high-stakes domains like autonomous driving or medical diagnosis.

To address this, researchers have introduced fDBD (fast Decision Boundary based Detector), a blazing-fast OOD detector that measures how close a sample's features are to a model's decision boundaries. By using a clever closed-form mathematical estimation, it avoids the heavy computational overhead of existing feature-space methods, resulting in a hyperparameter-free detector that matches state-of-the-art accuracy with virtually zero added inference latency.

The Efficiency-Effectiveness Trade-off

Currently, post-hoc OOD detection methods generally fall into two camps:

  1. Output-space methods: These approaches (like analyzing softmax confidence scores) are fast but ignore the rich, high-dimensional information hidden in the network's internal layers.
  2. Feature-space methods: Techniques like Mahalanobis distance or K-Nearest Neighbors (KNN) are highly accurate but computationally expensive. They usually require building and querying auxiliary models or storing massive datasets of training features during inference.

This paper tackles a fundamental trade-off: How can we leverage the rich information of the feature space without the latency overhead that makes real-time deployment impossible?

The fDBD Approach: Decision Boundaries

The authors propose looking at OOD detection through the lens of decision boundaries. Intuitively, if a model is highly certain about an In-Distribution (ID) sample, its feature representation should sit deep inside a class territory, far away from the boundaries of other classes. Conversely, OOD samples tend to fall closer to the edges of these learned territories.

OOD features tend to fall closer to decision boundaries than ID features, as shown in both the 2D feature space and the distance distribution.

To turn this intuition into a practical detector, the authors developed fDBD based on two core components:

  • Closed-Form Distance Estimation: Calculating the exact distance from a feature to a decision boundary is mathematically complex (non-convex) and usually requires slow, iterative adversarial attacks. The authors derived a closed-form estimation that tightly lower-bounds this distance using just the model's logits and classifier weights. This turns a computation that might take a full second into a constant-time, near-instant calculation.
  • Plug-and-Play Architecture: The method is hyperparameter-free, requires no auxiliary models, and scales linearly with the number of classes and feature dimensions.

Key Insight: The "Deviation" Confounder and Regularization

During their analysis, the authors noticed a tricky geometric phenomenon: as any feature (ID or OOD) moves further away from the center of the training data, its distance to decision boundaries artificially inflates.

Because of this inflation, a highly deviant OOD sample might look like it has the same boundary distance as a normal ID sample. However, if you group samples by their deviation level (how far they are from the training mean), ID and OOD samples become highly separable.

This insight led to the crucial Regularized Scoring step. The fDBD algorithm calculates the average estimated distance to all unpredicted class boundaries and regularizes this score by dividing it by the feature's distance to the mean of the training data. It essentially levels the playing field before comparing boundary distances.

Distributions of average distance to decision boundaries before and after regularization. Regularization significantly improves the separability of ID and OOD samples.

Key Results and Performance

The fDBD method was evaluated across standard ID datasets (CIFAR-10, ImageNet-1k) and various OOD benchmarks (SVHN, iSUN, Places365, Texture, etc.). The results highlight a massive leap in efficiency:

  • Basically Free Inference: On a CIFAR-10 ResNet-18 model, standard inference takes 0.53ms per image. Adding fDBD takes exactly the same time (0.53ms). For context, a KNN approach takes 1.95ms, and iterative boundary estimation takes ~992ms.
  • State-of-the-Art Accuracy: Despite being lightning-fast, fDBD matches or beats heavier baselines. On CIFAR-10, it reduced the False Positive Rate (FPR95) of the standard Maximum Softmax Probability baseline by nearly 30% (a ~48% relative error reduction).
  • Highly Versatile: The method proved effective across different architectures (ResNets, Vision Transformers, DenseNets) and training paradigms (standard Cross-Entropy and Supervised Contrastive Learning). It also stacks perfectly with modern activation shaping techniques like ReAct and ASH.

Limitations and Future Work

While highly effective, the authors note that fDBD's performance degrades slightly when the In-Distribution data undergoes moderate domain shifts (e.g., evaluating on corrupted data like CIFAR-10-C), though it remains largely robust.

Looking forward, the authors suggest that this novel perspective—quantifying model uncertainty via feature-space decision boundaries—could be a powerful tool for adjacent fields, such as improving adversarial robustness and domain generalization.

Summary updated

Abstract

Efficient and effective Out-of-Distribution (OOD) detection is essential for the safe deployment of AI systems. Existing feature space methods, while effective, often incur significant computational overhead due to their reliance on auxiliary models built from training features. In this paper, we propose a computationally-efficient OOD detector without using auxiliary models while still leveraging the rich information embedded in the feature space. Specifically, we detect OOD samples based on their feature distances to decision boundaries. To minimize computational cost, we introduce an efficient closed-form estimation, analytically proven to tightly lower bound the distance. Based on our estimation, we discover that In-Distribution (ID) features tend to be further from decision boundaries than OOD features. Additionally, ID and OOD samples are better separated when compared at equal deviation levels from the mean of training features. By regularizing the distances to decision boundaries based on feature deviation from the mean, we develop a hyperparameter-free, auxiliary model-free OOD detector. Our method matches or surpasses the effectiveness of state-of-the-art methods in extensive experiments while incurring negligible overhead in inference latency. Overall, our approach significantly improves the efficiency-effectiveness trade-off in OOD detection. Code is available at: https://github.com/litianliu/fDBD-OOD.
BibTeX
@inproceedings{liu2024fast,
  author = {Litian Liu and Yao Qin},
  title = {{Fast Decision Boundary based Out-of-Distribution Detector}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=eQaOb4r6YC},
}
Figure