Federated Domain Generalization with Domain-specific Soft Prompts Generation

Jianhan Wu, Xiaoyang Qu, Zhangcheng Huang, Jianzong Wang

TL;DR

This paper introduces FedDSPG, a novel approach for federated domain generalization (FDG) that leverages a generative model to create domain-specific soft prompts for vision-language models like CLIP. By generating diverse and adaptable prompts, FedDSPG significantly improves performance on unseen target domains in federated settings, achieving state-of-the-art results.

What Problem Does This Paper Address?

Federated learning (FL) allows training models on decentralized data while preserving privacy, but it faces challenges with "domain shift" – where data distributions vary significantly across clients (e.g., indoor vs. outdoor photos). Federated Domain Generalization (FDG) aims to tackle this by training models that can generalize to unseen target domains, even when test data is unavailable during training. Traditional prompt learning methods, while efficient for adapting models like CLIP, often struggle with domain shift in FL because they rely on hand-crafted or naively learned prompts that lack domain-specific nuances and diversity. This leads to suboptimal performance when client data distributions differ greatly.

Methods

FedDSPG addresses this by introducing a two-stage training process:

  1. Domain-Specific Soft Prompts (DSPs) Tuning: Instead of generic prompts, FedDSPG designs unique soft prompt structures for each client's domain. These DSPs are composed of domain-invariant context and domain-specific tokens, allowing them to encode richer information. CLIP's text and image encoders are used to learn these DSPs, optimizing them via cross-entropy loss.
  2. Prompts Generative Model Tuning: A Continuous Conditional Generative Adversarial Network (CcGAN) is employed to learn the latent data distribution of DSPs. This generative model learns to produce diverse and generalized DSPs, conditioned on image embeddings and noise. This adversarial process enhances the adaptability of prompts to unseen domains.

For federated aggregation, FedDSPG uses a momentum-based approach for soft prompt parameters to ensure continuity and prevent destabilizing changes due to averaging diverse domain-specific parameters.

Datasets

The paper evaluates FedDSPG on three standard image classification benchmark datasets for domain generalization:

  • Office-Home: A large-scale visual cross-domain dataset with 65 classes across four visually distinct domains (Art, Clipart, Product, Real World).
  • DomainNet: A large-scale dataset with 345 classes distributed across six domains (Clipart, Infograph, Painting, Quickdraw, Real, Sketch).
  • PACS: Features approximately 10,000 images from seven categories across four domains (Photo, Sketch, Cartoon, Art).

The experiments use a "leave-one-domain-out" protocol, where each domain is sequentially designated as the target, and the remaining domains serve as source data.

Key Insights and Ideas

  • Generative Prompts for FDG: The core innovation is using a generative model to create soft prompts, moving beyond simple prompt tuning or fixed prompt designs. This allows for dynamic and diverse prompt generation tailored to unseen domains.
  • Domain-Specific Prompt Structure: Designing prompts with explicit domain-specific tokens is crucial for capturing nuanced domain information, leading to better generalization than generic prompts.
  • Momentum Aggregation for Stability: Directly averaging domain-specific prompt parameters in FL can be unstable. Using a momentum-based aggregation helps maintain parameter continuity and improves performance.
  • Generative Models Enhance Adaptability: The CcGAN component is key to learning the underlying data distribution of prompts, enabling the generation of prompts that are highly adaptable to diverse and unseen target domains.

Key Results

FedDSPG consistently outperforms existing state-of-the-art FDG methods across the Office-Home, DomainNet, and PACS datasets. For instance, on the Office-Home dataset, FedDSPG achieves an average accuracy of 85.3%, outperforming the next best baseline (FedTPG) by a significant margin. The paper also shows that FedDSPG is robust to varying data distributions across clients, exhibiting only a marginal performance drop (around 1%) as the number of clients increases. Furthermore, FedDSPG shows superior performance compared to baselines when the number of shots exceeds one.

Limitations and Future Work

  • Computational Cost: While prompt learning is generally efficient, the generative model tuning stage might introduce additional computational overhead. The paper mentions that diffusion models for prompt generation could lead to high communication costs, implying CcGAN is chosen for efficiency.
  • Cross-Dataset Transfer: While FedDSPG shows strong performance, cross-dataset transfer experiments (training on DomainNet, testing on Office-Home/PACS) still result in performance declines, though FedDSPG still outperforms baselines. This highlights the inherent difficulty of transferring knowledge across vastly different datasets.
  • Future Work: The paper suggests that the findings provide a strong foundation for future research in FDG, particularly highlighting the untapped potential of generative techniques. Further exploration into more advanced generative models and their integration into federated learning for domain generalization is a promising direction.

Summary updated

BibTeX
@inproceedings{wu2025federated,
  author = {Jianhan Wu and Xiaoyang Qu and Zhangcheng Huang and Jianzong Wang},
  title = {{Federated Domain Generalization with Domain-specific Soft Prompts Generation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure