Sub topic 7
Training Data: Image-Text Pairs from the Web
This chapter assumes you know basic Python and PyTorch, neural-network training, embeddings, and vector similarity. It focuses on how CLIP’s web-scale data shapes what the model learns.
What counts as an image-text pair?
CLIP trains on pairs consisting of an image and nearby text. The text might be an image caption, an article heading, alternative text, a product description, or text surrounding an image on a web page.
The pair does not need to be a carefully written caption. It only needs to provide a useful association often enough for the training process to learn from it.
For example:
| Image | Paired text | Likely signal |
|---|---|---|
| A photograph of a golden retriever | “A dog playing in a park” | dog, action, outdoor setting |
| A product photograph | “Red running shoes” | object and color |
| A news photograph | “Flooding in the city center” | event and location |
During training, CLIP sees many pairs in a batch. It learns to give a high similarity score to each true pair and lower scores to mismatched pairs. The data therefore teaches both visual concepts and language associations.
How web data becomes a training set
A practical collection pipeline usually has several stages:
Collection systems first download or reference images and extract associated text. Filters may remove tiny images, broken files, text with too little information, and pages that match blocked-content rules. Deduplication reduces repeated images and copied captions. The final dataset is then shuffled and divided into training batches.
The exact process matters because contrastive learning treats other examples in the batch as negatives. If a batch contains several near-duplicates, the model may receive contradictory signals. If a caption is unrelated to its image, the model is also trained on a false match.
Why scale helps
Web data contains a wide range of objects, languages, styles, locations, and activities. This variety supports open-vocabulary recognition. A model can sometimes recognize a category that was never included in a fixed list of labeled classes because the category appears in text during training.
Scale also improves coverage of rare concepts. However, more data does not automatically mean better data. Repeated, biased, or misleading examples can dominate the learned representation.
Noise, bias, and responsibility
Web text reflects the people and systems that created it. It can contain stereotypes, offensive language, inaccurate descriptions, and unequal coverage of different groups. Search and popularity effects can make common concepts appear far more often than uncommon ones.
Important data concerns include:
- Copyright and permission to use the images and text.
- Personal information visible in images or captions.
- Unsafe or hateful content.
- Language and geographic imbalance.
- Duplicate images and machine-generated captions.
- Captions that describe a page rather than the image itself.
These issues affect downstream behavior. A model trained on biased associations may produce biased zero-shot classifications or retrieval results. Filtering can reduce harm, but aggressive filtering may also remove useful cultural or linguistic diversity.
Practical takeaway
CLIP’s capability comes from aligning two encoders across a large and varied collection of image-text pairs. The web provides breadth, but its noise and bias become part of the model. Dataset construction, filtering, documentation, and evaluation are therefore as important as the loss function.
Exercise
Why can duplicate or unrelated image-text pairs harm contrastive training?
Show answer
Duplicates can create confusing negatives, while unrelated pairs teach the model that incorrect image-text associations are correct.