Plug-and-Play Transformer Modules for Test-Time Adaptation

Xiangyu Chang, Sk Miraj Ahmed, Srikanth V. Krishnamurthy, Basak Guler, Ananthram Swami, Samet Oymak, Amit K. Roy-ChowdhuryarXiv 2024

Abstract

Parameter-efficient tuning (PET) methods such as LoRA, Adapter, and Visual Prompt Tuning (VPT) have found success in enabling adaptation to new domains by tuning small modules within a transformer model. However, the number of domains encountered during test time can be very large, and the data is usually unlabeled. Thus, adaptation to new domains is challenging; it is also impractical to generate customized tuned modules for each such domain. Toward addressing these challenges, this work introduces PLUTO: a Plug-and-pLay modUlar Test-time domain adaptatiOn strategy. We pre-train a large set of modules, each specialized for different source domains, effectively creating a "module store". Given a target domain with few-shot unlabeled data, we introduce an unsupervised test-time adaptation (TTA) method to (1) select a sparse subset of relevant modules from this store and (2) create a weighted combination of selected modules without tuning their weights. This plug-and-play nature enables us to harness multiple most-relevant source domains in a single inference call. Comprehensive evaluations demonstrate that PLUTO uniformly outperforms alternative TTA methods and that selecting $\le$5 modules suffice to extract most of the benefit. At a high level, our method equips pre-trained transformers with the capability to dynamically adapt to new domains, motivating a new paradigm for efficient and scalable domain adaptation.

Introduction

Machine learning models often experience performance degradation when encountering domain shift—where test data distributions differ from training data. While Unsupervised Domain Adaptation (UDA) offers a solution, it typically requires substantial target data and offline training. Test-Time Adaptation (TTA) provides a more flexible alternative by adapting models during inference. However, existing TTA methods often struggle with data scarcity (few-shot scenarios), catastrophic forgetting of source knowledge, and the computational overhead of fine-tuning large models for every new environment.

This paper introduces PLUTO (Plug-and-pLay modUlar Test-time adaptatiOn), a framework designed to overcome these hurdles. PLUTO maintains a "store" of small, specialized modules and dynamically blends them based on the current input, achieving state-of-the-art performance in few-shot, unlabeled domain adaptation without the heavy cost of full-model fine-tuning.

Methodology: The PLUTO Framework

PLUTO employs a two-step "Plug-and-Play" strategy to adapt pre-trained Transformers to new domains on the fly.

Overview of the PLUTO framework, showing the initialization of the module store and the two-step test-time adaptation process.

1. The Module Store

Rather than relying on a single monolithic model, PLUTO utilizes a library of Parameter-Efficient Tuning (PET) modules, such as Visual Prompt Tuning or Adapters. Each module is pre-trained to specialize in a specific source domain, creating a diverse "module store."

2. Step 1: Module Selection and Weighting

Upon receiving new target data, an attention-based Module Selector evaluates the input alongside the outputs of the stored specialists. It assigns weights to these modules, effectively routing the data to the most relevant experts. This selector is updated in an unsupervised manner using pseudo-label entropy minimization, which increases the model's confidence in its predictions on the new domain.

3. Step 2: Robust Refinement

To further refine the adaptation, PLUTO identifies a sparse subset of the most relevant modules (typically $M \le 5$). It then performs a lightweight update on the model's LayerNorm (LN) parameters using Sharpness-Aware Minimization (SAM). SAM helps the model find a "flat" loss landscape, ensuring robust adaptation and preventing the model from collapsing into single-class predictions.

Experimental Evaluation

The authors evaluated PLUTO across several standard computer vision benchmarks, including Digits-Five, Office-Home, and corrupted datasets like CIFAR-10C and ImageNet-C.

Key Results and Insights

PLUTO consistently outperformed state-of-the-art TTA baselines such as TENT, CoTTA, and EaTA. A significant finding is the effectiveness of sparse selection; choosing only the top 5 modules from the store is sufficient to capture nearly all adaptation benefits, maintaining high efficiency.

Performance comparison on the Office-Home dataset across varying target data sizes, highlighting PLUTO's robustness in few-shot and zero-shot scenarios.

As shown in the experimental results, PLUTO demonstrates remarkable resilience in data-scarce environments. On the Office-Home benchmark, PLUTO achieved a +24% absolute accuracy improvement over the best alternative methods in zero-shot and 16-shot scenarios. Furthermore, the method scales effectively; the authors successfully managed a store of 75 modules on ImageNet-C with minimal parameter overhead (less than 1% of a standard ViT-Base model).

Discussion and Conclusion

PLUTO introduces a scalable and efficient paradigm for domain adaptation. By keeping the backbone Transformer frozen and only updating small PET modules and LayerNorm parameters, the model is inherently resistant to catastrophic forgetting.

While PLUTO's performance is tied to the diversity of its module store, its ability to perform sample-specific adaptation through its attention-based selector makes it a powerful tool for real-world applications. Future work may involve expanding the module store's complexity and applying this framework to other modalities, such as Natural Language Processing, where domain shift remains a critical challenge for large-scale models.

Summary updated

BibTeX
@misc{chang2024plug,
  author = {Xiangyu Chang and Sk Miraj Ahmed and Srikanth V. Krishnamurthy and Basak Guler and Ananthram Swami and Samet Oymak and Amit K. Roy-Chowdhury},
  title = {{Plug-and-Play Transformer Modules for Test-Time Adaptation}},
  year = {2024},
  eprint = {2401.04130},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.04130},
}
Figure