Prompt Distribution Learning

Yuning Lu, Jianzhuang Liu, Yonggang Zhang, Yajing Liu, Xinmei TianCVPR 2022

Abstract: We present prompt distribution learning for effectively adapting a pre-trained vision-language model to address downstream recognition tasks. Our method not only learns low-bias prompts from a few samples but also captures the distribution of diverse prompts to handle the varying visual representations. In this way, we provide high-quality task-related content for facilitating recognition. This prompt distribution learning is realized by an efficient approach that learns the output embeddings of prompts instead of the input embeddings. Thus, we can employ a Gaussian distribution to model them effectively and derive a surrogate loss for efficient training. Extensive experiments on 12 datasets demonstrate that our method consistently and significantly outperforms existing methods. For example, with 1 sample per category, it relatively improves the average result by 9.1% compared to human-crafted prompts.

Introduction

Vision-Language Models (VLMs) like CLIP have revolutionized computer vision by aligning images with natural language. However, their performance is highly sensitive to the "prompt"—the text description used to identify a class (e.g., "a photo of a {class}"). Current approaches face two main hurdles: manual bias and intra-class variance. Hand-crafting prompts is time-consuming and often sub-optimal, especially for specialized tasks like satellite imagery or fine-grained textures. Furthermore, a single category contains massive visual diversity in terms of pose, lighting, and background. Existing "prompt tuning" methods, such as CoOp, learn a single static vector (a "soft prompt"), which often fails to capture this broad visual spectrum.

Methodology

We present Prompt Distribution Learning (ProDA), an approach that treats prompt learning as a distribution estimation problem rather than a point estimation problem. ProDA is designed to capture the wide variety of visual representations within a single category.

The ProDA framework: learning a distribution of prompt output embeddings to handle visual diversity.

Modeling the Output Space

A key insight of ProDA is modeling the output embeddings of the text encoder rather than the input word embeddings. While raw text prompts may appear scattered in the input space, their high-level embeddings naturally cluster together. This allows us to effectively model them using a multivariate Gaussian distribution.

Surrogate Loss and Diversity Constraints

Since calculating the exact classification loss over a continuous distribution is mathematically intractable, we derive a surrogate loss—an upper bound of the true loss—to enable efficient training. To ensure the learned distribution is rich and covers diverse visual angles, we implement two constraints:

  1. Position Diversity: Varying the placement of the class name within the prompt (front, middle, or end).
  2. Semantic Orthogonality: Applying a loss that encourages different prompts in the collection to be dissimilar, preventing the model from collapsing into redundant representations.

Experimental Results

ProDA was evaluated on a comprehensive suite of 12 downstream datasets, including general object recognition (ImageNet, CIFAR), fine-grained recognition (Oxford Pets, Stanford Cars), and specialized tasks (EuroSAT, DTD).

Few-shot performance of ProDA compared to baselines across 12 diverse datasets.

Performance Analysis

  • Superior Few-Shot Learning: With only 1 training sample per category, ProDA improved average results across all 12 datasets by 9.1% compared to hand-crafted prompts and 8.5% compared to CoOp.
  • Robustness in Specialized Domains: The gains were most significant in specialized datasets. On EuroSAT (satellite imagery) and DTD (textures), ProDA achieved relative improvements of 40% and 25% respectively in the 1-shot setting.
  • Scaling with Prompt Diversity: Results indicate that as the number of prompts in the collection increases, the estimation of the distribution becomes more precise, leading to enhanced classification accuracy.

Conclusion

ProDA effectively addresses the limitations of static prompt tuning by modeling the distribution of task-related content. By learning from minimal data, it discovers task-specific context that manual prompting might overlook. While currently focused on image classification, future work could extend this distribution learning approach to more complex tasks such as object detection or semantic segmentation.

Summary updated

BibTeX
@inproceedings{lu2022prompt,
  author = {Yuning Lu and Jianzhuang Liu and Yonggang Zhang and Yajing Liu and Xinmei Tian},
  title = {{Prompt Distribution Learning}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=8i1PWGl9HV},
}
Figure