Federated Text-driven Prompt Generation for Vision-Language Models

Chen Qiu, Xingyu Li, Chaithanya Kumar Mummadi, Madan Ravi Ganesh, Zhenzhen Li, Lu Peng, Wan-Yi LinICLR 2024

TL;DR

FedTPG moves beyond static, learned prompt vectors in Federated Learning by training a lightweight prompt generator that creates context-aware prompts from text inputs. This approach significantly improves the ability of Vision-Language Models (like CLIP) to generalize to new, unseen classes and datasets while maintaining data privacy across multiple clients.

The Challenge: Static Prompts in Federated Learning

Vision-Language Models (VLMs) like CLIP are incredibly powerful but expensive to fine-tune. To adapt them to specific tasks, researchers use "prompt learning"—replacing manual prompts like "a photo of a [class]" with learnable "soft" prompt vectors.

In a Federated Learning (FL) setting, multiple clients (like different hospitals or mobile devices) collaborate to train a model without sharing their private data. Current methods (e.g., FedCoOp) learn a single set of fixed prompt vectors. However, these static vectors suffer from a major flaw: they overfit to the specific classes seen during training and fail to generalize to "unseen" classes or entirely new datasets. Because these prompts lack contextual awareness, they don't change based on what the model is actually looking for.

Proposed Method: FedTPG

To address this, the authors propose FedTPG (Federated Text-driven Prompt Generation). Instead of learning a fixed set of numbers (vectors), they learn a small neural network called a Prompt Generator.

Comparison of CoOp and FedTPG
  1. Text-Driven Generation: The generator takes the embeddings of class names (from CLIP’s own text encoder) as input.
  2. Cross-Attention Mechanism: It uses a cross-attention layer where a learnable "query" interacts with the task-specific text "keys" and "values." This allows the model to "distill" the most important semantic information from the class names into the prompt.
  3. Context-Aware Prompts: Because the prompt is generated from the text, it naturally changes depending on the task (e.g., recognizing types of flowers vs. types of cars).
FedTPG Architecture

Federated Pipeline: In each round of FL, clients download the global generator, train it locally on their specific data for a few steps, and send the updated generator weights back to a central server for aggregation.

Experimental Setup

The researchers evaluated FedTPG across a diverse suite of nine image classification datasets to test its versatility:

  • General Objects: Caltech101
  • Fine-grained: OxfordPets, StanfordCars, Flowers102, FGVCAircraft
  • Food/Scenes/Actions: Food101, SUN397, UCF101
  • Textures: DTD (Describable Textures Dataset)

They also tested "domain shift" using ImageNet and its variants (ImageNetV2, -Sketch, -A, -R) to see how the model handles stylistic changes in images.

Key Insights and Results

  • Context is King: Static prompts are "blind" to the task. By conditioning the prompt on class names, the model gains a "semantic anchor" that helps it understand new categories it hasn't seen before.
  • Diversity as a Strength: In FL, having many clients with different datasets is usually a challenge (non-IID data). Here, it's an advantage. Training the generator on a wide variety of tasks across many clients helps it learn a more robust, generalized mapping from text to prompts.
  • Visualizing Generalization: Using PCA (Principal Component Analysis) to visualize the prompts, the authors showed that FedTPG's prompts for different datasets naturally cluster together based on context. This proves the generator is actually learning to distinguish between different domains (like "textures" vs. "animals").
  • Superior Generalization: FedTPG outperformed existing federated methods (like FedCoOp and FedMaple) on unseen classes by an average of 4.32% and on entirely new datasets by 1.82%.
  • Robustness & State-of-the-Art: The method proved robust to the "participation rate" of clients, meaning it works well even if only a small fraction of devices are available to train at any given time. On the challenging ImageNet benchmark, FedTPG achieved the highest accuracy on both the source dataset and four different domain-shifted versions, showing it handles "real-world" visual noise better than its predecessors.

Limitations and Future Work

  • Dependency on Class Names: Since the system is "text-driven," its performance relies on the quality and descriptiveness of the class names provided.
  • Computational Overhead: While the authors describe the generator as "lightweight," it still adds a small amount of extra computation and memory compared to using fixed vectors.
  • Future Directions: The authors suggest that future work could explore using more descriptive text (like Wikipedia definitions) instead of just class names to further enrich the context provided to the generator.

Summary updated

BibTeX
@inproceedings{qiu2024federated,
  author = {Chen Qiu and Xingyu Li and Chaithanya Kumar Mummadi and Madan Ravi Ganesh and Zhenzhen Li and Lu Peng and Wan-Yi Lin},
  title = {{Federated Text-driven Prompt Generation for Vision-Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=NW31gAylIm},
}
Figure