CLIP 用自然语言监督连接图文
对比学习对齐图像与文本编码器,支持零样本视觉分类
OpenAI 发布 CLIP:在大规模图文对上对比训练图像编码器与文本编码器,使模型可用自然语言描述做零样本图像分类,并开放代码与权重示例。
把“狗”写成一句 “a photo of a dog”,这句话就能当分类标签用。
2021 年 1 月 5 日,OpenAI 的博客介绍 CLIP(Contrastive Language–Image Pre-training)。视觉模型通常在封闭标签集上长大:猫、狗、飞机,一千类或更多,但都是事先订好的词表。换任务就换标注;词表以外的说法,网络没有接口。与此同时,互联网上图片旁常有说明文字——不完美、有噪声,却极其多。CLIP 的动作是:用自然语言当监督信号,训练一对编码器,让图像与文本掉进可以互相比较的空间。
做法可以压成对比学习的一句口令。取一批图文对;图像编码器产出图像向量,文本编码器产出文本向量。同一对的向量应靠近,batch 里其他组合应推远。训练结束后,分类不必再训练一个固定的分类头:把候选类别写成自然语言短语,用文本编码器编成向量,与图像向量算相似度,分数最高者即为预测。这就是零样本(zero-shot)图像分类的接口——类别集是临时写的句子,不是焊死在最后一层权重里的索引。
博客与随后的论文叙述建立在大规模图文对与可扩展的双编码器设计上;代码与示例权重一并放出,使复现与二次开发有落点。它不是第一份图文多模态工作——对比学习与自然语言监督早有文献——却把“自然语言监督 + 对比目标 + 开放词汇分类”捆成可传播的研究与产品模块。检索场景同样直接:以文搜图、以图搜文,本质是同一空间里的近邻查询。生成模型后来常把 CLIP 类编码器当作条件或过滤——那是下游用法,不是 1 月 5 日公告的全部正文。
需要留下的限制与论文、博客自己也强调的方向一致。零样本不免费:提示措辞会影响分数;分布外图像、细粒度类别与系统性社会偏见仍会进入表示。对比目标优化的是配对匹配,不保证细读图中每一物体关系。把它当万能视觉大脑,会低估标注视觉系统与专用检测分割模型仍在做的事。它改变的是默认接口:文本成为查询视觉概念的语言,而不是只有整数类号。
对计算机视觉工程师,迁移路径往往是:用 CLIP 图像塔做检索或线性探测基线,再决定是否上专用检测器。对多模态产品,故事更短:用户可以用自然语言描述想找的图,而不必维护同义词标签树。两条路径共享同一几何——余弦相似度当接口——却服务不同的可靠性要求。生成式图像模型兴起后,CLIP 分数有时被拿来当粗糙的图文一致性度量;这种用法有争议,也说明共享嵌入已经渗进评估习惯。
把日期钉在 2021-01-05,是为了区分“研究思想累积”与“可下载基线公开”。OpenAI 的动作是把规模、工程与发布捆在一起,让零样本分类从演示变成许多人机器上的默认实验。后续论文补训练细节与更完整评估,博客页则留下事件的公共时间戳。札记收束在可操作的检查清单:有没有双编码器?有没有 batch 内对比?推理时类别是否以文本形式进入?三者同在,才是这条 CLIP 式路径,而不是任意贴了图文标签的卷积网。
Write “dog” as the sentence “a photo of a dog,” and that sentence can serve as a class label.
On 5 January 2021 OpenAI’s blog introduced CLIP (Contrastive Language–Image Pre-training). Vision models usually grow up on closed label sets: cat, dog, airplane—a thousand classes or more, all fixed in advance. New tasks mean new labels; phrases outside the list have no interface. Meanwhile the web is full of images beside captions—noisy, imperfect, and extremely numerous. CLIP’s move: train a pair of encoders with natural language as the supervision signal so images and text land in a space where they can be compared.
The method compresses to one contrastive order. Take a batch of image–text pairs; an image encoder emits image vectors, a text encoder emits text vectors. Matched pairs should sit close; other combinations in the batch should be pushed apart. After training, classification need not retrain a fixed head: write candidate classes as natural-language phrases, encode them with the text tower, score similarity against the image vector, and take the highest score. That is the zero-shot image-classification interface—the label set is a temporary set of sentences, not indices welded into a final layer.
The blog and the later paper rest on large-scale image–text pairs and scalable dual-encoder design; code and example weights shipped so reproduction and reuse had a landing pad. CLIP was not the first vision–language system—contrastive learning and language supervision had prior literature—but it bundled natural-language supervision, a contrastive objective, and open-vocabulary classification into a portable research and product module. Retrieval is the same geometry: text-to-image and image-to-text search are nearest-neighbor queries in one space. Generative models later often used CLIP-like encoders for conditioning or filtering—those are downstream uses, not the whole of the 5 January announcement.
Limits belong in the same notebook the blog and paper already point toward. Zero-shot is not free: prompt wording moves scores; out-of-distribution images, fine-grained classes, and social bias still enter the representation. The contrastive objective optimizes pairing, not a guarantee of reading every object relation in a scene. Treating it as a universal visual brain undercounts what labeled detectors and segmentation models still do. What changes is the default interface: text becomes a language for querying visual concepts, not only integer class ids.
For vision engineers the migration path is often: use a CLIP image tower as a retrieval or linear-probe baseline, then decide whether a dedicated detector is still required. For multimodal products the story is shorter: users can describe the image they want in natural language without maintaining a synonym tag tree. Both paths share one geometry—cosine similarity as the interface—while demanding different reliability. After generative image models rose, CLIP-style scores sometimes served as rough image–text consistency metrics; the practice is debated, and it shows shared embeddings entering evaluation habits.
Pinning the date to 2021-01-05 separates cumulative research ideas from a downloadable public baseline. OpenAI’s move bundled scale, engineering, and release so zero-shot classification became a default experiment on many machines. Later papers filled training detail and fuller evaluation; the blog page left the public timestamp. Close the notes with an operational checklist: dual encoders? In-batch contrast? Classes entering inference as text? All three mark this CLIP-style path, not every convnet that once saw an image caption.
展开完整事件档案人物、主题、模型与产品
- 人物
- —
- 模型
- clip
- 产品
- —