Using Knowledge Graphs to harvest datasets for efficient CLIP model training

Simon Ging, Sebastian Walter, Jelena Bratulić, Johannes Dienert, Hannah Bast, Thomas Brox

TL;DR

Researchers have developed a way to train high-quality CLIP models using significantly less data by leveraging knowledge graphs and LLMs to "harvest" targeted web datasets. Their new dataset, EntityNet, allows a model trained on just 33M images to match the performance of models trained on 20x more data, while their 10M-image expert model for living organisms outperforms state-of-the-art models trained on billions of pairs.

What Problem Does This Paper Address?

Contrastive Language-Image Pretraining (CLIP) has revolutionized how AI understands the relationship between images and text. However, the standard recipe for a "good" CLIP model usually involves brute-force scaling—training on billions of image-text pairs scraped indiscriminately from the web.

This approach has three major drawbacks:

  1. Cost: Training requires massive computational resources.
  2. Domain Gaps: General-purpose models often fail in "expert" domains like biology or medicine where fine-grained details matter.
  3. Lack of Control: Researchers have little say over the data distribution, making it hard to study emergent behaviors or build specialized tools.

The authors ask: Can we replace quantity with quality? Instead of scraping the whole web, can we use structured knowledge to find exactly the images we need?

Methods

The authors propose a four-step pipeline to create EntityNet, a curated dataset designed for efficiency:

  1. Entity Extraction: They use the Wikidata knowledge graph to identify 135k visual entities (e.g., "eagle," "muscle car") based on a hierarchical structure.
  2. Attribute Generation: To ensure visual diversity, they prompt LLMs (like GPT-4o and Qwen) to generate visual attributes for these entities across categories like color, texture, and environment (e.g., "porous rock," "wolf in the snow").
  3. Query Building: They combine entities and attributes into specific search queries. They also use "natural types" (e.g., changing "BMW M4" to "black car") to help the model learn broader concepts.
  4. Targeted Harvesting: These queries are sent to the Bing Image Search API to collect images and their associated web "alt-text."
Fig. 2: We create a dataset for vision-language pretraining: First, we extract entities from knowledge graphs, then generate attributes and natural types for them. We search for different combinations of entities, attributes, and types in image search engines, and collect alt texts for each image. Finally, we train our model on the combined data.

During training, they use a 50/50 sampling strategy: half the time the model sees the noisy web alt-text, and the other half it sees clean labels derived directly from the knowledge graph (the entity name, its aliases, or its description).

Datasets

  • EntityNet (New): 33M images paired with 46M text descriptions. It includes a specific Organism subset of 10M images focused on animals, plants, and fungi.
  • Evaluation Benchmarks:
    • Generic: ImageNet-1k and various distribution shifts (ImageNet-A, -R, -Sketch).
  • Expert: iNaturalist 2021 (10k species), CUB (birds), and RareSpecies (unseen taxa).
  • Retrieval: MS-COCO, Flickr30k, and XM3600.

Key Insights and Ideas

  • Diversity > Depth: The authors found that having more unique entities with fewer images each is more beneficial for model performance than having many images of fewer entities.
  • Knowledge Graphs as Regularizers: Mixing clean, structured labels from Wikidata with noisy web alt-text acts as a powerful signal. It helps the model learn fine-grained classification (like distinguishing species) without losing the ability to understand natural language.
  • Efficiency is the New Scale: By being smart about what the model sees, you can achieve a much better "quality-compute trade-off." Their model sits on a new Pareto front, providing higher accuracy for a fraction of the training cost.

Key Results

The results demonstrate that smart data beats raw volume:

  • 22.5x Efficiency Gain: On ImageNet, the EntityNet-trained model achieved performance comparable to the original OpenAI CLIP while using roughly 22.5 times less compute.
  • Expert Domain Dominance: The 10M-image organism model outperformed the massive DFN-5B (trained on 5 billion images) and BioCLIP on the iNaturalist and RareSpecies benchmarks.
  • Zero-Shot Prowess: On the CUB bird dataset, their model achieved 85.3% accuracy, significantly higher than standard CLIP models of the same size.
Fig. 1: We demonstrate how to harvest datasets for training CLIP models with an improved quality-cost trade-off, for a generic (left) or an expert domain (right).

Limitations and Future Work

  • Dependency on Knowledge Graphs: The method requires a pre-existing knowledge graph for the target domain. While these exist for many fields (like agriculture or proteins), they aren't universal.
  • Retrieval Trade-off: While excellent at classification, the model showed a slight drop in image-text retrieval performance compared to models trained purely on long-form alt-texts. The authors suggest this is because knowledge graph labels are short and "object-centric," whereas retrieval benefits from complex scene descriptions.
  • Visual Style Bias: The search-engine-based approach tends to find clean photos, meaning the model performs slightly worse on artistic renditions like sketches or paintings compared to models trained on raw web scrapes.

Future work could involve improving the quality of alt-texts or expanding the pipeline to even more specialized scientific domains where data is the primary bottleneck.

Summary updated

BibTeX
@inproceedings{ging2025using,
  author = {Simon Ging and Sebastian Walter and Jelena Bratulić and Johannes Dienert and Hannah Bast and Thomas Brox},
  title = {{Using Knowledge Graphs to harvest datasets for efficient CLIP model training}},
  booktitle = {DAGM GCPR},
  year = {2025},
  doi = {10.1007/978-3-032-12840-9\_19},
}
Figure