Abstract
Current computer vision systems are typically trained to predict a fixed set of object categories. This restricted form of supervision limits their generality and usability since additional labeled data is needed to specify any other visual concept. We present CLIP (Contrastive Language-Image Pre-training), a model trained on 400 million (image, text) pairs collected from the internet. CLIP demonstrates that learning directly from raw text is a promising alternative that enables "zero-shot" transfer to a vast array of downstream tasks without task-specific training.
Introduction
For over a decade, the dominant paradigm in computer vision has been supervised pre-training on datasets like ImageNet. While successful, this approach suffers from a "narrowness" problem: models are confined to the specific categories defined during training. If a new task requires recognizing objects outside the original 1,000 classes, practitioners must collect and label new datasets.
In contrast, Natural Language Processing (NLP) has transitioned toward task-agnostic models like GPT-3. These models learn from massive amounts of raw text and can be "prompted" to perform various tasks. CLIP aims to bring this "GPT moment" to computer vision by learning visual representations directly from the descriptive text that naturally accompanies images on the web.
Methods: Contrastive Pre-training
The core of CLIP is a Contrastive Pre-training objective. Rather than attempting the computationally expensive task of predicting the exact words in a caption, CLIP is trained to identify which caption matches which image within a batch.
Architecture and Objective
CLIP utilizes two separate encoders: an Image Encoder (either a ResNet or a Vision Transformer) and a Text Encoder (a standard Transformer). During training, the model learns a multi-modal embedding space where the cosine similarity between the embeddings of correct (image, text) pairs is maximized, while the similarity for mismatched pairs is minimized.
Zero-Shot Transfer
To perform classification without further training, class names are converted into natural language "prompts" (e.g., "a photo of a dog"). CLIP then calculates the similarity between the image embedding and the embeddings of all possible prompts, selecting the most similar one as the prediction.
Efficiency and Scaling
A key finding of the study is the superior efficiency of contrastive learning. The authors compared CLIP's contrastive objective against predictive models that try to generate captions and found that CLIP is significantly more data-efficient.
As shown in the figure above, the contrastive approach reaches the same level of performance as a Transformer language model while processing 4x fewer images. This efficiency was crucial for scaling the model to the WIT (WebImageText) dataset of 400 million pairs.
Key Results and Insights
- Zero-Shot Performance: CLIP matched the accuracy of a fully supervised ResNet-50 on ImageNet (76.2%) without ever seeing a single ImageNet training label.
- Robustness to Distribution Shift: Because CLIP learns semantic concepts through language rather than dataset-specific statistics, it is far more robust to "natural distribution shifts," such as sketches, cartoons, or new photos of common objects.
- The Power of Prompts: Simply using a class name often leads to ambiguity. The authors found that using a prompt template like "A photo of a {label}" significantly improved accuracy. For specialized datasets, even more specific prompts provided further boosts.
Limitations and Future Work
Despite its breakthrough performance, CLIP has limitations. It requires massive compute resources; reaching state-of-the-art performance across all vision tasks might require a 1000x increase in scale. Furthermore, CLIP struggles with fine-grained distinctions (e.g., specific car models) and abstract tasks like counting objects. It also performs poorly on specialized data types rare on the internet, such as MNIST handwritten digits. Finally, like all models trained on web data, CLIP inherits and can amplify societal biases regarding race, gender, and age.
Summary updated