arXiv:2610.05718cs.LGOct 2026

Manuscript Offprint

arXiv:2610.05718

ReMaD: Tuning-free Domain Adaptation for Classification and Out-of-Distribution Detection

Elijah Bolluyt, Cristina Comaniciu

Elijah Bolluyt, Cristina Comaniciu

Abstract— We introduce Reduced-rank Mahalanobis Distance (ReMaD), a novel prototypical distance-based refinement to classification and out-of-distribution (OOD) detection using pretrained models without finetuning. We use embeddings of the target dataset to fit closed-form distribution statistics in the model's latent space which can classify in-distribution samples and detect OOD samples, all without training or prior knowledge of the OOD data. Building on prototype classification and OOD detection, we analyze the distribution properties of large pretrained models when processing new datasets; based on this analysis, we formulate a simple modification to Mahalanobis Distance to adapt models' latent space distributions to new domains by removing unused features, without the finetuning or hyperparameter searches required by other adaptation procedures. We demonstrate the efficacy of this method to adapt existing large pretrained image embedding models to new classification domains outside their trained capabilities by testing across four target datasets, with competitive performance in both classification and OOD detection.

Impact Statement — Neural network image classifiers deployed in real tasks must often handle unexpected data from far outside their training sets, especially in safety-sensitive applications where an inappropriate response could cause harm. While large pretrained models have become prevalent in classification tasks, current literature on methods to handle anomalous data has mostly focused on traditional trained classifiers or models which have at least observed relevant data during training. Our method allows these large models to be more safely deployed without the high cost of retraining by enhancing their ability to identify and handle out-of-distribution data. In contrast to other methods, we also do not require any hyperparameter tuning, further minimizing deployment cost and complexity. By adding this capability without significant added cost, our method can help to fortify existing systems against unexpected inputs.

Index Terms—Anomaly Detection, Classification, Domain Adaptation, Large Pretrained Models, Mahalanobis Distance, Out-of-Distribution Detection

I. INTRODUCTION

As neural network classifiers are deployed in real-world applications, the rise of large pretrained models in both image and text modalities has reduced the need to train specialized models on individual classification tasks. These large models benefit from pretraining on largescale datasets, often performing competitively with specially trained models. In addition, distillation and related methods [1][1] [2][2] can reduce these large, general models to smaller sizes, allowing deployment to constrained environments and negating the primary disadvantage of large architectures. For tasks related to their training domain, these models can often complete tasks in a zero- or few-shot modality [3][3] [2][2]. For tasks outside their original domain, these models can be finetuned; efficient methods can make this process more affordable, but it often still requires significant computational resources and specialized techniques for individual domains.

Simultaneously, robustness to anomalous inputs from outside a classifier’s target distribution has become increasingly important as models are deployed to a widening array of safety-critical tasks. Detecting and handling unexpected inputs appropriately ensures that systems perform their tasks reliably once deployed. Out-of-Distribution (OOD) detection codifies this task by augmenting classifiers to detect samples which do not belong to any known in-distribution (ID) classification label. OOD detection can be implemented as a post-hoc method on trained classifier models, or via finetuning methods.

However, most existing OOD detection methods for classifiers rely on the models' differing responses to in-distribution (ID) data versus OOD data [4] [5] [6]. Large unimodal encoders which offer rich embedding spaces must be finetuned to serve as classifiers and OOD detectors. Zero-shot classifiers based on Contrastive Language Image Pretrained (CLIP) models can be augmented with OOD detection, but most methods require finetuning [7]; others assume that the model's text encoder has knowledge of the ID sample's classes [8] [9], limiting their application to tasks within the domain of the model's training data. This also largely excludes the application of general models to tasks with highly technical terminologies, such as medical data.

Zero-shot classification and OOD detection requires that the model has knowledge of the in-distribution's classes, and finetuning requires compute resources and the storage of specialized models for every task. We propose a third approach based on the hypothesis that the embedding model's features, which are trained over largescale data, are sufficiently capable to succeed at a new classification task if we can appropriately define the target distribution. To this end, we analyze the

This work has been submitted to the IEEE for possible publication. Copyright may be transferred without notice, after which this version may no longer be accessible.

This work is supported in part by ACC-New Jersey under Contract No. W15QKN-18-D-0040

E. Bolluyt is with Stevens Institute of Technology, Hoboken, NJ, 07030, USA (e-mail: ebolluyt@stevens.edu).

C. Comaniciu is with Stevens Institute of Technology, Hoboken, NJ, 07030, USA (e-mail: ccomanic@stevens.edu).

properties of latent distributions in large embedding models when utilized for new tasks; we leverage our findings to create a simple modification to existing distance-based methods to better serve domains which are novel to the model. Specifically, we address cases where a training set is available for a new domain, but the pretrained model need not have any knowledge of it, and finetuning of parameters or hyperparameters is not performed. We also exclude prior knowledge of any OOD data, in contrast to methods which include such information [10].

We introduce a novel training-free and hyperparameter tuning-free approach for the domain adaptation of large pretrained models to new classification tasks, with accompanying OOD detection capability. Related to distance-based OOD detection using Mahalanobis Distance [11] [12] [13] and prototypical networks [14], our method calculates closed-form distribution statistics using a single inference pass across a target dataset. Once collected, these statistics enables both classification and OOD detection using large pretrained embedding models, even when the target task is outside the knowledge of the model. This process requires no training, only inference, drastically reducing the computational requirements of adapting large models to new domains. The resultant classifiers leverage the large model's learned features and possess robust OOD detection capabilities.

References (39)