# 多模态对比学习

多模态对比学习是一种机器学习方法：它为不同的数据模态（例如图像与文本）分别训练编码器，使相互匹配的样本对在共享嵌入空间中彼此靠近，而不匹配的样本对彼此远离。由此得到的对齐嵌入可用于零样本分类、跨模态检索，以及为生成模型提供条件。随着 CLIP<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> 与 ALIGN<sup>[2](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)</sup> 在 2021 年出现，这一方法开始广受关注；它们表明，在数亿对含噪网络数据上做对比对齐，所得到的视觉—语言表示能够迁移到模型从未被显式训练过的任务上。

| 关键事实 | 数值 |
|---|---|
| 核心目标 | 在一个批次中，对 \( N \) 个真实配对与 \( N^{2}-N \) 个错误配对的余弦相似度计算对称交叉熵<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> |
| CLIP 训练数据 | 用 50 万条查询词收集的 4 亿对网络图文对，每条查询最多 2 万对<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> |
| CLIP 训练规模 | 小批量大小为 32,768；最大的 ResNet 在 592 块 V100 GPU 上训练了 18 天<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> |
| 零样本结果 | CLIP 在不使用 ImageNet 的 128 万标注样本的情况下，达到原始 ResNet-50 的水平；ALIGN 的零样本 top-1 达到 76.4%<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup><sup> • </sup><sup>[2](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)</sup> |
| 算力削减 | SigLIP 的 sigmoid 损失在四块 TPUv4 芯片上用两天时间，就把一个大型 LiT 模型训练到 ImageNet 零样本 84.5%<sup>[3](https://openaccess.thecvf.com/content/ICCV2023/papers/Zhai_Sigmoid_Loss_for_Language_Image_Pre-Training_ICCV_2023_paper.pdf)</sup> |
| 模态间隙 | 图像与文本的嵌入保持一臂之遥；在单位球面上，默认的 0.82 间隙在其学到的温度下恰好达到 CLIP 损失的全局最小值<sup>[4](https://proceedings.neurips.cc/paper_files/paper/2022/file/702f4db7543a7432431df588d57bc7c9-Paper-Conference.pdf)</sup> |

## 工作原理

给定一批 \( N \) 个（图像，文本）配对，模型被训练来预测 \( N \times N \) 种可能配对中究竟哪些配对真实发生过。图像编码器与文本编码器各自产生嵌入；经 L2 归一化后，两两余弦相似度按温度缩放形成逻辑值，再以标签 \( \mathrm{arange}(n) \) 在两个方向上分别计算对称交叉熵损失并取平均，\( \mathcal{L} = (\mathcal{L}_{i} + \mathcal{L}_{t})/2 \)。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> 最小化该损失会抬高 \( N \) 个真实配对的相似度、压低 \( N^{2}-N \) 个错误配对的相似度，从而迫使两个编码器把语义上匹配的内容放到嵌入空间的同一区域。

为什么这样能学到对齐的表示，有一个理论上的答案：当两个特征之间的相似度等于两个数据点的逐点互信息（相差一个常数）时，对称 InfoNCE 损失即达到最大，因此嵌入的几何结构编码了两个模态共享多少信息。<sup>[5](https://ar5iv.labs.arxiv.org/html/2404.19228)</sup> 在线性表示设定下，对一大类多模态对比损失（包括 CLIP 与 ALIGN 的损失）而言，每一步梯度下降都等价于对一个对比交叉协方差矩阵做奇异值分解。<sup>[6](https://ar5iv.labs.arxiv.org/html/2302.06232)</sup> 同一分析还表明，只要观测到的配对中包含不可忽略比例的真实配对，该方法就能以参数速率恢复核心特征——这解释了它为何对含噪的、错误匹配的配对具有稳健性。<sup>[6](https://ar5iv.labs.arxiv.org/html/2302.06232)</sup>

## 实施方法

实践者按以下步骤操作：

1. **大规模收集配对数据。** CLIP 的 WIT 数据集是通过在网上搜索图文对构建的，其文本须包含 50 万条查询词之一，并对每条查询设 2 万对的上限，使各类别大致均衡。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> ALIGN 则大规模使用了含噪的图像替代文本（alt-text）。<sup>[2](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)</sup>
2. **选择编码器。** CLIP 的图像端使用 ResNet 或视觉 [Transformer](https://www.edgepedia.org/zh/transformer)，文本端使用一个 6300 万参数、12 层、宽度 512、8 个注意力头的 Transformer，输入为字节对编码。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>
3. **设定温度。** 温度 \( \tau \) 是一个以对数参数化的可学习标量，初始化为相当于 0.07，并加以截断，以防逻辑值被放大超过 100 倍——CLIP 作者发现这对防止训练不稳定是必要的。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>
4. **使用极大的批量。** CLIP 训练时的小批量大小为 32,768。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> SigLIP 作者把批量推到一百万，发现收益很快递减，32k 已足够。<sup>[3](https://openaccess.thecvf.com/content/ICCV2023/papers/Zhai_Sigmoid_Loss_for_Language_Image_Pre-Training_ICCV_2023_paper.pdf)</sup> 当显存限制了批量大小时，GradCache 将对比损失与编码器之间的反向传播解耦，从而支持更大的批量。<sup>[7](https://arxiv.org/abs/2410.05160)</sup>
5. **评估零样本性能。** 用文本编码器嵌入数据集的类别名称，对温度缩放后的余弦相似度做 softmax 归一化，结果就相当于一个输入与权重均经 L2 归一化的多项逻辑回归分类器。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>

CLIP 本身去掉了 ConVIRT 所用的非线性投影头和文本变换函数，只保留随机方形裁剪作为唯一的数据增强。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>

## 起源

批次构造与目标函数可追溯到[深度度量学习](https://www.edgepedia.org/zh/deep-metric-learning)：多类 N 对损失（N-pair loss，孙基赫，2016，NeurIPS）、InfoNCE 损失，以及由 ConVIRT（张宇浩及同事，2020，arXiv）改造用于医学影像中文本—图像对比学习的版本。<sup>[8](https://doi.org/10.48550/arxiv.2010.00747)</sup> 单模态对比学习则通过 SimCLR（陈婷、西蒙·科恩布利思、穆罕默德·诺鲁齐与[杰弗里·辛顿](https://www.edgepedia.org/zh/geoffrey-hinton)，2020，arXiv）提供了其余机制。<sup>[9](https://doi.org/10.48550/arxiv.2002.05709)</sup> ConVIRT 论文称，自 2020 年首次发布以来，它直接启发了 CLIP（[亚历克·拉德福德](https://www.edgepedia.org/zh/alec-radford)及同事，2021，arXiv）<sup>[10](https://doi.org/10.48550/arxiv.2103.00020)</sup> 与 ALIGN（贾超及同事，2021，arXiv）<sup>[11](https://doi.org/10.48550/arxiv.2102.05918)</sup>，而 CLIP 被描述为从零训练的 ConVIRT 简化版。<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup> 后来有些论文把 ConVIRT 引作张宇浩等，2022，而非 2020；2020 这个发布年份是 ConVIRT 论文自己给出的。

## 变体

- **ALIGN** 采用双编码器架构：图像端是带全局池化的 [EfficientNet](https://www.edgepedia.org/zh/efficientnet)，文本端是使用 [CLS] 嵌入的 BERT，在含噪替代文本上用归一化 softmax 损失训练，把匹配的配对视为正例，把批次中其余随机配对全部视为负例。<sup>[2](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)</sup>
- **SigLIP** 用成对 sigmoid 损失取代 softmax 归一化的对比损失，该损失只作用于图文对，不需要在批次上做全局归一化。<sup>[3](https://openaccess.thecvf.com/content/ICCV2023/papers/Zhai_Sigmoid_Loss_for_Language_Image_Pre-Training_ICCV_2023_paper.pdf)</sup>
- **SigLIP 2** 在目标中加入了基于描述生成的预训练、自监督损失与在线数据整理，在全部四个已发布模型规模上都优于 SigLIP。<sup>[12](https://arxiv.org/pdf/2502.14786)</sup>
- **ImageBind** 学习横跨六种模态（图像、文本、音频、深度、热成像与 IMU 数据）的联合嵌入，只使用与图像配对的数据而非所有模态两两配对，损失为 InfoNCE 式的正负配对损失。<sup>[13](https://doi.org/10.48550/arxiv.2305.05665)</sup>
- **MedCLIP** 将图像与文本解耦，使可用的训练数据按组合方式增长，并用基于医学知识的语义匹配损失取代 InfoNCE，以消除假负例。<sup>[14](https://doi.org/10.48550/arxiv.2210.10163)</sup>
- **UniCLIP** 使用的图像编码器产生与增强无关的表示，投影头则输出与增强相关的嵌入。<sup>[15](https://papers.nips.cc/paper_files/paper/2022/file/072fd0525592b43da661e254bbaadc27-Paper-Conference.pdf)</sup>
- **VLM2Vec** 不再使用分离的编码器：它在 Transformer 内部深度整合视觉与语言特征，并在任务指令下处理图像与文本的任意组合。<sup>[7](https://arxiv.org/abs/2410.05160)</sup>

## 应用

训练好的编码器可直接用于零样本分类——类别名称成为文本锚点<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>——以及跨模态检索：在 Flickr30K 与 MSCOCO 上，ALIGN 在多数零样本与微调的 R@1 指标上比此前的最优结果高出 7% 以上。<sup>[2](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)</sup> 嵌入还可为生成模型提供条件；[ImageBind](https://www.edgepedia.org/zh/imagebind) 展示了音频到图像的生成：把它的音频嵌入与一个预训练的 DALLE-2 解码器配合使用，后者原本是为处理 CLIP 文本嵌入而设计的。<sup>[13](https://doi.org/10.48550/arxiv.2305.05665)</sup> 在医学影像中，ConVIRT 预训练只需 [ImageNet](https://www.edgepedia.org/zh/imagenet) 初始化对照模型 10% 的标注数据，就能在全部 4 项受评估的医学分类任务上达到更好或相当的表现<sup>[16](https://proceedings.mlr.press/v182/zhang22a/zhang22a.pdf)</sup>；而 MedCLIP 用 2 万条预训练样本，就胜过了此前用约 20 万条样本训练的方法。<sup>[14](https://doi.org/10.48550/arxiv.2210.10163)</sup> VLM2Vec 的 MMEB 基准涵盖 36 个数据集上的分类、视觉问答、多模态检索与视觉定位。<sup>[7](https://arxiv.org/abs/2410.05160)</sup>

## 局限与替代方案

有据可查的最典型失效模式是模态间隙：在 CLIP 这类模型中，图像与文本在共享空间里保持一臂之遥。<sup>[4](https://proceedings.neurips.cc/paper_files/paper/2022/file/702f4db7543a7432431df588d57bc7c9-Paper-Conference.pdf)</sup> 对其成因并存两种解释。一种把间隙归因于模型初始化（不同的随机初始化会形成不同的嵌入锥）与对比优化的共同作用，并发现当 CLIP 学到的最终温度为 1/100 时，默认的 0.82 间隙恰好达到损失的全局最小值。<sup>[4](https://proceedings.neurips.cc/paper_files/paper/2022/file/702f4db7543a7432431df588d57bc7c9-Paper-Conference.pdf)</sup> 后来的一项研究则指出，图像与描述之间存在信息不均衡——图像携带的信息多于描述——这才是模态间隙与物体偏置背后的驱动因素。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2025/file/4572bc2f514e627914cbe60d0398a2d1-Paper-Conference.pdf)</sup>

间隙未必是缺陷。增大它可以改善零样本分类与公平性表现<sup>[4](https://proceedings.neurips.cc/paper_files/paper/2022/file/702f4db7543a7432431df588d57bc7c9-Paper-Conference.pdf)</sup>；而增大间隙的嵌入变化会提高逻辑值的熵，从而带来逐样本的不确定性控制，这是全局温度无法提供的。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2025/file/4572bc2f514e627914cbe60d0398a2d1-Paper-Conference.pdf)</sup> 在现成的视觉—语言模型中，间隙对性能的影响通常被其他因素盖过，不过缩小它也能带来改善。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2025/file/4572bc2f514e627914cbe60d0398a2d1-Paper-Conference.pdf)</sup>

一个结构性局限在于成对目标本身：当模态达到三个或更多时，成对的 CLIP 无法捕捉联合信息。Symile 是一种捕捉任意数量模态之间高阶（总相关）信息的对比方法，即便每个模态各自以 0.5 的概率独立缺失，它在零样本检索上仍对成对 CLIP 保持很大优势。<sup>[18](https://proceedings.neurips.cc/paper_files/paper/2024/file/6828259348d99d5e8994028bfdf15d09-Paper-Conference.pdf)</sup> 至于数据集规模的阈值，已发表的比较都是间接的：CLIP 在 4 亿对上训练，而公开可用的医学图像与报告要少几个数量级<sup>[14](https://doi.org/10.48550/arxiv.2210.10163)</sup>；把预测式的词袋目标换成对比目标，在零样本迁移到 ImageNet 上又带来了 4 倍的效率提升<sup>[1](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)</sup>；但尚无正面比较的基准，来量化对比对齐究竟在哪个点上胜过监督预训练。

## References

1. [Learning Transferable Visual Models From Natural Language Supervision (CLIP)](https://proceedings.mlr.press/v139/radford21a/radford21a.pdf)
2. [Scaling Up Visual and Vision-Language Representation Learning With Noisy Text Supervision (ALIGN)](https://proceedings.mlr.press/v139/jia21b/jia21b.pdf)
3. [Sigmoid Loss for Language Image Pre-Training (SigLIP)](https://openaccess.thecvf.com/content/ICCV2023/papers/Zhai_Sigmoid_Loss_for_Language_Image_Pre-Training_ICCV_2023_paper.pdf)
4. [Mind the Gap: Understanding the Modality Gap in Multi-modal Contrastive Representation Learning](https://proceedings.neurips.cc/paper_files/paper/2022/file/702f4db7543a7432431df588d57bc7c9-Paper-Conference.pdf)
5. [Understanding multimodal contrastive learning through pointwise mutual information](https://ar5iv.labs.arxiv.org/html/2404.19228)
6. [Understanding Multimodal Contrastive Learning and Incorporating Unpaired Data](https://ar5iv.labs.arxiv.org/html/2302.06232)
7. [VLM2Vec: Training Vision-Language Models for Massive Multimodal Embedding Tasks](https://arxiv.org/abs/2410.05160)
8. [Zhang, Yuhao and colleagues (2020). Contrastive Learning of Medical Visual Representations from Paired Images and Text. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2010.00747)
9. [Chen, Ting and colleagues (2020). A Simple Framework for Contrastive Learning of Visual Representations. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2002.05709)
10. [Radford, Alec and colleagues (2021). Learning Transferable Visual Models From Natural Language Supervision. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2103.00020)
11. [Jia, Chao and colleagues (2021). Scaling Up Visual and Vision-Language Representation Learning With Noisy Text Supervision. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2102.05918)
12. [SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features](https://arxiv.org/pdf/2502.14786)
13. [Girdhar, Rohit and colleagues (2023). ImageBind: One Embedding Space To Bind Them All. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2305.05665)
14. [Wang, Zifeng and colleagues (2022). MedCLIP: Contrastive Learning from Unpaired Medical Images and Text. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2210.10163)
15. [UniCLIP: Unified Framework for Contrastive Language–Image Pre-training](https://papers.nips.cc/paper_files/paper/2022/file/072fd0525592b43da661e254bbaadc27-Paper-Conference.pdf)
16. [Contrastive Learning of Medical Visual Representations from Paired Images and Text (ConVIRT)](https://proceedings.mlr.press/v182/zhang22a/zhang22a.pdf)
17. [Two Effects, One Trigger: On the Modality Gap, Object Bias, and Information Imbalance in Contrastive Vision-Language Models](https://proceedings.iclr.cc/paper_files/paper/2025/file/4572bc2f514e627914cbe60d0398a2d1-Paper-Conference.pdf)
18. [Contrasting with Symile: Simple Model-Agnostic Representation Learning for Unlimited Modalities](https://proceedings.neurips.cc/paper_files/paper/2024/file/6828259348d99d5e8994028bfdf15d09-Paper-Conference.pdf)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Oct 15, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/multimodal-contrastive-learning

English original: https://www.edgepedia.org/multimodal-contrastive-learning
