Abstract
While Vision-Language Pre-training (VLP) models like CLIP have demonstrated exceptional performance in cross-modal association tasks, their application to generative tasks like image and video captioning remains challenging. This difficulty stems primarily from the "modality gap," where image and text embeddings occupy distinct subspaces despite being mapped to a shared representation. We present Knight (K-nearest-neighbor Cross-modality Mapping), a novel zero-shot framework that transforms CLIP into a powerful caption generator. By utilizing a text-only unsupervised training strategy and a $k$-nearest-neighbor retrieval mechanism, Knight effectively bypasses the modality gap to achieve state-of-the-art performance in both image and video captioning without requiring paired image-text data during training.
Introduction: The Challenge of the Modality Gap
Models like CLIP have revolutionized computer vision by mastering the art of association—determining whether a specific sentence matches a given image. However, transitioning from association to generation (describing an image from scratch) is non-trivial.
The primary obstacle is the modality gap. Although CLIP maps images and text into a unified embedding space, the embeddings for different modalities tend to cluster into separate subspaces. When a language decoder, such as GPT-2, is trained solely on text features, it becomes optimized for the text subspace. During inference, when presented with an image feature, the slight shift in the embedding space caused by the modality gap often leads the decoder to produce inaccurate or nonsensical descriptions. Previous attempts to mitigate this shift, such as injecting random noise or complex joint-space training, often fail to preserve the nuanced semantic information required for high-quality captioning.
The Knight Framework
Knight addresses the generation problem by reframing cross-modal generation as a mono-modal task. The framework consists of two primary phases: text-only training and cross-modal inference.
1. Text-only Training
Knight eliminates the need for images during the training phase. The process begins with a caption from a large, unpaired text corpus. Using CLIP, the system identifies the $k$-nearest neighbor ($k$-NN) captions within that same corpus. A GPT-2 decoder is then trained to reconstruct the original caption based on the embeddings of these $k$ neighbors. This approach ensures that the decoder learns to generate coherent text while remaining strictly within the "text subspace" of the CLIP embedding space.
2. Cross-modal Inference
During inference, when the model is tasked with describing an image, it uses the CLIP image encoder to find the $k$ most similar captions from the training corpus. These retrieved text embeddings are then fed into the pre-trained GPT-2 decoder. Because the decoder was specifically trained to reconstruct text from these types of CLIP text features, the modality gap is effectively bypassed. The retrieval mechanism acts as a bridge, translating visual features into the text-based representations the decoder understands.
3. Video Adaptation
To extend this capability to video captioning, Knight extracts keyframes from a video sequence. It calculates the $k$-NN for each frame and averages these representations to provide a stable temporal context for the decoder, allowing it to generate descriptions that reflect the progression of the video.
Experimental Results
The researchers evaluated Knight using a CLIP (ResNet50x64) encoder and a GPT-2 Large decoder across four major benchmarks. The training corpus consisted of the text-only captions from the training splits of these datasets.
Image and Video Captioning Performance
Knight achieved state-of-the-art (SOTA) results across all zero-shot metrics:
- Image Captioning: On the MS-COCO dataset, Knight reached a BLEU@4 of 27.8, outperforming the previous SOTA method, CapDec (26.4), while utilizing fewer training parameters.
- Video Captioning: The performance gains were particularly significant in video tasks. On MSR-VTT, Knight achieved a BLEU@4 of 25.4, a substantial leap over previous unsupervised methods that struggled to reach double-digit scores.
Efficiency and Generalization
One of Knight's most compelling advantages is its computational efficiency. Because the model avoids processing image pixels during training, the training process is remarkably fast—taking less than six hours on a single NVIDIA A100 GPU.
Furthermore, Knight demonstrates impressive zero-shot generalization. By learning the relationships between concepts within the text space, the model can describe objects or entities it has never seen in a paired image-text context (e.g., specific characters like "Squidward" or game environments like "Minecraft"), provided those concepts exist within the text corpus and CLIP can associate the visual features with them.
Discussion and Future Work
Knight’s success highlights that CLIP’s retrieval capabilities are often more robust than its raw embedding alignment. By using retrieval as an anchor, the framework converts a complex cross-modal problem into a more manageable text-to-text problem.
However, the model's performance is inherently tied to the quality and diversity of its text-only training corpus; if a concept is missing from the corpus, the model cannot retrieve it. Additionally, while training is efficient, the $k$-NN search during inference introduces computational overhead that may require vector database optimization for larger scales. Future research may explore the integration of larger language models (LLMs) and more sophisticated temporal fusion techniques to further enhance the descriptive depth of the generated captions.
Summary updated