Abstract: Recent advances in vision-language models have combined contrastive approaches with generative methods to achieve state-of-the-art (SOTA) on downstream inference tasks like zero-shot image classification. However, a persistent issue of these models for image classification is their out-of-distribution (OOD) generalization capabilities. We first show that when an OOD datapoint is misclassified, the correct class can be typically found in the Top-K predicted classes. In order to steer the model prediction toward the correct class within the top predicted classes, we propose the Image-Caption Encoding (ICE) method, a straightforward approach that directly enforces consistency between the image-conditioned and caption-conditioned predictions at evaluation time only. Intuitively, we take advantage of unique properties of the generated captions to guide our local search for the correct class label within the Top-K predicted classes. We show that our method can be easily combined with other SOTA methods to enhance Top-1 OOD accuracies by 0.5% on average and up to 3% on challenging datasets.
The Challenge of Out-of-Distribution Generalization
Vision-Language Models (VLMs) have revolutionized zero-shot classification—the ability to categorize images into classes the model never saw during training. However, these models still struggle with Out-of-Distribution (OOD) generalization. For example, a model trained on standard photos might fail when shown a sketch, a cartoon, or a satellite image.
Research presented at WACV 2024 identifies a specific pattern: when a VLM misclassifies an OOD image, the correct label is almost always hiding in the Top-K (e.g., Top-5) predicted classes. The challenge is "steering" the model to pick that correct runner-up instead of the wrong first choice.
The Image-Caption Encoding (ICE) Method
The authors propose Image-Caption Encoding (ICE), a training-free inference-time method that introduces a "second opinion" from a text decoder to refine visual predictions. Instead of relying solely on the image's visual embedding, ICE follows a multi-step process:
- Caption Generation: Given an image, a generative model (like CoCa, BLIP-2, or LLaVA) produces a descriptive caption (e.g., "a photo of a bowl of miso soup").
- Dual Encoding: The system calculates two probability distributions over the possible class labels: one based on the image embedding and one based on the generated caption's embedding.
- Top-K Filtering: To keep the model grounded, ICE only considers the Top-K classes identified by the image encoder. This prevents the captioner from hallucinating a completely irrelevant class.
- Adaptive Weighting: ICE dynamically decides how much to trust the caption versus the image. If the image encoder is "unsure" (indicated by a low standard deviation in its Top-K scores), the system gives more weight to the caption.
Why Captions Improve Generalization
Standard image encoders often compress the whole image into a single "class" token. Text decoders, however, use cross-attention to look at the full spatial grid of image tokens. This allows the caption to verbalize fine-grained details that the global visual embedding might overlook.
Furthermore, because text decoders are often pre-trained with language modeling losses, they possess rudimentary "reasoning." For instance, a decoder might know that certain visual features are more characteristic of a specific breed of dog than another, helping it classify an image more accurately than a purely visual model could.
Experimental Results and Impact
The researchers evaluated ICE across 15 different datasets, including cross-dataset generalization (ImageNet, Caltech101, EuroSAT) and domain generalization (ImageNet-Sketch, ImageNet-A).
- Consistent Gains: ICE improved Top-1 accuracy by an average of 0.5% across all 15 benchmarks.
- High Impact on Hard Tasks: On challenging datasets like FGVCAircraft and EuroSAT, accuracy jumped by as much as 3%.
- Universal Compatibility: The method isn't tied to one architecture, showing improvements when applied to CoCa, BLIP-2, and LLaVA.
- Synergy with Fine-Tuning: Even when combined with state-of-the-art few-shot learning methods (like CoOp or MaPLe), ICE provided an additional performance boost.
Conclusion
ICE demonstrates that "talking about what it sees" before making a final decision allows a VLM to significantly improve accuracy on tricky, out-of-distribution data. Crucially, this entire process happens at evaluation time only, requiring no backpropagation or weight updating. While it introduces some computational overhead due to the extra forward pass through a text decoder, the gains in robustness make it a powerful tool for zero-shot generalization.
Summary updated