Consistency-guided Prompt Learning for Vision-Language Models

Shuvendu Roy, Ali Etemad

TL;DR

CoPrompt is a novel fine-tuning method for vision-language models (like CLIP) that prevents overfitting in few-shot settings by enforcing a consistency constraint between the trainable model and its frozen, pre-trained ancestor. By combining both prompt tuning and adapters with input perturbations—including descriptive text generated by LLMs—it achieves a new state-of-the-art in generalizing to unseen classes and datasets.

Introduction: The Fine-Tuning Trade-off

Vision-language models (VLMs) like CLIP are famous for their "zero-shot" capabilities—the ability to recognize objects they weren't explicitly trained on. However, when researchers try to fine-tune these massive models on specific small datasets (few-shot learning), they run into a classic trade-off: the model gets very good at the specific task but "forgets" its general knowledge, leading to poor performance on new, unseen classes.

Existing methods try to solve this by only training a tiny fraction of the parameters using "prompts" or "adapters." Even then, these models often overfit the small training set. The authors of CoPrompt set out to find a way to let the model learn new tasks while strictly anchoring its behavior to the original, highly generalized foundation model.

Methods: Consistency-Guided Prompt Learning

The core of CoPrompt is Consistency-guided Prompt learning. Instead of just minimizing classification error, the model is forced to ensure its internal representations don't drift too far from the original pre-trained model.

Detailed architecture of CoPrompt showing the dual tuning paradigm and consistency constraints.

Key components of the architecture include:

  1. Dual Tuning Paradigm: Unlike previous works that chose either prompting (adding learnable vectors to the input) or adapters (adding learnable layers inside the network), CoPrompt uses both. This provides flexibility in both the input and output spaces of the model.
  2. Consistency Constraint: The authors use a cosine distance loss to ensure the embeddings produced by the trainable model are "consistent" with the frozen pre-trained model.
  3. Input Perturbation: To make the consistency constraint more robust, the system compares perturbed inputs against standard ones:
  4. Text Branch: They use an LLM to turn a simple prompt like "a photo of a dog" into a descriptive sentence like "a four-legged animal with fur, floppy ears, and a wagging tail." They then enforce consistency between the trainable model's view of the simple prompt and the frozen model's view of the descriptive one.
  5. Image Branch: They apply standard data augmentations (crops, flips) and ensure the trainable model's view of the augmented image matches the frozen model's view of the original.

Key Insights

  • Regularization via Distillation: CoPrompt essentially treats the frozen foundation model as a "teacher" that constantly reminds the "student" (the trainable model) not to lose its general common sense while learning a specific task.
  • The Power of Description: Using an LLM to generate descriptive prompts acts as a powerful regularizer. It forces the text encoder to focus on the semantic meaning of a class rather than just the specific word label.
  • Angular Similarity over Magnitude: The choice of cosine distance for the consistency loss was intentional. It captures the direction (semantic meaning) of the vectors rather than their magnitude, which yields better generalization.
  • Synergy of Prompts and Adapters: While adding more parameters usually risks more overfitting, the consistency constraint acts as a safety net, allowing the model to benefit from the increased representational power of having both prompts and adapters.

Key Results

The authors evaluated CoPrompt across a massive suite of benchmarks, including base-to-novel generalization across 11 datasets, cross-dataset evaluation, and domain generalization.

Base-to-novel generalization results across 11 datasets.
  • New State-of-the-Art: CoPrompt outperformed previous leading methods (like MaPLe and PromptSRC) in the harmonic mean of base and novel class accuracies across 11 datasets.
  • Novel Class Boost: It showed a significant 1.13% improvement in recognizing novel (unseen) classes compared to the previous best method, without sacrificing performance on the base classes it was trained on.
  • Cross-Dataset Success: When trained on ImageNet and tested elsewhere, it achieved an average accuracy of 67.0%, outperforming MaPLe by 0.70%.
  • Efficiency: Despite the performance gains, CoPrompt only adds a negligible number of parameters (<1% increase over MaPLe).

Limitations and Future Work

  • Computational Cost: Training CoPrompt requires two forward passes (one for the frozen model and one for the trainable model) for every iteration. This makes training roughly 2x slower and more memory-intensive than simpler methods.
  • LLM Dependency: The method relies on an external LLM to generate descriptive prompts. While the authors showed that the specific version of GPT doesn't matter much, it adds a pre-processing step to the pipeline.
  • Inference Time: While training is slower, inference is just as fast as other methods because the "teacher" model is discarded after training. Future work could look into optimizing the training efficiency.

Summary updated

BibTeX
@inproceedings{roy2024consistency,
  author = {Shuvendu Roy and Ali Etemad},
  title = {{Consistency-guided Prompt Learning for Vision-Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=wsRXwlwx4w},
}
Figure