Contrastive Out-of-Distribution Detection for Pretrained Transformers
Wenxuan Zhou, Fangyu Liu, Muhao Chen
摘要
Pretrained Transformers achieve remarkable performance when training and test data are from the same distribution. However, in real-world scenarios, the model often faces out-of-distribution (OOD) instances that can cause severe semantic shift problems at inference time. Therefore, in practice, a reliable model should identify such instances, and then either reject them during inference or pass them over to models that handle another distribution. In this paper, we develop an unsupervised OOD detection method, in which only the in-distribution (ID) data are used in training. We propose to fine-tune the Transformers with a contrastive loss, which improves the compactness of representations, such that OOD instances can be better differentiated from ID ones. These OOD instances can then be accurately detected using the Mahalanobis distance in the model's penultimate layer. We experiment with comprehensive settings and achieve near-perfect OOD detection performance, outperforming baselines drastically. We further investigate the rationales behind the improvement, finding that more compact representations through margin-based contrastive learning bring the improvement. We release our code to the community for future research.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 30 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Partial and Asymmetric Contrastive Learning for Out-of-Distribution Detection in Long-Tailed Recognition 引用了 Energy-based Out-of-distribution Detection
- Partial and Asymmetric Contrastive Learning for Out-of-Distribution Detection in Long-Tailed Recognition 引用了 Supervised Contrastive Learning
- Delving into Out-of-Distribution Detection with Vision-Language Representations 引用了 Partial and Asymmetric Contrastive Learning for Out-of-Distribution Detection in Long-Tailed Recognition
- Delving into Out-of-Distribution Detection with Vision-Language Representations 引用了 Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere
- Delving into Out-of-Distribution Detection with Vision-Language Representations 引用了 POEM: Out-of-Distribution Detection with Posterior Sampling
- Delving into Out-of-Distribution Detection with Vision-Language Representations 引用了 Energy-based Out-of-distribution Detection
- Delving into Out-of-Distribution Detection with Vision-Language Representations 引用了 CSI: Novelty Detection via Contrastive Learning on Distributionally Shifted Instances
- Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere 引用了 A Simple Framework for Contrastive Learning of Visual Representations
- POEM: Out-of-Distribution Detection with Posterior Sampling 引用了 Energy-based Out-of-distribution Detection
- POEM: Out-of-Distribution Detection with Posterior Sampling 引用了 Supervised Contrastive Learning
- Beyond Mahalanobis Distance for Textual OOD Detection 引用了 Energy-based Out-of-distribution Detection
- A Data-centric Framework to Endow Graph Neural Networks with Out-Of-Distribution Detection Ability 引用了 Energy-based Out-of-distribution Detection
- Supervised Contrastive Learning 引用了 Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere
- Supervised Contrastive Learning 引用了 A Simple Framework for Contrastive Learning of Visual Representations
- CSI: Novelty Detection via Contrastive Learning on Distributionally Shifted Instances 引用了 A Simple Framework for Contrastive Learning of Visual Representations
- CSI: Novelty Detection via Contrastive Learning on Distributionally Shifted Instances 引用了 Supervised Contrastive Learning
引用它的顶会 Paper30
- Delving into Out-of-Distribution Detection with Vision-Language RepresentationsYifei Ming, Ziyang Cai, Jiuxiang Gu, Yiyou Sun 等NeurIPS 2022 · 308 次引用
- POEM: Out-of-Distribution Detection with Posterior SamplingYifei Ming, Ying Fan, Yixuan LiICML 2022 · 151 次引用
- Partial and Asymmetric Contrastive Learning for Out-of-Distribution Detection in Long-Tailed RecognitionHaotao Wang, Aston Zhang, Yi Zhu, Shuai Zheng 等ICML 2022 · 61 次引用
- A Data-centric Framework to Endow Graph Neural Networks with Out-Of-Distribution Detection AbilityYuxin Guo, Cheng Yang, Yuluo Chen, Jixi Liu 等KDD 2023 · 26 次引用
- Beyond Mahalanobis Distance for Textual OOD DetectionPierre Colombo, Eduardo Dadalto Câmara Gomes, Guillaume Staerman, Nathan Noiry 等NeurIPS 2022 · 24 次引用
它引用的 Paper10
- A Simple Framework for Contrastive Learning of Visual RepresentationsTing Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey E. HintonICML 2020 · 24,064 次引用
- Supervised Contrastive LearningPrannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna 等NeurIPS 2020 · 7,049 次引用
- Understanding Contrastive Representation Learning through Alignment and Uniformity on the HypersphereTongzhou Wang, Phillip IsolaICML 2020 · 2,360 次引用
- Energy-based Out-of-distribution DetectionWeitang Liu, Xiaoyun Wang, John D. Owens, Yixuan LiNeurIPS 2020 · 2,213 次引用
- CSI: Novelty Detection via Contrastive Learning on Distributionally Shifted InstancesJihoon Tack, Sangwoo Mo, Jongheon Jeong, Jinwoo ShinNeurIPS 2020 · 755 次引用
相关 Paper
- Is Fine-tuning Needed? Pre-trained Language Models Are Near Perfect for Out-of-Domain DetectionRheeya Uppaal, Junjie Hu, Yixuan LiACL 2023 · 9 次引用
- On Prefix-tuning for Lightweight Out-of-distribution DetectionYawen Ouyang, Yongchang Cao, Yuan Gao, Zhen Wu 等ACL 2023 · 1 次引用
- X-Mahalanobis: Transformer Feature Mixing for Reliable OOD DetectionTong Wei, Bolin Wang, Jiang-Xin Shi, Yu-Feng Li 等NeurIPS 2025 · 9 次引用
- Gradient-Based Novelty Detection Boosted by Self-Supervised Binary ClassificationJingbo Sun, Li Yang, Jiaxin Zhang, Frank Liu 等AAAI 2022 · 17 次引用
- Out-of-Distribution Detection by Leveraging Between-Layer Transformation SmoothnessFran Jelenic, Josip Jukic, Martin Tutek, Mate Puljiz 等ICLR 2024 · 12 次引用
