techlist.io
OpenAI2021-01-044 min read

Curated summary

CLIP: Connecting text and images

Read original(opens in new tab)

CLIP: Connecting Text and Images

OpenAI's CLIP (Contrastive Language–Image Pre-training) is a neural network that learns visual concepts from text paired with images found on the internet, rather than from manually labeled datasets. Because it is trained to match images with natural-language descriptions, it can be applied to new image classification tasks simply by supplying the category names, without task-specific training. The authors argue this zero-shot approach produces benchmark results that better reflect real-world performance, since the model is never optimized directly for the benchmark.

Problems with Standard Computer Vision Models

  • Labeled vision datasets are expensive to build and cover only a fixed set of predetermined concepts. ImageNet required over 25,000 workers to annotate 14 million images across 22,000 categories.
  • Standard models are narrow. An ImageNet model handles its 1,000 categories well but needs a new dataset, a new output head, and fine-tuning for any other task.
  • Benchmark scores overstate real-world performance. Models that look superhuman on benchmarks often fail on stress tests, which the authors attribute to models effectively "studying for the test."

How CLIP Works

  • CLIP is trained on a proxy task: given an image, predict which of 32,768 randomly sampled text snippets was actually paired with it.
  • Solving this forces the model to learn many visual concepts and associate them with their names.
  • For classification, the category names are turned into text prompts (e.g., "a photo of a dog" vs. "a photo of a cat"), and the model picks the prompt most likely to match the image.

Background and Prior Work

  • Zero-data learning has been studied for over a decade, but natural language as a flexible prediction space was a key insight.
  • Socher et al. (2013) showed a model trained on CIFAR-10 could predict two unseen classes by using word vector embeddings.
  • DeVISE (2013) extended this to generalize beyond ImageNet's 1,000 training classes.
  • Li et al. (2016/2017) were the most direct inspiration. They trained on 30 million Flickr photos with their titles, descriptions, and tags, reaching 11.5% zero-shot accuracy on ImageNet.
  • Recent work such as VirTex, ICMLM, and ConVIRT explored related language-supervised objectives using Transformers, with ConVIRT applying a contrastive objective to medical imaging.

Key Results

Efficiency

  • A contrastive objective (matching images to text) was 4x to 10x more efficient than an image-to-text approach for zero-shot ImageNet classification in small to medium experiments.
  • Switching from a standard ResNet to a Vision Transformer gave a further 3x compute efficiency gain.
  • The best model trained on 256 GPUs for 2 weeks.

Flexibility

  • Zero-shot performance was measured across more than 30 datasets, including fine-grained object classification, geo-localization, video action recognition, and OCR.
  • With linear probes, the best CLIP model outperformed the best public ImageNet model (Noisy Student EfficientNet-L2) on 20 of 26 transfer datasets.
  • Fitting a linear classifier on ImageNet raised CLIP's ImageNet test accuracy by nearly 10%, but gave no average gain across seven other robustness datasets. This supports the authors' "cheating hypothesis."
  • CLIP closes the robustness gap by up to 75% while matching the original ResNet-50's ImageNet accuracy zero-shot, without using any of its 1.28M labeled training examples.

Limitations

  • CLIP struggles with abstract or systematic tasks such as counting objects or estimating distance to the nearest car, where it is only slightly better than random guessing.
  • It lags task-specific models on fine-grained classification, such as car models, aircraft variants, and flower species.
  • Generalization is limited. On handwritten MNIST digits, zero-shot CLIP reaches 88% accuracy versus 99.75% for humans.
  • Performance can be sensitive to wording, sometimes requiring trial-and-error "prompt engineering."

Broader Impacts

  • Class design strongly affects bias. With FairFace race labels and a few offensive terms, about 32.3% of images of people aged 0–20 were classified into the offensive category. Adding a "child" class reduced this to about 8.7%.
  • Celebrity identification reached 59.2% top-1 accuracy among 100 candidates and 43.3% among 1,000. This is not competitive with production systems, but it raises privacy and surveillance concerns that the authors flag for further research.

Conclusion

The authors show that task-agnostic pre-training on internet-scale natural language, which drove recent progress in NLP, can also improve computer vision. Like the GPT models, CLIP learns many tasks during pre-training and transfers to them zero-shot. The authors also argue that zero-shot evaluation gives a more representative measure of a model's capability.

Continue with another curated summary.