HyperAIHyperAI

Command Palette

Search for a command to run...

3 months ago

Conditional Prompt Learning for Vision-Language Models

Kaiyang Zhou Jingkang Yang Chen Change Loy Ziwei Liu

Conditional Prompt Learning for Vision-Language Models

Abstract

With the rise of powerful pre-trained vision-language models like CLIP, it becomes essential to investigate ways to adapt these models to downstream datasets. A recently proposed method named Context Optimization (CoOp) introduces the concept of prompt learning -- a recent trend in NLP -- to the vision domain for adapting pre-trained vision-language models. Specifically, CoOp turns context words in a prompt into a set of learnable vectors and, with only a few labeled images for learning, can achieve huge improvements over intensively-tuned manual prompts. In our study we identify a critical problem of CoOp: the learned context is not generalizable to wider unseen classes within the same dataset, suggesting that CoOp overfits base classes observed during training. To address the problem, we propose Conditional Context Optimization (CoCoOp), which extends CoOp by further learning a lightweight neural network to generate for each image an input-conditional token (vector). Compared to CoOp's static prompts, our dynamic prompts adapt to each instance and are thus less sensitive to class shift. Extensive experiments show that CoCoOp generalizes much better than CoOp to unseen classes, even showing promising transferability beyond a single dataset; and yields stronger domain generalization performance as well. Code is available at https://github.com/KaiyangZhou/CoOp.

Code Repositories

vill-lab/2024-aaai-hpt
pytorch
Mentioned in GitHub
hhenryd/tap
pytorch
Mentioned in GitHub
ThomasWangY/2024-AAAI-HPT
pytorch
Mentioned in GitHub
saic-fi/bayesian-prompt-learning
pytorch
Mentioned in GitHub
kaiyangzhou/coop
Official
pytorch
Mentioned in GitHub
Gahyeonkim09/AAPL
pytorch
Mentioned in GitHub
kaiyangzhou/on-device-dg
pytorch
Mentioned in GitHub
muzairkhattak/protext
pytorch
Mentioned in GitHub
healthx-lab/biomedcoop
pytorch
Mentioned in GitHub
Vill-Lab/2024-TIP-MetaPrompt
pytorch
Mentioned in GitHub
azshue/TPT
pytorch
Mentioned in GitHub

Benchmarks

BenchmarkMethodologyMetrics
prompt-engineering-on-caltech-101CoCoOp
Harmonic mean: 95.84
prompt-engineering-on-dtdCoCoOp
Harmonic mean: 64.85
prompt-engineering-on-eurosatCoCoOp
Harmonic mean: 71.21
prompt-engineering-on-fgvc-aircraftCoCoOp
Harmonic mean: 27.74
prompt-engineering-on-food-101CoCoOp
Harmonic mean: 90.99
prompt-engineering-on-imagenetCoCoOp
Harmonic mean: 73.10
prompt-engineering-on-imagenet-aCoCoOp
Top-1 accuracy %: 50.63
prompt-engineering-on-imagenet-rCoCoOP
Top-1 accuracy %: 76.18
prompt-engineering-on-imagenet-sCoCoOp
Top-1 accuracy %: 48.75
prompt-engineering-on-imagenet-v2CoCoOp
Top-1 accuracy %: 64.07
prompt-engineering-on-oxford-102-flowerCoCoOp
Harmonic mean: 81.71
prompt-engineering-on-oxford-iiit-pet-datasetCoCoOp
Harmonic mean: 96.43
prompt-engineering-on-stanford-cars-1CoCoOp
Harmonic mean: 72.01
prompt-engineering-on-sun397CoCoOp
Harmonic mean: 78.27
prompt-engineering-on-ucf101CoCoOp
Harmonic mean: 77.64

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp