Zero-Shot Image Labels
Write each class as a sentence, embed them once, and label photos by nearest text. No training photos needed for new names.
Why Does This Exist?
New classes arrive faster than labels. A pet app adds a breed a week, and collecting thousands of training photos per breed each time is hopeless. Zero-shot classification reuses a joint image-text space instead: encode each class name as sentences once, embed each photo once, and label by nearest text. Naming plus matching replaces training plus labeling.
It assumes one prerequisite: an image-text embedding where cosine similarity means semantic closeness, the setup behind modern classifiers covered in image classification. This page covers prompt classification of whole images only. Open-vocabulary detectors that add boxes are a separate topic.
Think of It Like This
Sorting mail by reading name cards aloud
A sorter never met the tenants but holds name cards, each read aloud in eighty tones of voice. Every letter goes to the card it sounds closest to, and a new tenant needs only a new card, never a retraining of the sorter.
Photos are letters, prompt readings are the eighty tones, and cosine similarity is closeness of sound. Where it stops: tenant names are exact, while photo subjects vary by phrasing, so wording moves accuracy by points.
How It Actually Works
Encode the photo to a unit-norm vector . For each class name , encode prompt templates such as a photo of a cat, then average them into one text prototype . Averaging over templates damps wording noise. Score cosine similarities scaled by , apply softmax, and take the argmax: the label is . Prompt tuning per domain with a few labeled shots is allowed, but then the setup is few-shot rather than zero-shot.
Worked example
A photo scores cat , dog , fox . With scale the logits are , , . Exponentials are , , , summing to about . The cat probability is . The similarity gap becomes near-certainty after scaling, which is why matters as much as the embeddings. At dataset scale, CLIP reaches percent top-1 on ImageNet with no training labels, about matching a supervised ResNet-50.
Watch Out For
One template deciding everything
A single a photo of a X prompt swings accuracy by points with article and plural changes, and classes flip on wording alone. The symptom is accuracy that collapses when a user rephrases a class name. Always ensemble the template set and test paraphrases before quoting a number.
Reading 76 percent as task-ready
ImageNet top-1 measures single centered objects, so the headline number overstates performance on cluttered, multi-object, or fine-grained photos. The symptom is a demo that shines on curated images and stumbles on phone photos. Re-measure on a sample of the deployment distribution before promising the headline figure.
The Quick Version
- Zero-shot classification labels photos by nearest class sentence in a joint embedding.
- Eighty templates per class average into one prototype that damps wording noise.
- Worked numbers: similarities , , scale to cat probability .
- CLIP reaches percent top-1 on ImageNet with no training photos.
- Wording shifts accuracy by points, so ensemble prompts and re-measure on deployment photos.