# How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability

분포 외 탐지 학습 이론이 트랜스포머를 강화하는 방식: 학습 가능성과 신뢰성

Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · arXiv · 2024년 6월 13일

- **연구 문제** 트랜스포머는 OOD 데이터에 일반화하기 어려우며, OOD 탐지 전략은 경험적 시행착오에 의존해 이론적 근거가 부족합니다.
- **연구 방법** 논문은 트랜스포머에서 OOD 탐지가 학습 가능한 조건을 PAC 틀로 규명하고, 이를 바탕으로 ID 경계 바깥에 가상 OOD를 만들어 ID-OOD 이진 분류 손실과 함께 미세조정하는 GROD를 제안합니다.
- **주요 결과** 분리 공간에서 입력 집합이 유한하면 트랜스포머의 OOD 탐지가 학습 가능하다는 결과와, CIFAR-10·ImageNet-200 등 이미지 벤치마크에서 비교 기준선보다 낮은 FPR@95를 보고하는 결과가 제시됩니다.

## 트랜스포머의 OOD 탐지 신뢰성 문제

트랜스포머는 자연어 처리와 컴퓨터 비전에서 뛰어난 성능을 보이지만, 학습 때 보지 못한 분포의 입력인 OOD(Out-of-Distribution) 데이터에 일반화하기 어렵습니다. OOD 탐지는 이런 이상치를 가려내면서 ID(In-Distribution) 데이터의 성능을 유지하는 과제입니다. 논문은 OOD 탐지 전략이 주로 경험적 직관과 시행착오에 의존하고, 트랜스포머에 대한 이론적 이해와 신뢰성에 관한 형식적 분석이 부족하다고 지적합니다. 이에 저자들은 트랜스포머에서 OOD 탐지가 학습 가능한 조건을 PAC 학습 틀로 규명하는 것을 목표로 삼습니다. 이 이론적 결과는 학습 전략과 모델 용량을 고르는 근거를 제공하며, 이를 바탕으로 가상 OOD를 활용하는 GROD 방법이 제안됩니다.

## 학습 가능성 정의와 트랜스포머 가설 공간

논문은 Fang et al. (2022)의 강한 학습 가능성 정의를 출발점으로 삼습니다. 이 정의에서 알고리즘이 만든 가설의 위험과 가설 공간 내 최적 위험의 차이가 샘플 수 n에 따라 감소하는 상한 ϵ(n)으로 제한되어야 합니다. 트랜스포머에 대해서는 블록의 예산 m과 층 수 l로 정해지는 가설 공간 H(l,m)을 정의하고, 여기에 분류기를 결합해 OOD 탐지용 가설 공간 H를 구성합니다. 분류기는 최댓값 기준 분류기와 점수 기반 분류기를 포함합니다. 이 정식화는 이후의 학습 가능성 정리가 어떤 모델 집합에서 성립하는지 정하는 기준입니다.

## 분리 공간의 학습 가능성 결과

논문은 ID와 OOD 클래스가 겹치지 않는 분리 공간에서 결과를 다룹니다. 이 공간에서 Theorem 3.2는 ID-OOD 분류 오류를 학습 손실에 반영하는 조건에서, 입력 집합의 크기 \|X\|가 유한하면 OOD 탐지가 학습 가능하고 무한하면 학습 가능하지 않다고 정리합니다. 유한한 경우의 충분 조건으로는 블록 예산과 층 수에 대한 구체적인 값이 제시됩니다. 학습 가능성의 확률 하한 P를 다루는 Theorem 3.4와 3.5는 예산과 데이터 수에 따른 Jackson형 근사 상한을 사용하며, 데이터 복잡도가 커질수록 더 많은 파라미터가 필요하다는 스케일링 법칙을 드러냅니다. 이 결과는 ID와 OOD가 겹치지 않는다는 가정 위에서 성립하며, 실제 데이터의 겹침 문제는 별도 논의로 남습니다.

![Figure 4: (a) The visualization of the generated two-dimensional Gaussian mixture dataset. (b) Curves show the classification accuracy and OOD detection accura…](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-6ff59d8d4f54d029a821d1992035824b.png?thumb=512)

**Figure 4** .(a) The visualization of the generated two-dimensional Gaussian mixture dataset. (b) Curves show the classification accuracy and OOD detection accuracy of the training stage and test stage with different model capacities. And likelihood score bars demonstrate that the model with the theoretical support is disabled to learn OOD characters, leading to the failure of OOD detection.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 21쪽에서 그림 영역을 추출했습니다.

## 이론과 학습 사이의 간극과 손실 설계

