Context-Adaptive Multi-Prompt Embedding with Large Language Models for Vision-Language Alignment

Dahun Kim, Anelia Angelova

TL;DR

This paper introduces Context-Adaptive Multi-Prompt Embedding, a method that leverages pretrained decoder-only Large Language Models (LLMs) to generate rich, multi-aspect text representations for vision-language alignment. By using multiple learned adaptive prompts processed efficiently in a single forward pass, combined with diversity and negation losses, the approach significantly improves zero-shot image and video retrieval performance over standard CLIP baselines.

What Problem Does This Paper Address?

Contrastive vision-language models like CLIP typically compress an entire text description into a single embedding vector. However, natural language descriptions are multi-faceted—a single caption might describe a main subject, background context, and specific actions all at once. A single vector often fails to capture all these nuances, limiting the model's ability to perform fine-grained matching.

While LLMs possess deep semantic reasoning capabilities that could help, adapting decoder-only LLMs (like GPT or Gemma) for contrastive learning is challenging. Their causal (unidirectional) attention mechanism means standard pooling strategies (like mean pooling or taking the first token's embedding) fail to summarize the sequence effectively. Existing workarounds use fixed prompt templates to force the model to summarize at the final token, but these are rigid and fail to capture diverse semantic viewpoints.

Methods

The authors propose a framework that extracts multiple distinct semantic views from a text description using an LLM text encoder:

  1. Context-Adaptive Multi-Prompts: Instead of one prompt, they construct $K$ structured prompts. Each prompt contains a unique, learnable Adaptive Prompt Token [APT-i] designed to specialize in a specific semantic aspect of the text. The prompt format follows: "[input_text]. The [APT-i] of this image means:".
  2. Efficient Attention Masking: To avoid running the LLM $K$ times, all prompts are concatenated into a single sequence. A custom prompt-wise attention mask ensures that while the prefix text is shared, the prompt-specific segments cannot attend to each other, allowing all $K$ embeddings to be computed in a single forward pass.
  3. Embedding Concatenation: The final token embedding of each prompt is projected to a lower dimension ($D/K$) and concatenated to form a final $D$-dimensional text embedding. This aligns each prompt's output with a specific channel segment of the visual embedding.
  4. Novel Auxiliary Losses:
  5. Prompt Diversity Regularization Loss ($L_{div}$): Minimizes the pairwise cosine similarity between the $K$ prompt embeddings, forcing them to specialize in different aspects (e.g., subject vs. background).
  6. Negation-Aware Loss ($L_{neg}$): Introduces negative text variants (e.g., "...does NOT mean:") to provide a stronger contrastive signal, helping the model better distinguish fine-grained semantic differences.
Figure 1: Overview of our method. Given an input text, we construct multiple structured prompts, each with a distinct adaptive prompt token [APT-i] (Sec. 3.2). The entire sequence is processed jointly in a single LLM forward pass via prompt-wise attention masking (Sec. 3.3). This yields K embeddings of size D/K, concatenated into a D-dimensional text embedding. A ViT encoder with attention pooling (Sec. 3.1) produces a matching image or video embedding. Training combines contrastive loss (Lcon) with a prompt diversity regularization loss (Ldiv, Sec. 3.4) and a negation-aware loss (Lneg, Sec. 3.5) to encourage semantic variation and incorporate contrastive signals from negated prompts.

Datasets

  • Training: Models are trained from scratch on LAION for image-text alignment. For video-text alignment, they initialize from the image-text model and finetune on VideoCC3M.
  • Evaluation: Zero-shot retrieval performance is evaluated on standard benchmarks: Flickr30K and MSCOCO for image-text retrieval, and MSR-VTT for video-text retrieval.

Key Insights and Ideas

  • Channel-wise Specialization: By concatenating the $K$ prompt embeddings rather than averaging them, each adaptive token maps directly to a specific segment of the visual embedding. Because contrastive learning relies on dot products, this naturally incentivizes different parts of the image embedding to align with different semantic concepts (e.g., one prompt captures the subject, another the background).
  • Causal LLMs Need Guidance: Simply freezing or unfreezing an LLM with standard pooling yields poor results for vision-language alignment. Explicitly prompting the model to summarize via last-token pooling is essential to unlock the LLM's latent semantic knowledge.
  • Negation Matters: Standard contrastive learning only teaches the model what an image is. Adding a negation loss explicitly teaches the model what an image is not, significantly boosting its discriminative power.

Key Results

  • Outperforming Baselines: The proposed method shows substantial improvements over vanilla CLIP and standard LLM text encoder baselines. For instance, on Flickr30K image-to-text retrieval, it achieves a Recall@1 of 66.0% compared to vanilla CLIP's 61.4% (using a batch size of 1024 and $K=6$).
  • Scaling with Prompts ($K$): Performance steadily increases as the number of adaptive prompts grows from 1 to 6, after which gains plateau.
  • Ablation of Losses: Incorporating both the diversity loss ($L_{div}$) and negation loss ($L_{neg}$) pushes the Flickr30K image-to-text performance further to 68.3%.
  • Model and Batch Scaling: The approach scales robustly when moving from a Gemma-2B to a Gemma-9B backbone, and benefits significantly from larger contrastive batch sizes (up to 16k).

Limitations and Future Work

  • Computational Cost: Although prompt-wise attention masking allows for a single forward pass, processing long concatenated sequences in an LLM still incurs higher memory and computational overhead compared to lightweight traditional text encoders like BERT.
  • Hyperparameter Sensitivity: The performance relies on tuning the number of prompts ($K$) and the loss weights ($\alpha, \beta$), which might vary depending on the downstream domain or backbone size.
  • Future Directions: The authors suggest exploring how this multi-prompt strategy can be extended to broader multimodal tasks beyond retrieval, such as text-to-image generation or complex visual reasoning.

Summary updated

BibTeX
@inproceedings{kim2025context,
  author = {Dahun Kim and Anelia Angelova},
  title = {{Context-Adaptive Multi-Prompt Embedding with Large Language Models for Vision-Language Alignment}},
  booktitle = {COLM},
  year = {2025},
}
Figure