Contrasting Intra-Modal and Ranking Cross-Modal Hard Negatives to Enhance Visio-Linguistic Fine-grained Understanding

Le Zhang, Rabiul Awal, Aishwarya Agrawal

Abstract

Vision-Language Models (VLMs) like CLIP have revolutionized tasks such as zero-shot image classification and image-text retrieval. However, their ability to perform compositional reasoning—understanding the specific relationships between objects, attributes, and actions—remains a significant weakness. This limitation often results in "bag-of-words" representations where the model identifies objects but fails to grasp their arrangement or interaction. We introduce a simple, annotation-free framework to enhance compositional reasoning by refining the standard contrastive learning objective. Our method utilizes automated hard negative generation paired with two novel objectives: an Intra-Modal Contrastive (IMC) loss and a Cross-Modal Rank (CMR) loss with an adaptive threshold. When integrated with CLIP (forming CE-CLIP), our approach yields substantial improvements across five compositional benchmarks without requiring additional parameters or manual labels.

Introduction: The "Bag-of-Words" Problem

While state-of-the-art VLMs excel at identifying global object presence, they frequently struggle with fine-grained visio-linguistic understanding. For instance, a model might correctly identify a "dog" and a "cat" in an image but fail to distinguish between the captions "the dog is to the left of the cat" and "the cat is to the left of the dog."

This "compositional blind spot" stems from the nature of standard contrastive learning. During pretraining, models are typically trained to distinguish a correct image-text pair from a completely random negative (e.g., a photo of a dog vs. a caption about a sunset). Because these random negatives are semantically distant, the model is never incentivized to learn the nuances of spatial relations, actions, or attributes. To address this, we propose a framework that forces the model to focus on these fine-grained details through the use of synthetic hard negatives.

Methodology

1. Automated Hard Negative Generation

To train the model on fine-grained distinctions without manual annotation, we utilize a two-step automated process. First, we use Part-Of-Speech (POS) tagging to identify key components of a caption. Second, we use a Language Model (RoBERTa) to generate four types of "hard negative" captions for every image:

  • Relation Negatives: Swapping the positions of two nouns (e.g., "dog on grass" becomes "grass on dog").
  • Attribute, Action, and Object Negatives: Masking a specific word and using RoBERTa to suggest a plausible but incorrect alternative that maintains grammatical integrity.

2. Intra-Modal Contrastive (IMC) Loss

The IMC loss is designed to refine the text encoder's representation space. By forcing the model to distinguish between a true caption and its hard-negative counterparts within the text modality, we push the embeddings of semantically different but syntactically similar sentences apart. This ensures that the text encoder is sensitive to small changes in wording that fundamentally alter meaning.

3. Cross-Modal Rank (CMR) Loss with Adaptive Threshold

The CMR loss ensures that the similarity score between an image and its ground-truth caption is higher than the score with a hard negative caption by a specific margin. A key innovation in our approach is the adaptive threshold.

Rather than using a fixed margin, we implement a curriculum learning strategy. Early in training, the margin is kept small to accommodate the difficulty of the task. As the model's performance improves, the margin grows, making the training objective progressively more challenging. This stabilization is particularly crucial for learning complex relations, which are often the most difficult for VLMs to master.

Experimental Results

Benchmarking Compositionality

We evaluated our Compositional Enhanced CLIP (CE-CLIP) across five rigorous benchmarks: ARO (Attributing Relations and Objects), VALSE, VL-CheckList, SugarCrepe, and Winoground. The results demonstrate a significant leap in performance over the standard CLIP baseline:

  • ARO-Relation: 23.7% improvement.
  • ARO-Attribute: 13.5% improvement.
  • SugarCrepe: 12.1% improvement.

Notably, CE-CLIP outperformed other state-of-the-art methods like NegCLIP and DAC, despite those methods often requiring more complex pipelines or additional human annotations. Furthermore, the method proved robust across architectures; when applied to X-VLM, it yielded similar performance gains.

Scaling and Trade-offs

Our research highlights that scaling model size is not a panacea for compositional reasoning. We found that a massive ViT-G/14 model (the largest available CLIP) still performed worse on compositional tasks than our smaller, specifically trained CE-CLIP. This suggests that the training objective is more critical than parameter count for fine-grained understanding.

However, we observed a slight trade-off: while compositional understanding improved dramatically, there was a minor decrease (approximately 1.6%) in standard zero-shot image classification accuracy. This indicates a small tension between learning "general" global features and "specific" compositional features.

Conclusion

By integrating intra-modal and cross-modal hard negative objectives with an adaptive curriculum, we significantly enhance the compositional reasoning of Vision-Language Models. CE-CLIP moves beyond "bag-of-words" processing to a more nuanced understanding of the visual world. Future work will explore generating hard negatives in the image domain and addressing the slight performance dip in general retrieval tasks to create even more versatile visio-linguistic models.

Summary updated

BibTeX
@inproceedings{zhang2024contrasting,
  author = {Le Zhang and Rabiul Awal and Aishwarya Agrawal},
  title = {{Contrasting Intra-Modal and Ranking Cross-Modal Hard Negatives to Enhance Visio-Linguistic Fine-grained Understanding}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  url = {https://openreview.net/forum?id=Z1RQuDIUGi},
}
Figure