이론은 충분한 파라미터가 있을 때 OOD 탐지 가능성을 보이지만, 실제 학습에서는 여전히 어렵습니다. 저자들은 두 가지 이유를 제시합니다. 첫째는 실제 OOD 분포가 잘 정의되지 않아 엄격한 비중첩 가정을 만족하기 어렵다는 점이고, 둘째는 교차 엔트로피 손실이 ID-OOD 오분류를 직접 벌하지 않는다는 점입니다. 이를 보완하기 위해 논문은 L = (1-γ)L1 + γL2 형태의 손실을 제안합니다. 여기서 L1은 교차 엔트로피이고 L2는 ID와 OOD를 구분하는 이진 분류 손실입니다. 가상 OOD가 없으면 모델은 테스트 데이터를 모두 ID로 오분류하는 경향이 있으므로, 보조 이상치를 생성하는 전략도 함께 도입됩니다.

## GROD의 가상 OOD 생성과 fine-tuning

GROD는 fine-tuning 단계에서 특징 공간의 ID 경계를 찾고 그 바깥쪽에 가상 OOD 임베딩을 만듭니다. 먼저 특징 F에 PCA와 LDA 투영을 적용해 각 차원의 최대·최소 경계 ID 점을 찾습니다. PCA는 전역적 경계를, LDA는 클래스 간 경계를 나타냅니다. 이 점들을 바깥쪽으로 확장해 가상 OOD 중심을 정하고, 그 주변에 가우시안 혼합 분포를 따르는 샘플을 생성합니다. 이후 Mahalanobis 거리로 ID와 유사한 샘플을 걸러내고, 각 가상 OOD에 소프트 라벨을 부여합니다. 최종적으로 ID 특징과 가상 OOD를 합쳐 L 손실로 미세조정합니다. 테스트 단계에서는 로짓을 조정한 뒤 수정된 VIM으로 최종 예측을 얻습니다.

![Figure 2: Overview of GROD: In fine-tuning, GROD generates fake OOD as part of the training data and guides fine-tuning by incorporating the ID-OOD lossL 2. In…](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-cd7070b36c736b36df0e1bc9b3a99530.png?thumb=512)

**Figure 2** .Overview of GROD: In fine-tuning, GROD generates fake OOD as part of the training data and guides fine-tuning by incorporating the ID-OOD lossL 2. In inference, features and adjusted LOGITSare input into the post-processor.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

## 이미지 벤치마크에서의 비교

CV 과제에서 GROD는 자기지도 사전학습된 DINO(ViT-B-16)를 백본으로 사용합니다. CIFAR-10을 ID로 한 실험에서 GROD는 평균 FPR@95 3.01%와 평균 AUROC 99.33%를 기록하여 비교된 기준선보다 낮은 FPR@95와 높은 AUROC를 보였습니다. CIFAR-100에서는 평균 FPR@95를 기준선 대비 적어도 5.43% 낮췄다고 보고됩니다. ImageNet-200에서는 평균 FPR@95 30.90%와 평균 AUROC 92.08%를 보였습니다. 이 수치는 OpenOOD 벤치마크의 설정을 따른 비교이며, 기준선 방법의 점수는 해당 벤치마크 조건에서 가져온 것입니다.

![Table 1: OOD Detection Results (FPR@95 and AUROC) on ID datasetsCIFAR-10andCIFAR-100. OOD datasetCIFARrepresents CIFAR-100andCIFAR-10when ID datasets areCIFAR-…](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-f33a48ff147deec79e26c15ef5388b3f.png?thumb=512)

**Table 1** .OOD Detection Results (FPR@95 and AUROC) on ID datasetsCIFAR-10andCIFAR-100. OOD datasetCIFARrepresents CIFAR-100andCIFAR-10when ID datasets areCIFAR-10andCIFAR-100respectively.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.

![Table 2: OOD Detection Results (FPR@95 and AUROC) onImageNet-200](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-483647043c3948c904cc945e48ded35e.png?thumb=512)

**Table 2** .OOD Detection Results (FPR@95 and AUROC) onImageNet-200.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.

![Figure 7: The distribution histograms and probability density curves of prediction likelihoods of ID and OOD test data. Results derived by GROD and the baselin…](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-9c55094ba5d3e0d59953106d2d6c8d64.png?thumb=512)

**Figure 7** .The distribution histograms and probability density curves of prediction likelihoods of ID and OOD test data. Results derived by GROD and the baseline MSP are visualized, withCIFAR-10as ID andSVHNas OOD.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 28쪽에서 그림 영역을 추출했습니다.

## 텍스트 과제와 절제 실험

