1. Introduction
When machine learning models are deployed in open-world environments, they often encounter inputs from out-of-distribution (OOD) data, which exhibit semantic shifts from id-distribution (ID) data used during training [
1,
2,
3]. It is imperative that models avoid making predictions on OOD data, especially in safety-critical domains [
4,
5], such as autonomous driving and medical diagnosis [
6]. In these fields, making arbitrary predictions on OOD data can lead to catastrophic consequences. This concern has spurred significant research on OOD detection in the field of reliable machine learning in recent years [
7,
8,
9,
10,
11,
12].
OOD detection involves two main tasks: accurately predicting ID data and effectively detecting OOD data [
10,
13,
14]. Existing methods can be broadly categorized into two types based on whether they introduce additional training data [
15]. The first type trains a model using only ID data to achieve accurate classification and then employs post-processing methods based on model outputs to distinguish between ID and OOD data [
16,
17,
18,
19]. For example, [
13,
20] design scoring functions that better capture the distinct patterns of ID and OOD data, [
15,
18] use different distance metrics to differentiate ID and OOD data based on features extracted by the model, and [
13,
21,
22] rely on gradient-based information to make this distinction. However, due to the lack of explicit OOD knowledge, these methods, despite theoretical guarantees, often fall short of achieving powerful OOD detection performance.
The second type of method uses additional auxiliary data to enhance the ability of the pre-trained model to detect OOD data. For instance, refs. [
6,
23] design various OOD data generation methods to create a diverse set of OOD data for model training, while others expand the coverage of OOD data through different methods to improve the ability of the model to detect OOD data [
1,
24]. These methods generally outperform the first category in OOD detection. However, these methods trend focus on acquiring more OOD data for training, with little attention paid to fully leveraging the potential of existing OOD data. Motivated by this gap, in this paper, we analyze the usefulness of different data for model training and propose a method that efficiently utilizes existing data to train the model.
In
Section 3, we empirically demonstrate through experiments the significant variations in the impacts of different data samples on model training. Unlike classical active learning paradigms [
25], which typically prioritize more challenging samples for training, our findings reveal that OOD data correctly classified by a pre-trained model are more beneficial for OOD detection training. Conversely, more difficult OOD samples are found to exert a negative influence on model training.
The samples that the model can confidently and correctly classify, which are referred to as easily distinguishable samples, play a pivotal role during fine-tuning. Consequently, a principled approach for OOD fine-tuning involves preferentially selecting such readily classifiable samples for training. Implementing this strategy necessitates developing a rigorous methodology to systematically assess and identify samples that exhibit higher distinguishability to the model.
Fortunately, prior research conducted by [
1,
26] has shown that pre-trained models exhibit inherent capabilities for OOD detection to a certain extent. Building on this insight, we can use the OOD scores predicted by pre-trained models to identify samples that it can correctly recognize samples based on a certain threshold. By fine-tuning the model using these important samples, we can enhance its OOD detection ability.
In
Section 4, we design an efficient training algorithm named
focus on important samples (FIS) that iteratively performs prediction and training, as illustrated in
Figure 1. This iterative process enables the model to learn from key samples that are more conducive to training. Ultimately, this approach not only ensures accurate classification of ID data but also maximizes its capability to effectively identify OOD data.
We conducted comprehensive and rigorous experiments across a variety of OOD detection scenarios. Consistently across all experimental settings, our method achieved superior OOD detection performance by using only a subset of the data, outperforming methods that utilized the entire dataset. This demonstrates the reliability of our proposed approach in practical applications. Furthermore, we performed extensive ablation studies, which confirmed the robustness of our method.
We summarize the main contributions of this paper as follows:
We empirically analyzed the varying impacts of different data on model training through comparative experiments, demonstrating that samples that the model can correctly identify play a more critical role in the OOD detection fine-tuning stage.
We proposed a highly efficient and targeted method for utilizing training data, which selects samples that are more beneficial to model training based on the OOD scores predicted by the model during the training process.
Through extensive experiments, we validated the efficiency, reliability, and robustness of our proposed method, FIS, in OOD detection training.
The organization of this paper is as follows: in
Section 2, we introduce and explain the key concepts and notations relevant to this study. In
Section 3, we analyze the varying impacts of different data on model performance during the training process. In
Section 4, we propose the FIS algorithm, which efficiently leverages data to optimize training performance. In
Section 5, we conduct extensive experiments to validate the reliability and robustness of our method. Finally, in the last section, we conclude this paper.
2. Preliminary
In this section, we provide a comprehensive introduction to the key concepts relevant to this paper and explain the key notations.
We consider the multi-class classification task. Let
and
denote the input space and label space corresponding to the ID distribution, respectively. Then, denote
as the ID distribution defined over
, and
is the OOD distribution. Let
Y be a random variable from space
, i.e.,
, and let
be a random variable from unknown OOD label space. We have
, which means that the ID sample
and OOD sample
have different label space [
26]. Then, we can define the ID training data as follows:
Furthermore, the goal of OOD detection can be defined as follows:
Definition 1 (OOD Detection [
26])
. OOD detection primarily accomplishes two tasks: (a) correctly classifying ID samples and (b) enabling the model to detect OOD samples that may be encountered during the inference phase. These two goals are achieved through the design of different OOD scoring functions. We present the formal definition of the OOD scoring function as follows:
Definition 2 (OOD Scoring Function [
1])
. With a pre-trained classifier , the OOD scoring function maps the input to a value, i.e., , such that the input data can be classified as ID or OOD data via a level-set estimation, i.e.,where is the binary decision between ID and OOD, and λ is a pre-defined parameter. Existing approaches leverage pre-trained classifiers and utilize the information from logit outputs [
10,
13,
16,
17,
27,
28,
29], embedding features [
15,
18,
30,
31,
32,
33,
34], or gradient information [
13,
21,
22] to devise various OOD scoring functions. Recent research has focused on employing non-parametric methods to design efficient scoring functions [
18]. To facilitate better understanding and ease the exposition in subsequent sections, we provide two commonly used OOD scoring functions below.
Maximum Softmax Prediction (MSP): This is a widely known baseline proposed by [
10] that employs the maximum value from the softmax output distribution as an indicator for OOD detection, with the scoring function provided in the following:
where
indicates the
j-th softmax output. In an ideal scenario, OOD data should not correspond to any specific class in the predictions, resulting in uniformly low softmax values across all dimensions. However, in practice, MSP is prone to errors due to the widely known problem of overconfident predictions [
10,
16].
MaxLogit Prediction (MLP): Ref. [
35] proposed an enhanced approach to MSP by utilizing maximal logits rather than softmax probabilities for constructing the scoring function, namely,
where
represents the
j-th dimension of the model output vector. Empirical results demonstrate that the MLP score outperforms MSP, particularly in scenarios with large ID label spaces, making it a prevalent choice in practical applications.
Building on these scoring functions, [
36] proposed using additional auxiliary OOD data to fine-tune models, a method widely known as outlier exposure (OE). This innovative approach allows models to learn from OOD data and has demonstrated strong performance. Since then, numerous studies have been based on OE. Our method is also grounded in OE, and we provide the classic definition of OE below.
Outlier Exposure (OE): [
36]. Given the ID training data
and the additional auxiliary OOD data set
, we defined the following:
where
is the auxiliary OOD distribution. We use
instead of
because the auxiliary OOD distribution
may not perfectly match the true OOD distribution
[
24]. Then, OE aims to fine-tune the model to enhance its ability to detect OOD samples. Specifically, the training is processed by minimizing the following empirical risk:
where
improves the model ability to classify ID data, which can be written as follows:
and
enhances the model’s ability to detect OOD data, which can be written as follows:
OE-based methods allow models to be further fine-tuned, thereby exhibiting more powerful OOD detection performance [
16,
36,
37]. Accordingly, various studies have designed more efficient fine-tuning approaches from different perspectives, such as sampling strategies [
37,
38,
39], adversarial robust learning [
15,
38,
40], meta-learning [
41,
42], and regularization strategies [
43]. Some research has also explored various outlier synthesis strategies when OOD data are difficult to obtain [
6,
23,
44]. Although outlier exposure often yields positive results, the discrepancy between auxiliary data and real OOD data largely limits their effectiveness in real-world detection. In recent studies, [
1,
24] investigated using data generation to expand the coverage of auxiliary OOD data to reduce the gap between distributions and achieve better performance. Unlike previous methods that aimed to obtain more data, our approach focuses on screening a small amount of data that are more important for OOD detection training, allowing the OOD data to fine-tune the model. Based on the above discussion, this paper primarily addresses the following problem.
Problem Setup: Previous methods either exhibit suboptimal performance or require a large amount of additional OOD data to assist model training, which can be highly resource-intensive, especially in large-scale complex systems or when dealing with massive datasets [
39,
45]. The primary challenge addressed in this paper is how to fully leverage available data to train the model efficiently. To achieve this, we need to tackle two key questions: first, which data are more important for model training? Second, how can we identify and locate these important data? We will address these two questions in the subsequent sections.
3. Data Importance Analysis
In this section, we conduct experiments using
CIFAR-100 as ID data,
Tiny-ImageNet-200 as auxiliary OOD data, and
Textures as the test OOD dataset to systematically analyze which types of data are most beneficial for OOD detection training. The main results are summarized in
Figure 2.
Given that the FPR95 metric is optimized by lower values, our experimental findings reveal an intriguing phenomenon: when training with more challenging OOD data, the training performance begins to deteriorate after several iterations. Conversely, when utilizing OOD data that the pre-trained model can correctly detect, the model converges more rapidly than when using all OOD data for training. The final results further indicate that training with the most difficult OOD data yields the poorest performance, whereas training exclusively with OOD data that the pre-trained model can correctly detect outperforms training with all auxiliary OOD data.
We conduct further experiments to fine-tune the model using
as auxiliary OOD data. Meanwhile,
is employed as OOD data for testing to evaluate the OOD detection performance. The selected dataset sizes are as follows:
contains 29,275 samples, and
contains 37,575 samples, resulting in a ratio of
to
of approximately 1.28:1. The results are presented in
Table 1. It can be observed that fine-tuning the model using the entire OOD dataset
yields nearly identical performance compared to fine-tuning using only
. Moreover, the time required for fine-tuning with
is less than half of that required when using
. It is important to note that
encompasses the
portion of the data, whereas
does not include
.
We can infer from these observations that among the auxiliary OOD data, the samples that are more beneficial for model training are those relatively simple OOD instances that the pre-trained classifier can accurately detect. This is likely because these correctly detected OOD data possess more distinctive features compared to ID data, enabling the model to benefit from learning these patterns. In contrast, the OOD data that the model fails to detect exhibit lower distinguishability from ID data, thereby potentially impairing the ability of the model to learn to differentiate between ID and OOD data.
Therefore, it is sufficient to identify and utilize simpler OOD data that the pre-trained model can accurately distinguish for training purposes. We will subsequently propose a specific algorithm to achieve this.
4. Methodology
Based on the analysis presented in
Section 3, we now introduce a specific training algorithm in this section. The detailed procedure of the algorithm is summarized in Algorithm 1.
We first evaluate the ID data
to determine the OOD score threshold
that correctly identifies 95% of the ID samples, i.e.,
We subsequently evaluate the auxiliary OOD data to identify samples with OOD scores lower than the threshold
. These samples are selected as the auxiliary data for the training process, which can be formally formulated as follows:
In practical implementations, it is often not necessary to employ the entire dataset
. Specifically, we can sort the data within
based on their corresponding OOD scores in ascending order and then select a subset from the top, such as the top 10% of the data. This approach can significantly reduce computational costs. The experimental results presented in the following chapter demonstrate that even with the use of only the top 10% of the data, it is possible to achieve commendable performance levels.
Algorithm 1. FIS: Focus on Important Samples. |
Require: The ID training dataset ; the auxiliary OOD dataset ; the pre-trained classifier ; the trade-off parameters . Ensure: The OOD detector .
- 1:
# Setecting Auxiliary OOD Data: - 2:
Compute OOD scores of the ID data to get the threshlod via Equation ( 9); - 3:
Compute OOD scores of the auxiliary OOD data ; - 4:
Select the auxiliary training OOD data via Equation ( 10); - 5:
# Training: - 6:
for to do - 7:
Fetch a mini-batch from ; - 8:
if selecting then - 9:
Perform steps 2 to 4.; - 10:
end if - 11:
Update by minimizing via Equation ( 6); - 12:
end for - 13:
return The well-trained .
|
During training, we follow the same approach as OE, minimizing the empirical risk , where we employ the multi-class cross-entropy loss as , and adopt the loss function used in the classic OE method as , i.e., the cross-entropy from the model output distribution to the uniform distribution.