← Back to Multimodal Mind Map
⚡Flashcard Drill➔
👁️ MultimodalID: contrastive-loss

InfoNCE Contrastive Loss

InfoNCE 对比损失
🎯Core Definition
InfoNCE (Info Noise-Contrastive Estimation) is the core loss of contrastive learning (CLIP/SimCLR/MoCo) — pull positives together and push all in-batch negatives apart: L=−log⁡exp⁡(sim(xi,yi)/τ)∑jexp⁡(sim(xi,yj)/τ)\mathcal{L} = -\log \frac{\exp(\text{sim}(x_i, y_i) / \tau)}{\sum_{j} \exp(\text{sim}(x_i, y_j) / \tau)}, where sim(⋅,⋅)\text{sim}(\cdot, \cdot) is cosine similarity, yiy_i the matching positive of xix_i, the denominator sums over every candidate in the batch (1 positive + N−1N-1 negatives), and τ\tau is the temperature hyperparameter that scales similarities before softmax.
💡Use Cases
image-text alignment (CLIP), self-supervised representation (SimCLR/MoCo), cross-modal retrieval; interviews always probe the role of temperature τ\tau and why larger batches help.
⚡Key Problems Solved
triplet loss compares against a single negative, giving sparse gradients and dependence on hard-negative mining; InfoNCE folds all in-batch negatives into the softmax denominator, far better negative utilization and gradient signal, and is structurally identical to multi-class cross-entropy (positive logit = sim(xi,yi)/τ\text{sim}(x_i,y_i)/\tau). Temperature controls sharpness: small τ\tau amplifies logits, forcing the positive to win decisively; large τ\tau flattens the distribution, diluting positive-negative separation. Example: positive sim=0.9\text{sim}=0.9, negative sim=0.2\text{sim}=0.2; with τ=0.07\tau=0.07 (CLIP's default) logits become 0.9/0.07≈12.860.9/0.07 \approx 12.86 vs 0.2/0.07≈2.860.2/0.07 \approx 2.86, the positive softmax probability is ≈99.99%\approx 99.99\% and the loss is near zero; with τ=1\tau=1 the logits are only 0.9 vs 0.2, giving about 66.7%66.7\% positive probability — the model almost loses discriminative power.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of InfoNCE Contrastive Loss.
Use Cases
In production engineering, what are the primary use cases for InfoNCE Contrastive Loss and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Write the InfoNCE loss and explain every symbol? How is it related to cross-entropy?
2
How to pick temperature τ? What happens when τ is too small or too large (numeric example)?
3
Why does a larger batch size help? Where do negatives come from?
4
InfoNCE vs triplet loss and vanilla NCE: key differences?
5
How does temperature interact with gradients in CLIP's symmetric loss? Handling hard negatives?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "InfoNCE Contrastive Loss"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
← Previous CardCLIP Two-Tower ArchitectureNext Card →CLIP Applications

🔗 More Multimodal Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/Multimodal/card/contrastive-loss