6.5.4 · D5Research Frontiers & Practice

Question bank — Self-supervised and contrastive learning (SimCLR, CLIP)

2,440 words11 min readBack to topic

Before we start, four plain-word anchors everyone forgets:

Figure — Self-supervised and contrastive learning (SimCLR, CLIP)
Figure — Self-supervised and contrastive learning (SimCLR, CLIP)

True or false — justify

TF1. "Self-supervised learning uses no labels, so it is the same as unsupervised learning."
False. It manufactures labels (pseudo-labels) from the data's own structure and then trains supervised-style on them; unsupervised methods (clustering, density) never form a label at all.
TF2. "Contrastive learning needs human-annotated positive pairs."
False. Positives are made for free — two augmentations of one image (SimCLR) or an image and its scraped caption (CLIP). No human labels the pair.
TF3. "Lowering the temperature makes the loss softer and more forgiving."
False — it's the opposite. Dividing similarities by a smaller blows up the differences, sharpening the softmax so the model is punished harder unless the positive clearly wins.
TF4. "In SimCLR, the representation (encoder output) is what you use for downstream tasks, not the projection output ."
True. The loss is applied on , but is kept for transfer; the projection head absorbs information useful only for the pretext task, so transfers better empirically.
TF5. "Cosine similarity ignores the length of the embedding vectors and only cares about their direction."
True. Dividing by cancels magnitude, leaving only the angle — that is exactly why embeddings are usually L2-normalized before the loss.
TF6. "A bigger batch always helps a supervised classifier the same way it helps SimCLR."
False. For SimCLR the batch is the negative pool ( negatives), so batch size directly changes the learning signal; for standard supervised training batch size mostly affects optimization noise, not the objective.
TF7. "CLIP's loss is just SimCLR's InfoNCE applied once."
False. CLIP is symmetric: image→text loss (softmax over each row of ) plus text→image loss (softmax over each column of ), averaged — two InfoNCE terms sharing one similarity matrix.
TF8. "Because CLIP is trained contrastively, it can only tell whether an image and a caption match — it can't classify."
False. Zero-shot classification is built from matching: turn each class name into a caption ("a photo of a {dog}") and pick the caption with highest similarity. See Zero-shot and few-shot learning.
TF9. "Removing the projection head entirely would leave SimCLR's downstream accuracy unchanged."
False. Without , the contrastive loss acts directly on , forcing to become invariant to augmentations it should retain info about — measured downstream accuracy drops.
TF10. "In CLIP, the diagonal entries of the similarity matrix are the positives and the off-diagonals are negatives."
True. Row 's only positive is column (its true caption); every off-diagonal () in that row is a negative.

Spot the error

SE1. "The InfoNCE denominator should include only the negatives; adding the positive term is a bug."
Error. Look at the InfoNCE formula: the positive term appears in the denominator sum, and it must — the loss is the negative log-probability of picking the positive among all candidates, so the positive is one of the choices being normalized over.
SE2. "SimCLR treats the anchor itself as one of its own negatives (the term of the sum)."
Error. In the InfoNCE formula the indicator zeroes out exactly the term, so the anchor is never compared to itself; that self-comparison (sim ) would swamp the sum and give a meaningless gradient.
SE3. "To get more negatives cheaply in SimCLR, just augment each image ten times instead of twice."
Error. Those ten views are all positives of each other, not negatives. Negatives come from different source images in the batch; more augmentations of one image add positives, not the contrast you want.
SE4. "CLIP normalizes each row of the similarity matrix with softmax, so the columns need no separate treatment."
Error. The text→image loss softmaxes down the columns of ; skipping it makes the objective asymmetric and lets the image side dominate the shared space.
SE5. "Cosine similarity of two vectors can be anything from to ."
Error. It ranges from (opposite directions) to (same direction); means orthogonal. Negatives can and should push similarity toward negative values, not merely toward zero.
SE6. "Since is symmetric it looks like , so CLIP's row-softmax and column-softmax give identical losses."
Error. Even setting aside that compares image to caption (not symmetric in general), softmax over row normalizes against different competitors than softmax over column , so the two losses differ and both are needed.
SE7. "A temperature of would give the sharpest, best contrastive signal."
Error. divides by zero; as the softmax collapses to a hard argmax, killing gradients for all but the single closest sample and destroying training. There is a useful minimum, not zero.
SE8. "In SimCLR the final loss only counts each pair once, so we compute but never ."
Error. Both directions are summed — each view of a pair serves as anchor once, so with the per-view loss defined above, both and appear in the total.

