Unsupervised Layer-Wise Score Aggregation for Textual OOD Detection
Maxime Darrin, Guillaume Staerman, Eduardo Dadalto Câmara Gomes, Jackie C. K. Cheung, Pablo Piantanida, Pierre Colombo
Abstract
Out-of-distribution (OOD) detection is a rapidly growing field due to new robustness and security requirements driven by an increased number of AI-based systems. Existing OOD textual detectors often rely on anomaly scores (e.g., Mahalanobis distance) computed on the embedding output of the last layer of the encoder. In this work, we observe that OOD detection performance varies greatly depending on the task and layer output. More importantly, we show that the usual choice (the last layer) is rarely the best one for OOD detection and that far better results can be achieved, provided that an oracle selects the best layer. We propose a data-driven, unsupervised method to leverage this observation to combine layer-wise anomaly scores. In addition, we extend classical textual OOD benchmarks by including classification tasks with a more significant number of classes (up to 150), which reflects more realistic settings. On this augmented benchmark, we show that the proposed post-aggregation methods achieve robust and consistent results comparable to using the best layer according to an oracle while removing manual feature selection altogether.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers6
- SaulLM-54B & SaulLM-141B: Scaling Up Domain Adaptation for the Legal DomainPierre Colombo, Telmo Pessoa Pires, Malik Boudiaf, Rui Melo et al.NeurIPS 2024 · 58 citations
- What If the Input is Expanded in OOD Detection?Boxuan Zhang, Jianing Zhu, Zengmao Wang, Tongliang Liu et al.NeurIPS 2024 · 19 citations
- Transductive Learning for Textual Few-Shot Classification in API-based Embedding ModelsPierre Colombo, Victor Pellegrain, Malik Boudiaf, Myriam Tami et al.EMNLP 2023 · 7 citations
- A Layer Selection Approach to Test Time AdaptationSabyasachi Sahoo, Mostafa ElAraby, Jonas Ngnawé, Yann Batiste Pequignot et al.AAAI 2025 · 6 citations
- Hypothesis Transfer Learning with Surrogate Classification Losses: Generalization Bounds through Algorithmic StabilityAnass Aghbalou, Guillaume StaermanICML 2023 · 3 citations
Builds on20
- The Many Faces of Robustness: A Critical Analysis of Out-of-Distribution GeneralizationDan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath et al.ICCV 2021 · 2,294 citations
- Energy-based Out-of-distribution DetectionWeitang Liu, Xiaoyun Wang, John D. Owens, Yixuan LiNeurIPS 2020 · 2,213 citations
- Input Complexity and Out-of-distribution Detection with Likelihood-based Generative ModelsJoan Serrà, David Álvarez, Vicenç Gómez, Olga Slizovskaia et al.ICLR 2020 · 307 citations
- ViM: Out-Of-Distribution with Virtual-logit MatchingHaoqi Wang, Zhizhong Li, Litong Feng, Wayne ZhangCVPR 2022 · 227 citations
- Is Out-of-Distribution Detection Learnable?Zhen Fang, Yixuan Li, Jie Lu, Jiahua Dong et al.NeurIPS 2022 · 188 citations
Related papers
- Enhancing Two Steps Textual Anomaly Detection through Anisotropy MitigationPierre Fihey, Matthieu Labeau, Pavlo MozharovskyiACL 2026
- Discriminability-Driven Channel Selection for Out-of-Distribution DetectionYue Yuan, Rundong He, Yicong Dong, Zhongyi Han et al.CVPR 2024 · 7 citations
- Revisit PCA-based technique for Out-of-Distribution DetectionXiaoyuan Guan, Zhouwu Liu, Wei-Shi Zheng, Yuren Zhou et al.ICCV 2023 · 19 citations
- Gradient-Based Novelty Detection Boosted by Self-Supervised Binary ClassificationJingbo Sun, Li Yang, Jiaxin Zhang, Frank Liu et al.AAAI 2022 · 17 citations
- Mysteries of the Deep: Role of Intermediate Representations in Out of Distribution DetectionIgnacio Meza De La Jara, Cristian Rodriguez Opazo, Damien Teney, Damith Ranasinghe et al.NeurIPS 2025 · 8 citations
