Learning to Prompt Your Domain for Vision-Language Models

Guoyizhe Wei, Feng Wang, Anshul Shah, Rama Chellappa

TL;DR

Federated learning often struggles when clients have data from vastly different domains, such as photos versus sketches. This paper introduces ADAPT (FederAted Domain-Aware Prompt Tuning), a method that enables CLIP-based models to recognize an image's domain and apply specialized, learnable prompts to improve classification accuracy while maintaining extreme communication efficiency and data privacy.

What Problem Does This Paper Address?

Federated Learning (FL) allows multiple participants to train a shared model without ever exchanging their raw, private data. However, real-world FL faces a major hurdle: domain shift. While most research focuses on label imbalance (e.g., one client has more "cats" than "dogs"), this paper tackles differences in feature distributions—where one client might have high-quality photos while another has stylized clipart or hand-drawn sketches.

Vision-Language models like CLIP are great candidates for FL because they can be adapted using "prompt tuning"—training only a tiny set of input tokens rather than the whole massive model. However, standard prompt tuning is domain-agnostic. If you train a single prompt to handle both "real-world photos" and "quick sketches," the model ends up being a "jack of all trades, master of none," leading to significant performance drops.

Methods

The authors propose ADAPT, a framework that makes prompt tuning "domain-aware." Instead of one global prompt, ADAPT maintains a set of $n$ prompts, where $n$ is the number of domains in the federated system.

Figure 1: An intuitive comparison of our ADAPT to zero-shot CLIP and the basic domain-agnostic prompt learning approach.

Key technical components include:

  • Dual Prompting: ADAPT uses both visual prompts (learnable tokens added to the image patches) and textual prompts (learnable tokens added to the class names).
  • Domain Correspondence: The vision encoder uses the visual prompts to calculate "attention scores." These scores act as a domain detector, determining how much the input image resembles each of the $n$ known domains.
  • Cross-Attention Mechanism: These domain scores are used to weight the output of the $n$ different textual prompts. If the model thinks an image is a "sketch," it gives more weight to the "sketch-specific" textual prompt.
  • Momentum Updates: To keep training stable, clients update their local domain prompt via gradients but incorporate prompts from other domains using a momentum-based moving average.
Figure 2: Local training framework. We load a pre-trained CLIP model and freeze both its image and text encoders. For each client, we feed the text encoder with n text prompts followed by class names, where one is optimized by the gradients and the rest n −1 are loaded from other clients with momentum update. We feed the image encoder with n learnable prompt tokens followed by patch-wise embedded images, where the prompt tokens are optimized by gradients.

Datasets

The researchers evaluated ADAPT on three major domain adaptation benchmarks:

  1. DomainNet: A massive dataset with ~600,000 images across 345 categories and 6 distinct domains (Clipart, Infograph, Painting, Quickdraw, Real, Sketch).
  2. OfficeHome: 15,500 images in 65 classes across 4 domains (Art, Clipart, Product, Real-world).
  3. PACS: ~10,000 images in 7 categories across 4 domains (Photo, Art painting, Cartoon, Sketch).

Key Insights and Ideas

  • Domain Detection is the Key: The core "aha moment" is that the model shouldn't just try to classify the object; it should first understand the context (domain) of the image. By explicitly modeling domain correlations, the model can pick the right "tool" (prompt) for the job.
  • Efficiency as a Privacy Shield: Because ADAPT only trains and shares a tiny fraction of parameters (roughly 0.1% of the total model), it is remarkably resilient to privacy attacks. Traditional "Deep Leakage from Gradient" (DLG) attacks, which try to reconstruct images from model updates, fail because there isn't enough information in the sparse prompt gradients to recover the original pixels.
  • Robustness to Few-Shot Learning: ADAPT performs exceptionally well even when clients have very few images (e.g., only 1 or 2 samples per class). This makes it highly practical for real-world scenarios where data is scarce.

Key Results

ADAPT significantly outperformed both zero-shot CLIP and existing federated learning methods:

  • Accuracy: On DomainNet, ADAPT achieved 68.4% average accuracy, a massive 14.8% improvement over zero-shot CLIP (53.6%) and a 5.2% lead over the best domain-agnostic prompt method (63.2%).
  • Communication Overhead: ADAPT requires sharing only about 0.08M parameters (or as low as 16.9k in some configurations), compared to the 86M parameters required by traditional fine-tuning methods like FedAvg or FedProx.
  • Privacy: Qualitative tests showed that gradient-based reconstruction attacks resulted in meaningless noise rather than recognizable images, confirming the privacy benefits of the low-parameter approach.
Examples of failed image reconstructions from gradients, demonstrating ADAPT's superior privacy preservation.

Limitations and Future Work

  • Fixed Domain Count: The current implementation assumes the number of domains is known and fixed. In highly dynamic federated systems, the number of domains might change or be unknown.
  • Inference Complexity: The two-step inference process (domain detection followed by weighted classification) adds a small amount of computational overhead compared to a single-pass prompt.
  • Future Directions: The authors suggest exploring how to handle "unseen" domains that weren't present during the federated training phase, potentially moving toward a more open-world domain adaptation.

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