Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Conditional Prompt Learning for Vision-Language Models

Conditional prompt learning fixes CoOp's poor generalization to unseen classes

  • Problem CoOp's learned prompts overfit base classes and fail on unseen classes.
  • Method CoCoOp adds an image-conditioned vector to each of CoOp's shared context vectors. A small Meta-Net built from the image encoder's features produces that vector, and only the context vectors and Meta-Net are trained while CLIP stays frozen.
  • Results CoCoOp reaches a 75.83 harmonic mean over 11 datasets in base-to-new evaluation, against 71.66 for CoOp and 71.70 for CLIP with manual prompts.

Why a fixed learned prompt fails on new classes

CoOp replaces the hand-written words of a CLIP prompt with learnable context vectors, so a few labeled images can tune the prompt instead of manual trial and error. The authors find that these context vectors do not generalize to classes that were absent from training but belong to the same dataset, which indicates that CoOp fits the base classes it saw during training.

Averaged over 11 datasets under 16 shots, CoOp's base accuracy is 82.69 while its new-class accuracy is 63.22, so the gain on base classes is largely lost on unseen classes.

Making the prompt depend on the image

CoCoOp keeps CoOp's M shared context vectors and adds an input-dependent part to each of them, so the prompt for a given image is no longer fixed. Giving each context token its own network would multiply the network size by M, so the authors instead train a single lightweight network, Meta-Net, that outputs one conditional vector for each image.

Meta-Net is a two-layer bottleneck with a Linear-ReLU-Linear structure whose hidden layer cuts the input dimension by 16 times, and its input is simply the features the image encoder produces. Each context token becomes \( v_m(x) = v_m + \pi \) with \( \pi = h_\theta(x) \), where \( h_\theta \) is Meta-Net with parameters \( \theta \), so the prompt for class i is conditioned on the input image x.

What is trained and how prediction works

Training updates only the context vectors and Meta-Net's parameters, using a cross-entropy objective, while the CLIP model stays fixed. At prediction time, the prompt for every class is built from the same image's conditional vector, passed through the text encoder, and compared with the image feature by cosine similarity to give class probabilities.

Because each image yields its own set of prompts, the text encoder must process prompts per image rather than once per mini-batch, which is the source of the cost discussed under limitations.

Experimental setup and fixed choices

CoCoOp is trained with a batch size of 1 for 10 epochs, because the instance-conditional design needs much more GPU memory and time than CoOp.

Base-to-new results over 11 datasets

Each dataset's classes are split into equal base and new halves, CoOp and CoCoOp are trained on base classes only, and both are tested on each half. Averaged over the 11 datasets, CoCoOp's new-class accuracy is 71.69, up from 63.22 for CoOp, while its base accuracy falls from 82.69 to 80.47. Its harmonic mean is 75.83, compared with 71.66 for CoOp and 71.70 for CLIP with manual prompts, so the balance between base and new classes is better than either baseline.

Base losses and where new-class gains come from

On ImageNet, new-class accuracy rises from 67.88 for CoOp to 70.43 for CoCoOp, which is above CLIP's 68.14. CoCoOp's base accuracy is below CoOp's on 9 datasets, and on 6 of those 9 the drop is under 3 percent. The largest base drop is on StanfordCars, at -7.63, but its new-class gain of +13.19 gives the authors a net improvement of 5.56 for CoCoOp on that dataset.

CoCoOp's new-class accuracy is higher than CLIP's on 4 of the 11 datasets, namely ImageNet, OxfordPets, Food101 and SUN397, and the gap remains large on FGVCAircraft.

Transfer from ImageNet to other datasets

Prompts learned on ImageNet with all 1,000 classes are applied directly to the other 10 datasets, and only prompt-learning methods are compared in this setting. The average over the 10 target datasets is 65.74 for CoCoOp and 63.88 for CoOp, with the source ImageNet accuracy at 71.02 and 71.51 respectively.

Domain generalization on ImageNet variants

The prompt is learned on ImageNet and tested on ImageNetV2, ImageNet-Sketch, ImageNet-A and ImageNet-R, with manual CLIP prompts as the zero-shot reference. CoCoOp scores 64.07 on ImageNetV2 against 64.20 for CoOp, which is slightly lower, and it scores higher on the other three: 48.75 against 47.99 on ImageNet-Sketch, 50.63 against 49.71 on ImageNet-A, and 76.18 against 75.21 on ImageNet-R.

Both learned methods are above the CLIP row on all four targets.

Initialization, context length and parameter count

The initialization study compares word-embedding initialization with random initialization from a zero-mean Gaussian with 0.02 standard deviation, while keeping the other parameters the same. Averaged over the 11 datasets, proper initialization helps both base and new classes, and the authors note that individual datasets may differ. With random initialization, context lengths of 4, 8 and 16 are compared; longer contexts mainly help the new classes, and 8 random tokens are marginally better than 4 properly initialized ones.

On ImageNet, a 60-token CoOp with 30,720 parameters reaches 70.34 harmonic mean, against 71.92 for the 4-token CoOp with 2,048 parameters and 73.10 for the 4-token CoCoOp with Meta-Net and 34,816 parameters.

DOSCO-2k results across four backbones

DOSCO-2k has seven datasets whose domain labels come from a network pre-trained on Places, and each dataset has 2,000 images in total, split 1,600 for training and 400 for validation. Both CoOp and CoCoOp use four learnable context tokens, and the checkpoint with the best validation performance is used for the test in unseen domains. With ViT-B/16, CLIP averages 67.2, CoOp averages 73.3 and CoCoOp averages 72.7, so CoCoOp is lower on average.

Limitations

CoCoOp is slow to train and uses a large amount of GPU memory when the batch size exceeds one, because each image needs its own forward pass of instance-specific prompts through the text encoder. CoOp needs only one forward pass for a mini-batch of any size, so the per-image cost is the central efficiency gap between the two methods. On 7 of the 11 datasets, CoCoOp's new-class accuracy still lags behind CLIP's, so the gap to manual prompts is not closed.

Paper info

Authors
Kaiyang Zhou, Jingkang Yang, Chen Change Loy, Ziwei Liu
Venue
arXiv · Preprint
First published
2022-3-10
Added
2026-11-12
Updated
2022-10-6
Version
v2
arXiv
2203.05557
Category
cs.CV · cs.AI · cs.CL · cs.LG
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Kaiyang Zhou, Jingkang Yang, Chen Change Loy, Ziwei Liu (2022). Conditional Prompt Learning for Vision-Language Models. arXiv:2203.05557v2. https://arxiv.org/abs/2203.05557v2

BibTeX
@misc{zhou2022conditional,
  title = {{Conditional Prompt Learning for Vision-Language Models}},
  author = {Kaiyang Zhou and Jingkang Yang and Chen Change Loy and Ziwei Liu},
  year = {2022},
  eprint = {2203.05557},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.05557v2}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up