NLP 과제에서는 BERT, GPT-2, Llama-3.1-8B를 백본으로 사용하고, IMDB와 CLINC150을 ID로 하여 배경 이동과 의미 이동 OOD를 평가합니다. 이 결과에서 GROD는 여러 기준선보다 나은 성능을 보고하지만, 텍스트 OOD 탐지는 여전히 어려운 과제로 설명됩니다. 절제 실험에서는 식 (51)의 a와 식 (57)의 γ를 조정합니다. 두 값을 0으로 두면 각각 ID 클러스터 중심에서 이상치를 생성하거나 ID-OOD 페널티 모듈을 제거하는 것에 해당하며, 이때 OOD 탐지 성능이 크게 저하된다고 보고됩니다. 다만 γ를 키우면 ID 분류 정확도가 떨어질 수 있다는 트레이드오프도 함께 관찰됩니다.

![Table 6: Quantitative comparison of NLP tasks, where the pre-trained BERT (a) and GPT-2 (b) are employed](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-19ca914b7d1d0b2fe1be4570ade1ea16.png?thumb=512)

**Table 6** .Quantitative comparison of NLP tasks, where the pre-trained BERT (a) and GPT-2 (b) are employed.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 26쪽에서 그림 영역을 추출했습니다.

![Figure 5: Ablation results for parametersain Eq. 51 andγin Eq. 57](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-44872adea95d40237a149be9eeabd239.png?thumb=512)

**Figure 5** .Ablation results for parametersain Eq. 51 andγin Eq. 57.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 27쪽에서 그림 영역을 추출했습니다.

## 적용 범위와 한계

저자들은 이론이 ID와 OOD가 겹치지 않는다는 가정에 기대므로, 실제 데이터에서 두 분포가 겹치는 경우에는 학습 가능성 조건과 충돌할 수 있다고 밝힙니다. 이 문제를 추정하는 방법은 향후 과제로 남아 있습니다. 또한 이론은 표준 트랜스포머 구조를 기반으로 하므로, 특수한 트랜스포머 변형으로 증명을 확장하는 일은 여전히 과제입니다. 합성 가상 OOD의 품질을 평가할 보편적 금 표준이 없어, 생성된 이상치의 품질은 주로 경험적 성능과 특징 시각화에 의존합니다.

![Figure 6: t-SNE visualization of the generated OOD data and test sets in the feature space](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7/figures/figure-8c2c4b096e2e1b7c5930ed7fa41fab86.png?thumb=512)

**Figure 6** .t-SNE visualization of the generated OOD data and test sets in the feature space.

