NeurIPS 2025poster0 citations

X-Mahalanobis: Transformer Feature Mixing for Reliable OOD Detection

Tong Wei, Bo-Lin Wang, Jiang-Xin Shi, Yu-Feng Li, Min-Ling Zhang

Abstract

Recognizing out-of-distribution (OOD) samples is essential for deploying robust machine learning systems in open-world environments. While conventional OOD detection approaches rely on feature representations from the penultimate layer of neural networks, they often overlook informative signals embedded in intermediate layers. In this paper, we present a straightforward feature mixing approach for pre-trained Transformers, which combines multi-layer representations via calculated importance weights, and identifies OOD samples using Mahalanobis distance in the blended feature space. When in-distribution samples are accessible, we show that parameter-efficient fine-tuning strategies effectively balance classification accuracy and OOD detection performance. We conduct extensive empirical analyses to validate the superiority of our proposed method under zero-shot, and fine-tuning settings using both class-balanced and long-tailed datasets. The source code is available at https://github.com/SEUML/X-Maha.

out-of-distribution detectionlong-tail learning
BibTeX
@inproceedings{
wei2025xmahalanobis,
title={X-Mahalanobis: Transformer Feature Mixing for Reliable {OOD} Detection},
author={Tong Wei and Bo-Lin Wang and Jiang-Xin Shi and Yu-Feng Li and Min-Ling Zhang},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=ewyR20zwqA}
}
X-Mahalanobis: Transformer Feature Mixing for Reliable OOD Detection · NeurIPS 2025