Zero-Shot Image-to-Text Generation for Visual-Semantic Arithmetic

Yoad Tewel, Yoav Shalev, Idan Schwartz, Lior Wolf

Introduction

Traditional image captioning models rely heavily on supervised learning from curated datasets like MS-COCO. While effective, these models often produce generic, repetitive captions constrained by their training vocabulary. They struggle with "zero-shot" scenarios—new domains for which no specific training data exists. ZeroCap addresses these limitations by combining the visual-semantic richness of CLIP with the generative power of GPT-2, creating a training-free, zero-shot captioning system.

ZeroCap demonstrates superior performance in real-world knowledge, diversity, OCR, and visual-semantic arithmetic compared to supervised baselines.

Methodology: Inference-Time Optimization

The core innovation of ZeroCap is its use of inference-time optimization to guide a Large Language Model (LLM) without modifying its weights.

Architecture

ZeroCap utilizes GPT-2 as a base text generator and CLIP as a visual guide. Instead of fine-tuning the models, ZeroCap optimizes the Key-Value (KV) pairs in the Transformer’s attention layers—the "context cache"—for each token generated.

Optimization Process

At each step of text generation, the model performs five iterations of gradient descent to minimize a dual-objective loss function:

  1. CLIP Loss ($\mathcal{L}_{CLIP}$): Ensures the generated text's embedding matches the input image's embedding in CLIP's shared space.
  2. Cross-Entropy Loss ($\mathcal{L}_{CE}$): Acts as a regularizer, ensuring the generated text remains fluent and adheres to the natural language distribution of the original GPT-2 model.

Visual-Semantic Arithmetic

Because optimization occurs within CLIP's embedding space, ZeroCap enables "visual-semantic arithmetic." Users can manipulate the target embedding by adding or subtracting concepts represented as images or text. For example, subtracting the concept of "man" from a "king" and adding "woman" can steer the model toward generating a description of a "queen."

Examples of OCR and visual-semantic arithmetic where concepts are added or subtracted to steer caption generation.

Key Results and Insights

ZeroCap prioritizes semantic accuracy and diversity over simple mimicry of human ground truth.

  • Diversity: On the MS-COCO test set, ZeroCap utilized a vocabulary of 8,681 words, nearly eight times larger than the supervised VinVL baseline (1,125 words). Remarkably, 100% of its generated sentences were novel relative to the training data.
  • World Knowledge: Leveraging CLIP's web-scale pre-training, ZeroCap identifies specific brands (e.g., "Toronto Blue Jays"), public figures, and technical objects (e.g., "Boeing 707") that supervised models typically miss.
  • Quantitative Performance: ZeroCap achieved a CLIP-Score (CLIP-S) of 0.87, outperforming VinVL's 0.78. In the Visual Relations (VR) benchmark, it successfully performed complex relational tasks where fine-tuned models like ClipCap failed.

Limitations

Despite its flexibility, ZeroCap faces challenges:

  • Inference Speed: The per-token optimization process makes it significantly slower than feed-forward models.
  • Bias and Noise: The model inherits biases from its training data and occasionally generates "meta-data" noise (e.g., photographer names) common in web-scraped datasets.

Future work may involve combining zero-shot flexibility with supervised accuracy or applying context steering to larger models like GPT-4.

Summary updated

BibTeX
@inproceedings{tewel2022zero,
  author = {Yoad Tewel and Yoav Shalev and Idan Schwartz and Lior Wolf},
  title = {{Zero-Shot Image-to-Text Generation for Visual-Semantic Arithmetic}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=o1vh05CloG},
}
Figure