Prompting through Prototype: A Prototype-based Prompt Learning on Pretrained Vision-Language Models

Yue Zhang, Hongliang Fei, Dingcheng Li, Tan Yu, Ping LiarXiv 2022 · DOI

Introduction

Pretrained Vision-Language Models (PVLMs) like CLIP have transformed computer vision by enabling models to interpret images through textual descriptions. Adapting these models to specific downstream tasks typically involves prompting. However, current methods face a significant trade-off between efficiency and effectiveness.

Task-level prompting uses a single universal prompt for all images, which is efficient but lacks the nuance to capture diversity within a dataset. Conversely, instance-level prompting generates unique prompts for every image, offering high precision but requiring complex networks that are prone to overfitting in few-shot scenarios. Prompting through Prototype (PTP) is proposed to bridge this gap by grouping similar images and assigning them optimized, shared prompting strategies.

The PTP Framework

The PTP architecture introduces a middle ground between universal and per-instance prompts. It consists of three core components:

  1. Image Prototypes ($K$): Learnable centroids in the latent embedding space that represent clusters of similar images.
  2. Prompt Prototypes ($K$): Each image prototype is paired with a "soft prompt"—a sequence of learnable continuous vectors that serve as a specialized template for that cluster.
  3. Similarity-based Weighting: For a given input image, the model calculates its similarity to each image prototype. The final prediction is a weighted summation of the outputs from all $K$ prompt prototypes.
The PTP architecture: Input images are processed by an encoder and compared against K prototypes to generate a weighted prediction.

To ensure the prototypes accurately reflect the data distribution, the authors employ two regularizers ($R_1$ and $R_2$) during training. these functions encourage prototypes to move toward the centers of image clusters while pulling training images toward their nearest prototypes.

Experimental Evaluation

The researchers evaluated PTP across seven diverse image classification benchmarks, including Caltech101 (general objects), StanfordCars (fine-grained), UCF101 (actions), and Food101. This variety tests the model's robustness across different semantic domains.

Hyper-parameter configurations for PTP across different model architectures.

The implementation details, such as prompt lengths ($m$) for different architectures and optimization settings like the AdamW optimizer and a 3e-3 learning rate, were standardized to ensure fair comparison across benchmarks.

Key Results and Insights

PTP consistently outperformed existing baselines, such as CoCoOp, across various shot counts (1 to 16 shots):

  • Performance Gains: PTP achieved absolute accuracy improvements of approximately 4% in 1-shot tasks and up to 7% in 16-shot tasks compared to state-of-the-art automated prompts.
  • Architectural Versatility: The method proved effective for both bi-encoder architectures (e.g., CLIP) and single-encoder architectures (e.g., ViLT).
  • Parameter Efficiency: By keeping the massive PVLM frozen and only updating the small set of prototypes, PTP remains highly lightweight.

A critical finding was the importance of semantic meaning in labels. Prompting struggles when class names are technical codes (e.g., "A321") rather than descriptive words (e.g., "Airplane"), as the pretrained model lacks a linguistic "hook" for the former.

Conclusion and Limitations

PTP offers a robust solution for few-shot learning by leveraging the "similar images, similar prompts" hypothesis. While highly effective, it remains dependent on the quality of label semantics and the underlying knowledge of the frozen pretrained model. Future work may explore hybrid approaches that combine prompt learning with parameter-efficient fine-tuning to better scale as more training data becomes available.

Summary updated

BibTeX
@misc{zhang2022prompting,
  author = {Yue Zhang and Hongliang Fei and Dingcheng Li and Tan Yu and Ping Li},
  title = {{Prompting through Prototype: A Prototype-based Prompt Learning on Pretrained Vision-Language Models}},
  year = {2022},
  eprint = {2210.10841},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.10841},
}
Figure