MaPLe: Multi-modal Prompt Learning

Muhammad Uzair Khattak, Hanoona Abdul Rasheed, Muhammad Maaz, Salman Khan, Fahad Khan · DOI

Abstract

Pre-trained vision-language (V-L) models such as CLIP have shown excellent generalization ability to downstream tasks. However, they are sensitive to the choice of input text prompts and require careful selection of prompt templates to perform well. Inspired by the Natural Language Processing (NLP) literature, recent CLIP adaptation approaches learn prompts as the textual inputs to fine-tune CLIP for downstream tasks. We note that using prompting to adapt representations in a single branch of CLIP (language or vision) is sub-optimal since it does not allow the flexibility to dynamically adjust both representation spaces on a downstream task. In this work, we propose Multi-modal Prompt Learning (MaPLe) for both vision and language branches to improve alignment between the vision and language representations. Our design promotes strong coupling between the vision-language prompts to ensure mutual synergy and discourages learning independent uni-modal solutions. Further, we learn separate prompts across different early stages to progressively model the stage-wise feature relationships to allow rich context learning. We evaluate the effectiveness of our approach on three representative tasks of generalization to novel classes, new target datasets and unseen domain shifts. Compared with the state-of-the-art method Co-CoOp, MaPLe exhibits favorable performance and achieves an absolute gain of 3.45% on novel classes and 2.72% on overall harmonic-mean, averaged over 11 diverse image recognition datasets.

Introduction

Large-scale vision-language (V-L) models like CLIP have revolutionized computer vision by learning to associate images with natural language descriptions. However, these models are "frozen" giants; fine-tuning their billions of parameters for a specific task is computationally expensive and often destroys the general knowledge the model already possesses.

To solve this, researchers use Prompt Learning. Instead of changing the model, they learn a small set of "context tokens" (prompts) that are prepended to the input to guide the model's behavior. Current state-of-the-art methods like CoOp and Co-CoOp only apply these prompts to the text encoder. The authors argue this is sub-optimal: because CLIP relies on the alignment of two different branches (vision and language), prompting only one side creates an imbalance.

Conceptual comparison of MaPLe against existing uni-modal prompt tuning methods and its performance across 11 datasets.

Methods

The authors introduce MaPLe, which stands out through three key technical innovations:

  1. Multi-modal Prompting: MaPLe learns prompts for both the Vision Encoder and the Text Encoder. This allows both branches to dynamically adjust their representation spaces to better "meet in the middle" for a specific downstream task.
  2. Deep Prompting: Instead of just adding prompts at the very first layer (shallow prompting), MaPLe introduces separate learnable prompts across multiple early transformer layers (up to depth $J$). This allows the model to learn a hierarchy of task-specific features.
  3. Vision-Language Coupling: To ensure the two branches don't drift apart, MaPLe uses a V-L Coupling Function (denoted as $\mathcal{F}$). The vision prompts are explicitly derived from the language prompts via a shared linear layer. This "bridge" ensures mutual synergy and allows gradients to flow between the two modalities during training, promoting a unified solution.
The MaPLe architecture: deep multi-modal prompts are coupled via a shared function to ensure alignment across vision and language branches.

Experimental Setup

The researchers evaluated MaPLe across 11 diverse image recognition datasets to test its versatility:

  • Generic Objects: ImageNet, Caltech101.
  • Fine-grained Categories: OxfordPets, StanfordCars, Flowers102, Food101, FGVCAircraft.
  • Specialized Domains: SUN397 (scenes), DTD (textures), EuroSAT (satellite imagery), UCF101 (action recognition).

They also tested Domain Generalization using four ImageNet variants (ImageNet-V2, -Sketch, -A, and -R) to evaluate robustness to out-of-distribution data.

Key Results

  • Base-to-Novel Generalization: When trained on "base" classes and tested on "novel" (unseen) classes, MaPLe achieved an absolute gain of 3.45% on novel classes and 2.72% on the overall harmonic mean over the previous state-of-the-art, Co-CoOp.
  • Cross-Dataset Transfer: A MaPLe model trained only on ImageNet showed superior "plug-and-play" performance when tested directly on the other 10 datasets, proving it learns more robust, generalizable features.
  • Domain Robustness: MaPLe consistently outperformed CLIP and Co-CoOp on all four ImageNet domain-shift datasets, showing it is less likely to be fooled by style changes or different image distributions.

Discussion and Insights

  • Synergy is Secret Sauce: Prompting both branches together is far more effective than prompting them independently. The coupling function ensures that when the text side learns a new concept, the vision side adapts its "eyes" accordingly.
  • Depth Matters: Performance improves as prompts are inserted deeper into the model (up to a point). Shallow prompts only affect the initial representation, while deep prompts allow the model to refine its internal reasoning through the transformer layers.
  • Efficiency: Despite prompting two branches, MaPLe is highly efficient. It only adds a tiny fraction (0.1%) of extra FLOPs compared to uni-modal methods and maintains high inference speeds (FPS).

Limitations

While MaPLe is a significant step forward, the authors note that performance is sensitive to the choice of prompt depth ($J$) and prompt length. Additionally, prompt initialization still impacts the final result, suggesting further research is needed into how these prompts interact with pre-trained knowledge.

Code and pre-trained models are available at https://github.com/muzairkhattak/multimodal-prompt-learning.

Summary updated

BibTeX
@misc{khattak2022maple,
  author = {Muhammad Uzair Khattak and Hanoona Abdul Rasheed and Muhammad Maaz and Salman Khan and Fahad Khan},
  title = {{MaPLe: Multi-modal Prompt Learning}},
  year = {2022},
  eprint = {2210.03117},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.03117},
}
Figure