Files
myWiki/concepts/contrastive-learning.md

32 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "对比学习 (Contrastive Learning)"
created: 2026-07-04
updated: 2026-07-04
type: concept
tags: [self-supervised, representation-learning, embedding, multimodal]
sources: []
---
# 对比学习 (Contrastive Learning)
一种自监督/监督表示学习方法,通过拉近正样本对、推开负样本对来学习有判别力的嵌入表示。
## 核心损失
$$\mathcal{L} = -\log \frac{\exp(\text{sim}(z_i, z_i^+)/\tau)}{\sum_j \exp(\text{sim}(z_i, z_j)/\tau)}$$
- $z_i, z_i^+$:正样本对(匹配的图文/增强视图)
- $z_j$batch 中所有样本(包括负样本)
- $\tau$:温度参数
## 在 VLM 中的作用
CLIP 的对比训练使文本嵌入成为嵌入空间中的**语义锚点**——匹配的图文对被拉近,不匹配的被推开。这是 [[text-proxy-for-semantics|文本语义代理]] 有效的基础:文本 prompt 的嵌入在语义上与其描述的概念对齐。
## 参考
- [[clip|CLIP]]
- [[vision-language-models|VLM]]
- [[cosine-similarity-geometry|余弦相似度几何]]
- [[text-proxy-for-semantics|文本语义代理]]