Zero-shot image classifiers such as CLIP, a model that scores how well an image matches a piece of text, work better when each class name is expanded by a language model into a visual description. "Goldfinch" becomes "a small bird with a bright yellow body and black wings." The trouble is that the language model writes these descriptions once and never checks them. When it invents a trait the bird does not have, or describes a trait that the image model cannot actually see, the error flows straight into classification.
Programmers solved a similar problem with generated code by running it, reading the error reports, and revising. We propose to do the same for class descriptions. Each description is turned into a small executable test program that asks perception models concrete questions about a few labeled images, such as "is there a red face patch?" and "does this attribute separate goldfinch from the warbler it is confused with?" The program returns a structured report of which claims failed on which images and which confusable class pairs they failed to separate. The language model then repairs the description, and the repair is kept only if it holds up on images the loop never saw. At test time the verified descriptions are compiled back into ordinary CLIP prompts, so inference costs no more than standard zero-shot CLIP.
Core Claim
Open-loop label expansion has two failure modes. Some claimed attributes are false, and some true attributes are useless to the particular image model because it cannot detect them or they do not separate the classes that model confuses. Both are invisible without execution. Our claim is that a refinement loop driven by per-attribute, per-class-pair test reports fixes both failure modes. It should improve accuracy in the very-low-shot regime (one to four labeled images per class), and it should also measurably reduce the rate of hallucinated attributes. The claim is specific about which ingredient matters. The gain should come from the localized diagnostic report, not from the fact that the artifact is code and not from simply showing the language model a confusion matrix. The experiments are designed to separate these three explanations, and we will report the answer whichever way it falls.
Relation to Prior Work
Three works motivate the problem. CuPL, What does a platypus look like?, generates class-specific prompts with a language model and reaches 76.69% top-1 zero-shot accuracy on ImageNet. The same line of work notes that hallucinated traits hurt alignment. DesCo shows that detectors ignore descriptive modifiers unless training forces them to use them. GRAIN grounds descriptions in image regions. All three produce descriptions in a single pass. Our method adds a verification-and-repair step on top of any of them.
Two works come closest in mechanism, and the contrast with them is sharp. Bayesian Concept Bottleneck Models with LLM Priors (BC-LLM) iterates too. A language model proposes concepts, and a statistical acceptance rule on held-out data keeps or discards them, which gives 0.874 AUC on CUB. Its feedback is a single accept or reject signal per concept. The proposer never learns why a concept failed, whether because it is false, invisible to the model, or non-discriminative for a specific pair. We supply that reason. Our split-sample acceptance rule is borrowed from BC-LLM. ViperGPT writes Python programs that call detectors and visual question answering models. It is strictly single-pass, and it answers individual queries rather than building class descriptions. We reuse its idea of perception models behind a Python interface, and add the execution-feedback loop that it lacks.
On the code-refinement side, Vision-Guided Iterative Refinement for Frontend Code Generation is the nearest cross-modal loop. It renders web code and critiques the screenshot with a vision-language model, reporting up to 17.8% improvement over three cycles against 1.5% for refinement without a critic. It refines code that produces an image, whereas we refine descriptions that interpret images. Its critic ablation is exactly the kind of ablation we need. CAAFE is the closest analogue in spirit: semantic column names become feature code, and a feature is kept only if downstream validation improves (mean ROC AUC 0.798 to 0.822). We transplant its "keep only what validates" rule to vision.
Two further results shape the design as constraints. Yan et al. find that refinement gains plateau after two to four cycles, so we cap the loop and report curves against the number of rounds. Fang et al. roll back edits that cause regressions, and we do the same.
Research Program
For each class the language model first writes a description as a list of attribute claims. It also writes a short Python function that tests each claim using three kinds of perception call. The first is a CLIP similarity check on an attribute phrase. The second is an open-vocabulary detector (OWLv2 or GLIP) that localizes a part. The third is a visual question answering model (BLIP-2) queried on the crop. The functions may use control flow, for example "only check wing bars if a wing is detected."
We run the functions on a small "test split" of labeled images. The report the language model receives has four components:
- Python tracebacks from broken code.
- For each claim, the pass rate on the class's own images.
- For each claim, the pass rate on images of the two or three classes CLIP most often confuses with this class.
- The resulting margin: how much better the claim fires on its own class than on its confusers.
A claim with a low own-class pass rate is flagged as likely false or invisible. A claim that passes equally on the confusers is flagged as non-discriminative. The model rewrites, drops, or adds claims.
An edit is accepted only if accuracy on a separate "validation split" does not drop. This split-sample rule follows BC-LLM and guards against tailoring descriptions to four images. Otherwise the edit is rolled back. After at most four rounds, the surviving claims are converted to CLIP prompts. Each prompt is weighted by its measured discriminative margin rather than averaged uniformly, which addresses the blurring from uniform averaging noted in Active Prompt Learning.
We also evaluate an arm that runs the full programs at inference. This arm measures the interpretability-versus-latency trade that Zero-shot Concept Bottleneck Models reports as roughly 3 ms to 55 ms per sample for its regression step.
Baselines
The naive reference point is zero-shot CLIP with the standard hand-written template ensemble, using the same backbone and no labeled images. Any method that fails to beat it after using labeled images has failed outright.
The strongest open-loop description method is CuPL, run with the same language model and the same CLIP backbone, for which the file reports 76.69% ImageNet top-1 and +6.50% on DTD. We will regenerate CuPL prompts ourselves so that model versions match. Beating CuPL means a consistent gain across the dataset suite at equal language-model backbone, not a gain on a single dataset.
The strongest iterative text method is a BC-LLM-style loop. It uses the same proposer, the same test and validation splits, and the same number of language-model calls, but gives only accept/reject feedback. Its reported CUB AUC of 0.874 comes from a different setup (a supervised bottleneck), so we rerun it rather than compare numbers. This is the most important baseline. If our loop cannot beat it at matched language-model calls, the diagnostic report adds nothing.
The strongest method that uses the labeled images directly is the few-shot family. We run a linear probe on CLIP features and a cache-based adapter in the style of CaFo, which reports 68.79% on 16-shot ImageNet. Both see exactly the same one-to-four labeled images per class, and both are tuned on the same validation split.
The ablations isolate the key ingredient. The first is text-only refinement with a confusion-matrix report, which keeps the diagnostic signal but removes the code. The second is our loop with the per-attribute report replaced by overall accuracy only. The third is a single-pass ViperGPT-style test program with no refinement. All arms run under a fixed budget of language-model calls and perception-model calls.
Why not just…?
Why not just refine the text descriptions using the confusion matrix, with no code at all? This is the most serious threat, and it is also our first ablation. A confusion matrix tells the language model which classes collide but not which claims are false or invisible. The frontend-refinement result, where feedback without a grounded critic gave only 1.5%, suggests that unlocalized feedback is weak. That result comes from a different domain, however. If the confusion-matrix ablation matches our loop, we will report that the code layer is unnecessary and recast the contribution as the report format.
Why not just fit a few-shot adapter on the same images? Adapters such as CaFo use labeled images very efficiently, and at 16 shots they will likely win on raw accuracy. We therefore stake the accuracy claim on the one-to-four-shot regime and on novel classes. The primary test for novel classes is Products-2023, where CLIP has weak priors; no reported result was found on Lacuna for any method on it. We also report two quantities adapters do not provide: a human-readable, verified attribute list and a measured hallucination rate. If adapters dominate even at one shot, the case for our method rests on auditability alone, and we will say so.
Why not just accept or reject proposals statistically, as BC-LLM does? Accept/reject discards the reason for failure. The proposer then samples blindly, which should cost more calls to reach the same quality. The matched-call comparison with call-count curves settles this directly.
Proposed Experiments
The dataset suite is CUB-200-2011, DTD, Stanford Cars, FGVC-Aircraft, Flowers-102, EuroSAT, and ImageNet, which are the fine-grained and standard benchmarks used by CuPL and Z-CBM. Products-2023 serves as the novel-class stress test. We use one, two, and four shots per class, split evenly between the test and validation roles, with five random seeds per setting. Metrics are top-1 accuracy, language-model and perception-model calls, and inference latency per image.
The first decisive check is hallucination. CUB-200-2011 ships with expert per-image attribute annotations. We will measure the fraction of claimed attributes contradicted by those annotations for CuPL descriptions, for BC-LLM survivors, and for our descriptions before and after refinement. If refinement does not lower this rate, the mechanism we claim is not what is happening.
The second decisive check is the ablation ladder under matched call budgets, reported as accuracy against rounds. We expect a plateau near round two to four, consistent with Yan et al.
The third check is transfer. Descriptions refined with one CLIP backbone are evaluated with another. This tells us whether the loop fixes true facts, which should transfer, or tunes prompts to one model's quirks, which would not.
References
- What does a platypus look like? Generating customized prompts for zero-shot image classification
- DesCo: Learning Object Recognition with Rich Language Descriptions
- Grounding Descriptions in Images informs Zero-Shot Visual Recognition
- Bayesian Concept Bottleneck Models with LLM Priors
- ViperGPT: Visual Inference via Python Execution for Reasoning
- Vision-Guided Iterative Refinement for Frontend Code Generation
- Large Language Models for Automated Data Science: Introducing CAAFE for Context-Aware Automated Feature Engineering
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- MEIC: Re-thinking RTL Debug Automation using LLMs
- Active Prompt Learning in Vision Language Models
- Zero-shot Concept Bottleneck Models
- Prompt, Generate, then Cache: Cascade of Foundation Models makes Strong Few-shot Learners