Learning Transferable Visual Models From Natural Language Supervision
@radfordLearningTransferableVisual2021
State-of-the-art computer vision systems are trained to predict a fixed set of predetermined object categories. This restricted form of supervision limits their generality and usability since additional labeled data is needed to specify any other visual concept. Learning directly from raw text about images is a promising alternative which leverages a much broader source of supervision. We demonstrate that the simple pre-training task of predicting which caption goes with which image is an efficient and scalable way to learn SOTA image representations from scratch on a dataset of 400 million (image, text) pairs collected from the internet. After pre-training, natural language is used to reference learned visual concepts (or describe new ones) enabling zero-shot transfer of the model to downstream tasks. We study the performance of this approach by benchmarking on over 30 different existing computer vision datasets, spanning tasks such as OCR, action recognition in videos, geo-localization, and many types of fine-grained object classification. The model transfers non-trivially to most tasks and is often competitive with a fully supervised baseline without the need for any dataset specific training. For instance, we match the accuracy of the original ResNet-50 on ImageNet zero-shot without needing to use any of the 1.28 million training examples it was trained on. We release our code and pre-trained model weights at https://github.com/OpenAI/CLIP.
Knowledge
Section titled “Knowledge”CLIP jointly trains a text encoder and an image encoder to learn a shared embedding space for both modalities. It uses a contrastive loss (InfoNCE) that pulls matched image-text pairs together (minimizes cosine distance) and pushes unmatched pairs apart (maximizes cosine distance). A matching image-caption pair is treated as a positive example, all other pairs in the batch are treated as negative examples. The loss encourages the model to learn meaningful representations that capture the semantic relationships between images and text.
Insights
Section titled “Insights”CLIP contrastive loss implicitly encourages the learned embeddings to be uniformly distributed across the unit hypersphere rather than collapsing into a small cluster or just pushing negatives 180 degrees apart within a single batch. This is desirable:
- Maximizes the information content of the embedding space
- Keeps distinct concepts well-separated
- Improves generalization as no parts of the sphere is underutilized.