Why questions

WY1. Why does a logarithm appear in the InfoNCE loss?
It turns the softmax probability into a log-probability, converting products into sums and giving numerically stable, well-scaled gradients — minimizing is maximizing the probability of picking the positive.
WY2. Why use cosine similarity instead of raw dot product?
Cosine strips out vector length so the model can't cheat by simply making all vectors huge; only the direction (semantic content) is compared, which is what we want to align.
WY3. Why does SimCLR need strong augmentation, not mild?
Weak augmentations let the model match views by trivial low-level cues (same pixels, same color histogram). Strong augmentation destroys those shortcuts, forcing genuinely semantic, invariant features — see Data augmentation techniques.
WY4. Why does contrastive learning transfer well to downstream tasks it never trained on?
To separate positives from many negatives, the encoder must capture object parts, shapes, and spatial relations — general features that reappear in classification/detection. That is the whole promise of Representation learning and Transfer learning and fine-tuning.
WY5. Why does CLIP enable zero-shot classification while a normal ResNet trained on ImageNet cannot generalize to unseen labels?
CLIP's supervision is language, so any new class expressed as text lands in the same shared space; a fixed softmax head only knows its trained label set. This is the Multi-modal learning payoff.
WY6. Why does larger batch size in SimCLR generally improve results?
Every other sample in the batch is a negative, so a bigger batch means a richer, harder pool of negatives ( of them), giving a stronger contrastive signal per step.
WY7. Why is the projection head discarded after pretraining?
It's specialized to the contrastive pretext task and may throw away info (like color) that hurts the pretext but helps downstream tasks; keeping before it preserves that richer representation.
WY8. Why does CLIP scale to 400M web pairs without human labeling?
The (image, alt-text) caption already is the supervision, harvested for free from the internet — the label problem is offloaded to whoever wrote the caption.
WY9. Why is temperature described as controlling "hardness of negatives"?
Small magnifies similarity gaps, so near-miss (hard) negatives dominate the gradient; large flattens the distribution so all negatives contribute roughly equally.

Edge cases

EC1. What happens to the InfoNCE loss for one pair if the batch contains zero negatives (batch size 1)?
The denominator equals just the positive term, so the fraction is and the loss is — no gradient, no learning. Contrastive learning is meaningless without negatives.
EC2. What if two different source images in a batch happen to be near-identical (e.g., two photos of the same landmark)?
They get treated as negatives and pushed apart even though they're semantically alike — a false negative. This is a known noise source; large batches make it statistically rare but never zero.
EC3. What if all embeddings collapse to a single point (every vector identical)?
Then every similarity is , positives and negatives are indistinguishable, and the loss is stuck high. Contrastive learning avoids this collapse precisely because negatives penalize making everything similar — unlike some non-contrastive methods that need extra tricks.
EC4. In CLIP, what if the same caption is correct for two images in the batch (duplicate captions)?
The off-diagonal for that duplicate is falsely labeled negative, so the model is pushed to separate a legitimately matching image–caption pair — mild label noise the objective silently tolerates at scale.
EC5. What is when and point in exactly opposite directions?
It is , the minimum possible. Negatives ideally drive toward here, but in practice orthogonality (sim ) is a more common and sufficient outcome.
EC6. What happens to the softmax as (very large temperature)?
All similarities get divided down toward zero, so of each is and the softmax becomes uniform — the positive gets no special weight and the model learns almost nothing.
EC7. If augmentation were the identity (no transform), what would SimCLR learn?
The two "views" would be pixel-identical, so the model matches them by trivial memorization with no invariance learned — the representations wouldn't transfer.
EC8. What breaks if you feed a raw dot product with unnormalized vectors into the temperature-scaled softmax?
The scale of the dot products drifts with vector magnitude, so no longer has a consistent meaning and one large-magnitude sample can dominate — this is why L2-normalization (making it true cosine similarity) is standard.
Recall Self-test: name three ways to accidentally destroy the negative signal

Batch size 1 (no negatives), (uniform softmax ignores the positive), and treating extra augmentations of the same image as negatives (they're positives). Each collapses the contrast the loss depends on.