Learning to Prompt Your Domain for Vision-Language Models

Guoyizhe Wei, Feng Wang, Anshul Shah, Rama Chellappa · DOI

Abstract

Prompt learning has recently become a very efficient transfer learning paradigm for Contrastive Language Image Pretraining (CLIP) models. Compared with fine-tuning the entire encoder, prompt learning can obtain highly competitive results by optimizing only a small number of parameters, which presents considerably exciting benefits for federated learning applications that prioritize communication efficiency. However, in this work, we identify that directly transferring prompt learning approaches into federated learning does not yield favorable results since the model often suffers from considerable domain gaps across different clients. To address this issue, we propose ADAPT, a novel domain-aware prompt learning approach that facilitates both intra- and inter-domain prompts across federated participants. The basic idea of ADAPT is that the prompted CLIP should detect the input image's domain correspondence before making the prediction of its category. Extensive experiments of ADAPT demonstrate its significant efficiency and effectiveness in federated learning. For example, by learning and sharing only 0.08M parameters, our ADAPT attains a 68.4% average accuracy over six domains in the DomainNet dataset, which improves the original CLIP by a large margin of 14.8%.

Introduction: The Challenge of Domain Shift in Federated Learning

Federated Learning (FL) has emerged as a vital paradigm for training machine learning models across decentralized clients while preserving data privacy. With the advent of large-scale Vision-Language Models (VLMs) like CLIP, researchers have sought to leverage Prompt Tuning—the process of adding a few learnable "tokens" to a frozen model—to adapt these massive models to specific downstream tasks efficiently. In an FL context, prompt tuning is particularly attractive because clients only need to exchange a tiny set of prompt parameters rather than the entire model, drastically reducing communication overhead.

However, a significant hurdle remains: Domain Shift. In real-world FL scenarios, data is often non-identically distributed (non-IID) across participants. One client might possess high-resolution photographs, while another works with sketches or artistic renderings. Standard prompt tuning methods are typically "domain-agnostic," attempting to find a single prompt that generalizes across all participants. As shown in Figure 1, when the domain gap is substantial, these one-size-fits-all prompts fail to bridge the divide, leading to suboptimal performance.

Comparison of Original CLIP, Basic Prompt Learning, and the proposed ADAPT framework. ADAPT achieves superior accuracy by being domain-aware.

The ADAPT Framework

To overcome the limitations of domain-agnostic tuning, we introduce ADAPT (FederAted Domain-Aware Prompt Tuning). ADAPT moves away from the "universal prompt" approach by learning a library of prompts tailored to specific domains.

Dual Prompting and Domain Routing

The core of ADAPT lies in its dual-prompting architecture. It maintains both visual prompts (integrated into the image encoder) and textual prompts (appended to class names in the text encoder) for every potential domain in the system.

During inference, the vision encoder utilizes the visual prompts to automatically detect the domain correspondence of an input image. This "Domain Routing" mechanism calculates attention scores that determine which domain-specific textual prompts should be prioritized. If an image is identified as a "sketch," the model assigns higher weight to the corresponding "sketch-style" textual representation.

Optimization and Stability

As illustrated in Figure 2, the model is optimized using a multi-task loss function:

  1. Object Classification Loss: The standard cross-entropy loss for category prediction.
  2. Domain Correspondence Loss: A specialized loss that ensures visual and textual prompts for the same domain are aligned within the shared embedding space.

To maintain training stability across decentralized clients, ADAPT employs Momentum Updates. When a client receives prompt updates from the global server, it applies an exponential moving average to integrate the new parameters. This prevents the local model from being "shocked" by sudden parameter shifts from disparate domains.

The ADAPT architecture featuring dual encoders, domain routing via cross-attention, and dual loss functions for classification and domain alignment.

Experimental Evaluation

We evaluated ADAPT across three major domain adaptation benchmarks: DomainNet (6 domains, 345 categories), OfficeHome (4 domains, 65 categories), and PACS (4 domains, 7 categories).

Key Results

  • Superior Accuracy: On the challenging DomainNet dataset, ADAPT achieved an average accuracy of 68.4%. This represents a 14.8% improvement over zero-shot CLIP (53.6%) and a 5.2% gain over standard federated prompt tuning (63.2%).
  • Extreme Efficiency: ADAPT achieves state-of-the-art performance while sharing only 0.08M parameters (roughly 16.9k to 80k per round). This is a fraction of the 86M parameters required by traditional full-model fine-tuning methods like FedAvg.
  • Robustness to Data Scarcity: In "few-shot" scenarios, where clients have as few as 1 or 2 images per class, ADAPT consistently outperformed baselines, demonstrating the data efficiency of domain-aware prompts.

Discussion and Insights

Beyond raw performance, ADAPT offers several qualitative advantages. By training and sharing a very sparse set of parameters, the framework is inherently more resistant to "gradient inversion" attacks, where an adversary attempts to reconstruct private training data from shared gradients.

Furthermore, analysis of the learned prompts reveals that they capture abstract, high-level stylistic semantics. When attempting to decode these prompts back into natural language, they do not map to simple keywords like "sketch" or "photo" but rather to complex stylistic features that the model uses to bridge the domain gap.

Conclusion and Future Work

ADAPT demonstrates that domain awareness is a critical component for successfully applying Vision-Language Models to Federated Learning. While highly effective, the current framework assumes a fixed number of domains. Future research will focus on "open-set" domain recognition, allowing the model to identify and adapt to entirely new styles encountered during deployment. Additionally, improving the interpretability of these "black-box" prompts remains a key area for exploration.

Summary updated

BibTeX
@misc{wei2023learning,
  author = {Guoyizhe Wei and Feng Wang and Anshul Shah and Rama Chellappa},
  title = {{Learning to Prompt Your Domain for Vision-Language Models}},
  year = {2023},
  eprint = {2310.03103},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.03103},
}
Figure