[원문](https://arxiv.org/abs/2406.12915v6) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang · How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability · 원문 그림 인용 · 원본 PDF 27쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2024년 6월 13일
- **등록일**: 2026년 10월 30일
- **수정일**: 2026년 1월 29일
- **버전**: v6
- **arXiv**: 2406.12915
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2406.12915v6) · [원문 PDF ↗](https://arxiv.org/pdf/2406.12915v6)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

Transformers excel in natural language processing and computer vision tasks. However, they still face challenges in generalizing to Out-of-Distribution (OOD) datasets, i.e. data whose distribution differs from that seen during training. OOD detection aims to distinguish outliers while preserving in-distribution (ID) data performance. This paper introduces the OOD detection Probably Approximately Correct (PAC) Theory for transformers, which establishes the conditions for data distribution and model configurations for the OOD detection learnability of transformers. It shows that outliers can be accurately represented and distinguished with sufficient data under conditions. The theoretical implications highlight the trade-off between theoretical principles and practical training paradigms. By examining this trade-off, we naturally derived the rationale for leveraging auxiliary outliers to enhance OOD detection. Our theory suggests that by penalizing the misclassification of outliers within the loss function and strategically generating soft synthetic outliers, one can robustly bolster the reliability of transformer networks. This approach yields a novel algorithm that ensures learnability and refines the decision boundaries between inliers and outliers. In practice, the algorithm consistently achieves state-of-the-art (SOTA) performance across various data formats.

## 원문 인용

Zhou, Yijin, Ge, Yutang, Xie, Wenyuan, Zeng, Linqian, Dong, Xiaowen, Wang, Yuguang (2024). How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability. arXiv:2406.12915v6. https://arxiv.org/abs/2406.12915v6

**BibTeX**

```
@misc{yijin2024distribution,
  title = {{How Out-of-Distribution Detection Learning Theory Enhances Transformer: Learnability and Reliability}},
  author = {Zhou, Yijin and Ge, Yutang and Xie, Wenyuan and Zeng, Linqian and Dong, Xiaowen and Wang, Yuguang},
  year = {2024},
  eprint = {2406.12915},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.12915v6}
}
```

## 이 논문의 용어

- [CIFAR-10](https://refivu.com/terms/19035a518d0a-cifar-10)
- [트랜스포머](https://refivu.com/terms/515e8433c447-transformer)
- [AUROC](https://refivu.com/terms/096f06e69425-auroc)
- [BERT](https://refivu.com/terms/45b639a1d317-bert)
- [cross-entropy loss](https://refivu.com/terms/14067bdf8b9f-cross-entropy-loss)
- [Mahalanobis distance](https://refivu.com/terms/56d44d3d60ed-mahalanobis-distance)
- [DINO](https://refivu.com/terms/1dfe38658e15-dino)
- [principal component analysis (PCA)](https://refivu.com/terms/84a4d2030ed5-principal-component-analysis-pca)
- [Theorem 3.2](https://refivu.com/terms/ea055a71101a-theorem-3-2)
- [VC dimension](https://refivu.com/terms/6b54e4de0aed-vc-dimension)
- [Learnability](https://refivu.com/terms/38d111394b77-learnability)
- [Vim](https://refivu.com/terms/ccb0db3cf0d7-vim)
- [Markov’s inequality](https://refivu.com/terms/146768ce3db9-markov-s-inequality)
- [Natarajan dimension](https://refivu.com/terms/2931d20fbe56-natarajan-dimension)
- [ODIN](https://refivu.com/terms/3b732693a183-odin)
- [OOD detection](https://refivu.com/terms/a2347d5725d0-ood-detection)

## 다른 논문 해설

- [Spectral Evolution Search: Efficient Inference-Time Scaling for Reward-Aligned Image Generation](https://refivu.com/papers/314e1bdf-e212-4f09-8c61-2f65d520a72f-spectral-evolution-search-efficient-inference-time-scaling.md)
- [ManifoldKV: Training-Free KV Cache Compression via Euclidean Outlier Detection](https://refivu.com/papers/46fa9cd0-f866-49ac-807d-ef461752654d-manifoldkv-training-free-kv-cache-compression-via-euclidean.md)
- [Capturing Temporal Dynamics in Large-Scale Canopy Tree Height Estimation](https://refivu.com/papers/f39cc8ae-27ba-473c-8b43-759b8e4465f0-capturing-temporal-dynamics-in-large-scale-canopy-tree.md)
- [What Information Matters? Graph Out-of-Distribution Detection via Tri-Component Information Decomposition](https://refivu.com/papers/1d49c82f-0bfb-46e1-90ad-fa428f1c0ca3-what-information-matters-graph-out-of-distribution-detection.md)
- [Unsupervised Concept Discovery Mitigates Spurious Correlations](https://refivu.com/papers/455cf8c4-53eb-4670-a8b5-bacfcbb29f7f-unsupervised-concept-discovery-mitigates-spurious.md)
- [Diverse Prototypical Ensembles Improve Robustness to Subpopulation Shift](https://refivu.com/papers/978c2747-2461-43d9-99fd-7e88322b5e8e-diverse-prototypical-ensembles-improve-robustness-to.md)
- [Optimal Learning from Label Proportions with General Loss Functions](https://refivu.com/papers/aaa2516a-f48c-41b5-8f79-ac1132130a22-optimal-learning-from-label-proportions-with-general-loss.md)
- [Equivariant Neural Networks for General Linear Symmetries on Lie Algebras](https://refivu.com/papers/f35fcd6d-d372-43a2-8452-f1ce7c9aeb9d-equivariant-neural-networks-for-general-linear-symmetries-on.md)
- [Message Passing on the Edge: Towards Scalable and Expressive GNNs](https://refivu.com/papers/49c578fd-04e4-4884-a1d2-40fa4aa9371f-message-passing-on-the-edge-towards-scalable-and.md)
- [Test-Time Anchoring for Discrete Diffusion Posterior Sampling](https://refivu.com/papers/cded6142-3433-4b7a-a45d-0139f6558257-test-time-anchoring-for-discrete-diffusion-posterior.md)
- [Thoughtbubbles: an Unsupervised Method for Parallel Thinking in Latent Space](https://refivu.com/papers/d2d7e8f7-1ee5-47be-866d-499ed5f06d3e-thoughtbubbles-an-unsupervised-method-for-parallel-thinking.md)
- [Convergent World Representations and Divergent Tasks](https://refivu.com/papers/f0831191-780f-4012-acce-67fbfef1e91f-convergent-world-representations-and-divergent-tasks.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/5f95a31c-287e-4d48-bed3-30fbea4904d7-how-out-of-distribution-detection-learning-theory-enhances)
