DeCap: Decoding CLIP Latents for Zero-Shot Captioning via Text-Only Training

Wei Li, Linchao Zhu, Longyin Wen, Yi Yang

TL;DR

DeCap is a lightweight framework for zero-shot image captioning that learns to generate descriptions using text-only training data. By leveraging CLIP’s multi-modal latent space and a novel training-free projection mechanism to bridge the "modality gap" between images and text, DeCap achieves state-of-the-art performance while being over 100x faster than previous zero-shot methods.

The Challenge of Zero-Shot Captioning

Image captioning traditionally relies on massive, expensive datasets of human-annotated image-text pairs. While large-scale pre-trained multi-modal models like CLIP provide a shared latent space for images and text, adapting them for "zero-shot" captioning—generating text for images without paired training data—presents significant challenges.

Existing approaches typically fall into two traps:

  1. The Task Mismatch: Utilizing Large Language Models (like GPT-2) often results in generic text that fails to accurately describe visual features, as these models were trained for language modeling, not visual description.
  2. The Modality Gap: Although CLIP aligns images and text, their embeddings are not perfectly identical. If a decoder is trained exclusively on CLIP text embeddings, it often fails when fed a CLIP image embedding because the two modalities reside in slightly different "neighborhoods" of the latent space.

The DeCap Framework

To overcome these limitations, the authors introduce DeCap, a simple yet highly effective framework consisting of two main components.

DeCap Framework

1. Text-Only Decoder Training

Instead of relying on image-text pairs, DeCap trains a lightweight 4-layer Transformer decoder to perform text reconstruction. A sentence is encoded using a frozen CLIP text encoder, and the decoder is tasked with "inverting" that embedding back into the original sentence. Essentially, the decoder learns to translate CLIP vectors back into natural language.

2. Bridging the Modality Gap via Support Memory

To resolve the modality gap at inference time, DeCap employs a training-free projection mechanism.

  • Support Memory: The system maintains a "memory" of CLIP embeddings derived from a large text corpus.
  • Projection: When an image is processed, its CLIP embedding is compared against the text embeddings in the support memory.
  • Weighted Combination: The image embedding is transformed into a "projected" vector—a weighted sum of the most similar text embeddings in the memory. This effectively nudges the visual representation into the text-only space that the decoder understands.

Datasets and Evaluation

DeCap is highly data-efficient. The model was trained on text-only corpora, including CC3M-text (3 million captions), SS1M (1 million captions), and the Book Corpus. It was evaluated on standard image captioning benchmarks (MSCOCO and NoCaps) and applied to video captioning on MSR-VTT, ActivityNet-Captions, and VATEX.

Key Insights

  • The Power of Inversion: A decoder does not need to see images to describe them; it only needs to know how to translate CLIP’s latent space into English. Since CLIP has already aligned images to that space, the decoder acts as a translator.
  • Modality Gap as a Geometric Problem: The difference between image and text embeddings is treated as a domain shift, corrected by a weighted k-Nearest Neighbor approach (the support memory) rather than complex, resource-heavy fine-tuning.
  • Efficiency is King: Because DeCap does not require backpropagation or multiple CLIP passes during inference, it is significantly more practical for real-world deployment than iterative optimization methods.

Key Results

DeCap demonstrates remarkable improvements in both performance and efficiency.

Zero-shot Captioning Performance
  • Superior Performance: DeCap outperformed previous zero-shot and unpaired captioning methods on MSCOCO and NoCaps by a large margin. On MSCOCO, it improved the CIDEr score by roughly 27.5% compared to the previous state-of-the-art, ZeroCap.
  • Massive Speedup: DeCap is 113x faster than ZeroCap. While ZeroCap takes over 11 seconds to caption a single image due to its iterative optimization process, DeCap completes the task in about 0.1 seconds.
  • Cross-Domain Flexibility: The model exhibits strong adaptability. By simply swapping the "support memory" with text from a new domain (e.g., from MSCOCO to Flickr30k), the model's performance improves without any additional training.

Limitations and Future Work

While highly effective, DeCap has a few limitations:

  • Support Memory Overhead: Maintaining a support memory of 1 million embeddings requires significant RAM. However, the authors suggest a filtering strategy that can reduce this memory footprint by 85% with minimal loss in quality.
  • Hallucination Risks: Like many CLIP-based models, DeCap can sometimes "hallucinate" objects that are semantically related to the scene but not actually present, as it relies on global CLIP embeddings rather than fine-grained spatial features.

Future work may explore extending this "decoding latents" framework beyond captioning to other tasks like visual dialog or complex multi-modal reasoning.

Summary updated

BibTeX
@inproceedings{li2023decap,
  author = {Wei Li and Linchao Zhu and Longyin Wen and Yi Yang},
  title = {{DeCap: Decoding CLIP Latents for Zero-Shot Captioning via Text-Only Training}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=Lt8bMlhiwx2},
}
Figure