CLIP: Connecting Text and Images

OpenAI 推出了 CLIP (Contrastive Language–Image Pre-training),這是一種透過自然語言監督來學習視覺概念的神經網路。藉由在網路上發現的海量多樣化圖像與文本對進行訓練,CLIP 可以執行廣泛的視覺分類任務,而不需要特定任務的訓練數據,有效地實現了類似於 GPT-2 和 GPT-3 的「zero-shot」能力。

Solving the Limitations of Standard Computer Vision

CLIP 解決了傳統深度學習電腦視覺方法的三個主要缺陷:

  • Reduction of Costly Datasets: Traditional models rely on manually labeled datasets (such as ImageNet, which required 25,000 workers to annotate 14 million images) that are expensive and scope limited. CLIP instead utilizes publicly available text-image pairs from the internet.
  • Increased Flexibility: Standard models are typically restricted to the specific categories they were trained on. To adapt a standard model to a new task, practitioners must build a new dataset and fine-tune the model. CLIP can be adapted to nearly any visual classification task by simply providing the names of the visual concepts to the text-encoder.
  • Closing the Robustness Gap: There is often a significant gap between a model's performance on a benchmark and its performance in real-world "wild" deployments. OpenAI conjectures that this happens because models "cheat" by optimizing specifically for the benchmark. Because CLIP is evaluated on benchmarks without being trained on their specific data, its performance is more representative of real-world utility. In tests, CLIP closed this robustness gap by up to 75% while matching the original ResNet-50 performance on ImageNet zero-shot.

Technical Approach and Training Efficiency

CLIP 是透過一個代理任務來進行訓練:給定一張圖像,模型必須從隨機採樣的 32,768 個文本片段中預測哪一個實際上與該圖像配對。這迫使模型學習廣泛的視覺概念,並將其與其自然語言名稱關聯起來。

為了優化訓練計算量,OpenAI 實施了兩個關鍵的演算法選擇:

  1. Contrastive Objective: CLIP 使用對比式目標來連接文本與圖像。在中小規模的實驗中,這被發現比圖像到文本的方法在 zero-shot ImageNet 分類上更有效率,效率高出 4 倍到 10 倍。
  2. Vision Transformer (ViT): 採用 Vision Transformer 提供了比標準 ResNet 額外 3 倍的計算效率增益。

因此,表現最好的 CLIP 模型是在 256 個 GPU 上訓練了兩週。

Capabilities and Generalization

CLIP 在超過 30 個不同的數據集上展現了高度的靈活性,包括 OCR、影片中的動作識別、地理定位和細粒度對象物分類。在利用線性探針 (linear probes) 進行表示學習評估時,表現最好的 CLIP 模型在 26 個不同遷移數據集中的 20 個上都優於 Noisy Student EfficientNet-L2。

Limitations and Challenges

儘管具有通用能力,CLIP 仍有特定的弱點:

  • Abstract and Systematic Tasks: CLIP 在圖像中計算物體數量或預測空間關係(例如,汽車在照片中有多近)方面表現不佳,其性能僅比隨機猜測稍好一些。
  • Fine-Grained Classification: 當區分非常相似的類別時,例如特定的飛機變體、花卉物種或汽車型號時,該模型的效果不如特定任務的模型。
  • Out-of-Distribution Data: CLIP 對於其預訓練中未涵蓋的圖像展現出較差的泛化能力。例如,它在 MNIST 數據集的手寫數字上達到了 88% 的準確度,顯著低於人類的 99.75% 準確度。
  • Prompt Sensitivity: Zero-shot 分類器對特定措辭可能很敏感,有時需要進行「prompt engineering」來達到最佳性能。

Broader Impacts and Biases

由於 CLIP 允許用戶在沒有特定任務數據的情況下設計自己的分類器,標籤的選擇可能會引入或放大偏見。OpenAI 發現,當給定一組包含種族標籤和諸如 "criminal" 或 "animal" 等惡劣術語的標籤時,模型將 0–20 歲的人分類為惡劣類別的比例約為 32.3%。若在標籤中加入 "child" 類別,則該比例會降至約 8.7%。

關於隱私與監控,CLIP 在從 100 個候選者中選擇時,對「野外」名人圖像分類的 top-1 準確度為 59.2%,在從 1,000 個候選者中選擇時為 43.3%。OpenAI 指出,雖然這可以用於任務無關的預訓練,但它並不具備與生產級別的 celebrity 識別模型競爭的實力。

Sources