Papers › Learning to Prompt for Vision-Language Models
Learning to Prompt for Vision-Language Models
Kaiyang Zhou, Jingkang Yang, Chen Change Loy, Ziwei Liu
Large pre-trained vision-language models like CLIP have shown great potential in learning representations that are transferable across a wide range of downstream tasks. Different from the traditional representation learning that is based mostly on discretized labels, vision-language pre-training aligns images and texts in a common feature space, which allows zero-shot transfer to a downstream task via prompting, i.e., classification weights are synthesized from natural language describing classes of interest. In this work, we show that a major challenge for deploying such models in practice is prompt engineering, which requires domain expertise and is extremely time-consuming -- one needs to spend a significant amount of time on words tuning since a slight change in wording could have a huge impact on performance. Inspired by recent advances in prompt learning research in natural language processing (NLP), we propose Context Optimization (CoOp), a simple approach specifically for adapting CLIP-like vision-language models for downstream image recognition. Concretely, CoOp models a prompt's context words with learnable vectors while the entire pre-trained parameters are kept fixed. To handle different image recognition tasks, we provide two implementations of CoOp: unified context and class-specific context. Through extensive experiments on 11 datasets, we demonstrate that CoOp requires as few as one or two shots to beat hand-crafted prompts with a decent margin and is able to gain significant improvements over prompt engineering with more shots, e.g., with 16 shots the average gain is around 15% (with the highest reaching over 45%). Despite being a learning-based approach, CoOp achieves superb domain generalization performance compared with the zero-shot model using hand-crafted prompts.
In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.
Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.
For agents, on Syntology's MCP service (how to connect):
get_harvested_code_for_paper(arxiv_id="2109.01134")get_code(code_sha256="…")with a sample'scode_sha256from the list belowget_citation_path(paper_1="2109.01134", paper_2="…")with another paper's arXiv id or titleget_concepts_for_paper(arxiv_id="2109.01134")
Code
No sample from the archive's official repository (kaiyangzhou/coop) is linked to this paper; the 12 samples below come from 3 community repositories. Syntology harvested code from kaiyangzhou/coop for another paper.
kaiyangzhou/coop: Syntology's graph links these samples to Visual-Language Prompt Tuning with Knowledge-guided Context Optimization (arXiv:2303.13283; that paper's own run record: 1 ran (of which 0 constructed an object rather than computing a result; 1 with no instrument failure: 1 honoured, 0 violated, 0 with no contract checked; 0 where Syntology's instrument failed) · 2 unverified); nothing checks that they implement this paper's method.
Syntology 12 code samples harvested from 3 repositories linked to this paper: 3 ran (of which 1 constructed an object rather than computing a result; 2 with no instrument failure: 0 honoured, 0 violated, 2 with no contract checked; 1 where Syntology's instrument failed) · 9 unverified. Where Syntology's instrument failed: 1 where our contract draft was wrong; failures of Syntology's instrument, not of the code.
By repository: community (archive-listed): 12 samples from 3 repositories, 3 ran (2 with no instrument failure; 1 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.
No sample is linked to this paper from 13 of its repositories that Syntology harvested for other papers:
- kaiyangzhou/coop, official repository: harvested for another paper, listed under the repository
- ArsenalCheng/Meta-Adapter, community (archive-listed): harvested for another paper, listed under the repository
- Gahyeonkim09/AAPL, community (archive-listed): harvested for another paper, listed under the repository
- azshue/TPT, community (archive-listed): harvested for another paper, listed under the repository
- farinamatteo/zero, community (archive-listed): harvested for another paper, listed under the repository
- healthx-lab/biomedcoop, community (archive-listed): harvested for another paper, listed under the repository
- kenomo/industrial-clip, community (archive-listed): harvested for another paper, listed under the repository
- mlvlab/dapt, community (archive-listed): harvested for another paper, listed under the repository
- muzairkhattak/multimodal-prompt-learning, community (archive-listed): harvested for another paper, listed under the repository
- muzairkhattak/protext, community (archive-listed): harvested for another paper, listed under the repository
- saic-fi/bayesian-prompt-learning, community (archive-listed): harvested for another paper, listed under the repository
- srvcodes/clap4clip, community (archive-listed): harvested for another paper, listed under the repository
- vill-lab/2024-aaai-hpt, community (archive-listed): harvested for 2 other papers, listed under the repository
Levels written on 2026-09-22 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.
18 repositories listed; official and paper-mentioned ones first.
Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.
A paper named beside a repository with no sample linked to this paper is shown with that paper's own run record, not this paper's: “ran” means executed on a synthesized input, not that the code is correct, and “where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Papers are listed in arXiv-id order, at most three per repository.
Code Syntology ran Syntology
12 samples harvested: 3 ran (of which 1 constructed an object rather than computing a result; 2 with no instrument failure: 0 honoured, 0 violated, 2 with no contract checked; 1 where Syntology's instrument failed) · 9 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page has not changed since , the first build that kept a record date for it; when this build read Syntology's graph is in the build record. That date is not when the samples ran.
Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.
Harvested from 3 repositories linked to this paper, official or community; the list below is grouped by repository, each group headed by its name and what it is to the paper. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.
Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.
Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.
A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.
8a2b72f24481ca15 · report
fixture: returned PromptLearner · level recorded 2026-09-22 aa2102c5842a8045 · report
fixture: signature x:Tensor/3/float, attn_mask:Tensor/2/float · returned Tensor · level recorded 2026-09-22 c568c664a705cfa6 · report
fixture: signature descriptor_text_prompt:dict/0/?, max_len_quantile:float/0/float · returned tuple · level recorded 2026-09-22 e8079fe48af584cb · report
0f982cfc0f69d842 · report
Method as code Syntology
What Syntology's graph records as this paper's claimed method, lifted into code: each assembly names its bricks (functions and classes), each with its own role and its own verification level. An assembly is not a check that the code implements the method correctly or reproduces the paper's results. Levels are each brick's own verification level in Syntology's graph (level 0: no recorded run), listed brick by brick and never combined into one level; “ran” means the brick executed on a synthesized input, not that its output is correct, and the instrument figure counts failures of Syntology's instrument, not of the code. Where a model read the code against the paper's claim, each assembly's label verdict is one model's judgement, kept in this page's JSON twin; it is not calibrated, so no card prints it. Siblings are assemblies lifted from this paper in the same batch for the same method: alternative readings kept side by side; none replaces or supersedes another.
3 assemblies on this paper: 3 harvested, 0 generated, listed in 1 groups (siblings lifted in one batch form one group).
3 sibling assemblies for Context Optimization (CoOp) (harvested), lifted in the same batch on 2026-09-09: alternative readings kept side by side; none replaces or supersedes another.
harvested Assembly for Context Optimization (CoOp) (graph method: Context Optimization (CoOp)). 1 brick; individually on a fixture: 1 ran (of which 1 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 0 where Syntology's instrument failed) · 0 unverified; the one sample that ran constructed an object rather than computing a result. The assembly has not been run end-to-end.
one of 3 siblings
- PromptLearner entry · level 1 · ran ·
8a2b72f24481ca15
harvested Assembly for Context Optimization (CoOp) (graph method: Context Optimization (CoOp)). 1 brick; individually on a fixture: 0 ran · 1 unverified. The assembly has not been run end-to-end.
one of 3 siblings
- PromptLearner entry · level 0 · unverified ·
39be90830c4c1621
harvested Assembly for Context Optimization (CoOp) (graph method: Context Optimization (CoOp)). 13 bricks; individually on a fixture: 5 ran (of which 1 constructed an object rather than computing a result; 2 with no instrument failure: 0 honoured, 0 violated, 2 with no contract checked; 3 where Syntology's instrument failed) · 8 unverified. The assembly has not been run end-to-end.
one of 3 siblings
- CustomCLIP_TAP entry · level 0 · unverified ·
7c02c9c890628418 - TextEncoder model · level 0 · unverified ·
c1fabc9fbf753209 - TextPromptLearner model · level 0 · unverified ·
0746a2da2f73c0eb - VisualEncoder model · level 0 · unverified ·
e1f5a7fb2fb95e19 - VisualPromptLearner model · level 0 · unverified ·
d75235fc5acba1a6 - load_clip_to_cpu helper · level 0 · unverified ·
0f982cfc0f69d842 - wordify helper · level 1 · ran · our draft was wrong ·
1812ba359126089a - make_description_batch helper · level 1 · ran · our draft was wrong ·
c568c664a705cfa6 - load_gpt_descriptions helper · level 0 · unverified ·
bf5154cf822c8f6a - AttentionPooling model · level 0 · unverified ·
e8079fe48af584cb - LayerNorm helper · level 1 · ran ·
4f7191c8173fb1eb - load_json helper · level 1 · ran · our draft was wrong ·
1069918b276d2855 - CrossAttention model · level 1 · ran ·
aa2102c5842a8045
Each brick ends with its code_sha256, Syntology's identity for that exact code; click one to copy the get_code call that returns it. For agents, on Syntology's MCP service: assembly(arxiv_id="2109.01134") returns these assemblies with each brick's role and wiring (how to connect).
Tasks
Results from the paper archive 2025-07-28
| Task | Dataset | Model | Metric | Value | Rank at snapshot | Leaderboard | Report |
|---|---|---|---|---|---|---|---|
| Few-shot Age Estimation | MORPH Album2 | CoOp | MAE | 5.09 | #2 of 2 | Archive leaderboard | report |
| Few-shot Age Estimation | MORPH Album2 | CoOp | MAE (16 shot) | 3.23 | #2 of 2 | Archive leaderboard | report |
| Few-shot Age Estimation | MORPH Album2 | CoOp | MAE (2 shot) | 4.50 | #2 of 2 | Archive leaderboard | report |
| Few-shot Age Estimation | MORPH Album2 | CoOp | MAE (4 shot) | 3.81 | #2 of 2 | Archive leaderboard | report |
| Few-shot Age Estimation | MORPH Album2 | CoOp | MAE (8 shot) | 3.57 | #2 of 2 | Archive leaderboard | report |
Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.
Methods
Introduced by this paper: CoOp
Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections