Contrastive Language-Image Pre-Training with Knowledge Graphs

Xuran Pan, Tianzhu Ye, Dongchen Han, Shiji Song, Gao Huang

Abstract

Knowledge-CLIP addresses the "semantic shallowing" problem in vision-language models by integrating structured Knowledge Graphs (KGs) into the pre-training phase. While standard models like CLIP learn from simple image-text co-occurrences, Knowledge-CLIP utilizes triplet-based semantic relationships to foster a deeper understanding of fine-grained concepts and logical reasoning. Our approach significantly outperforms the original CLIP on Visual Question Answering (VQA) and targeted semantic reasoning tasks, including negation and spatial awareness, while preserving broad generalization capabilities.

Introduction

Pre-trained vision-language models, most notably OpenAI’s CLIP, have transformed the field by learning from millions of image-text pairs. However, these models often suffer from "semantic shallowing"—a phenomenon where the model identifies word-image associations without understanding their logical or structural context. For example, CLIP often yields nearly identical results for a prompt and its negation (e.g., "a photo of an airliner" vs. "not a photo of an airliner"), indicating a failure to process logical operators.

CLIP's semantic shallowing: the model fails to distinguish negations and struggles with specific color attributes.

This lack of structural understanding limits performance on complex downstream tasks like Visual Question Answering (VQA) or identifying intricate spatial relationships.

Methods

We propose Knowledge-CLIP, which enhances the pre-training process by injecting structured knowledge through a continuous learning framework.

Architecture

Knowledge-CLIP extends the original CLIP architecture by adding a multi-modal Transformer encoder. This component processes "triplets" consisting of a head entity ($h$), a relation ($r$), and a tail entity ($t$). While entities can be represented as images or text, relations are strictly textual.

Training Objectives

To ensure the model captures both graph structure and original CLIP features, we employ four loss functions:

  • Entity-Entity (E2E) Loss: A masked-modeling objective where the model predicts a missing entity given a relation and the other entity.
  • Entity-Relation (E2R) Loss: A classification task to identify the relationship between two given entities.
  • Graph-Entity (G2E) Loss: Utilizes a Graph Neural Network (GNN) to propagate information, ensuring entity representations are informed by their neighborhood in the KG.
  • Knowledge Distillation (KD) Loss: Crucial for maintaining generalization, this loss keeps the model's outputs aligned with the original CLIP weights to prevent catastrophic forgetting.

Datasets

Knowledge-CLIP is trained on a diverse set of Knowledge Graphs:

  • VisualSem: Provides multilingual descriptions and illustrative images for entities.
  • Visual Genome: Offers scene graphs connecting objects via spatial and action-based relations.
  • ConceptNet: Supplies common-sense linguistic relationships.
  • Standard Pairs: COCO and CC3M datasets are converted into triplet formats (e.g., "caption of") to maintain general performance.

Results and Discussion

Knowledge-CLIP demonstrates superior performance across several benchmarks:

  • VQA Performance: On VQA v2.0, Knowledge-CLIP achieved 76.11%, compared to CLIP’s 74.10%.
  • Semantic Reasoning: Targeted evaluations showed improvements in handling Negations (+2.1%), Color attributes (+5.7%), and Spatial Positions (+7.1%).
  • Retrieval: Image Retrieval R@1 on Flickr30K increased from 72.4% to 75.7%.
  • Generalization: The model maintained competitive performance on ImageNet zero-shot classification and GLUE language benchmarks, confirming that specialized knowledge injection does not degrade general utility.

Conclusion

By moving beyond simple co-occurrence to explicit relational learning, Knowledge-CLIP provides a robust framework for enhancing semantic understanding in vision-language models. Future research will explore scaling this method to larger, more diverse Knowledge Graphs and implementing more complex graph reasoning within the multi-modal architecture.

Summary updated

BibTeX
@inproceedings{pan2022contrastive,
  author = {Xuran Pan and Tianzhu Ye and Dongchen Han and Shiji Song and Gao Huang},
  title = {{Contrastive Language-Image Pre-Training with Knowledge Graphs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=4T3kbrzfeR},
}
Figure