# Learning Transferable Visual Models From Natural Language Supervision

> Trains image and text encoders to match 400 million web image-caption pairs. Class names become text prompts, so CLIP classifies zero-shot, matching a supervised ResNet-50 on ImageNet and staying far more robust under distribution shift.

- arXiv: https://arxiv.org/abs/2103.00020
- Authors: Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, Ilya Sutskever
- Published: 2021-02-26
- Topic: Multimodal
- Visual carousel: https://instaxiv.com/p/2103.00020
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Learn vision from 400 million captions and classify anything zero-shot

**76.2%** ImageNet zero-shot, with no ImageNet labels

## Vision models only knew their fixed label set

**Supervised pretraining:** Train on 1,000 ImageNet classes, then collect labeled data for every new task. The model cannot name concepts it was never labeled with.

**CLIP:** Learn which caption goes with which image across 400M web pairs. Any new class becomes a text prompt, so recognition needs no new labels.

Natural language becomes the label space.

## Contrastive pretraining, then classify with text prompts

![Figure 1](https://cdn.instaxiv.com/figures/2103.00020/figure1.webp)

Matching image-text pairs sit on the diagonal of a similarity matrix. At test time, class names become prompts like 'a photo of a dog', and the closest prompt wins. (Figure 1)

## Training on batches of 32,768 pairs

1. **Encode both sides**: An image encoder, ResNet or ViT, and a text Transformer map inputs into one shared embedding space.
2. **Score every pairing**: Compute cosine similarity between all images and all captions in the batch.
3. **Contrast**: A symmetric cross-entropy pushes each true pair up and every other pairing in the batch down.

## One cross-entropy over rows, one over columns

$$
\begin{gathered} \text{logits} = \big(I_e\,T_e^{\top}\big)\,e^{t} \\ \mathcal{L} = \tfrac{1}{2}\big(\emerald{\mathrm{CE}}_{\text{img}} + \emerald{\mathrm{CE}}_{\text{txt}}\big) \end{gathered}
$$

Each image should pick its own caption out of the batch, and each caption its own image. The diagonal of the logit matrix holds the right answers.

- $I_e$: L2-normalized image embeddings
- $T_e$: L2-normalized text embeddings
- $t$: Learned temperature scaling the logits
- $\mathrm{CE}$: Cross-entropy with the diagonal as targets

## Lower ImageNet score, sturdier under shift

| Method | ImageNet | ImageNet-A | Sketch |
| --- | --- | --- | --- |
| Noisy Student L2 | 88.3 | 84.9 | 47.6 |
| Linear-probe CLIP | 85.4 | 75.3 | 57.4 |
| **Zero-shot CLIP (+12.6 Sketch)** | **76.2** | **77.2** | **60.2** |

_Top-1 accuracy (%). Zero-shot CLIP never sees ImageNet training labels._

## Zero-shot has blind spots

- **Weak on abstract tasks**: Struggles with counting objects and fine-grained classes like car models or flower species.
- **Truly unseen data**: On MNIST handwritten digits, zero-shot CLIP reaches only 88%, below logistic regression on raw pixels.
- **Inherits web biases**: Trained on unfiltered internet pairs, it absorbs social biases; the paper documents harmful misclassifications.

Best used when: You need open-vocabulary recognition or image-text retrieval without labeled data.

## Key takeaways

- Contrastive image-text pretraining turns any class name into a classifier with no labeled examples.
- Zero-shot models hold up far better under distribution shift than ImageNet-tuned ones.
- CLIP encoders sit inside Stable Diffusion, DALL·E 2 and many vision-language models.

## Links

- arXiv: https://arxiv.org/abs/2103.00020
- PDF: https://arxiv.org/pdf/2103.00020
- Code: https://github.com/openai/CLIP

## Citation

```bibtex
@article{radford2021learning,
  title   = {Learning Transferable Visual Models From Natural Language Supervision},
  author  = {Radford, Alec and Kim, Jong Wook and Hallacy, Chris and Ramesh, Aditya and Goh, Gabriel and Agarwal, Sandhini and Sastry, Girish and Askell, Amanda and Mishkin, Pamela and Clark, Jack and Krueger, Gretchen and Sutskever, Ilya},
  journal = {arXiv preprint arXiv:2103.00020},
  year    = {2021},
  url     = {https://arxiv.org/abs/2103.00020}
}
```
