Paper Breakdowns  /  SimCLR
Paper 55~11 min readICML 2020worked math + runnable code
Paper Breakdown

SimCLR,
explained.

How do you teach a model to see without ever telling it what anything is? SimCLR's answer is a single, almost obvious rule: two crops of the same photo should look alike to the model, and any two different photos should look different. Train hard on that one comparison, over millions of unlabeled images, and rich visual features fall out — enough to rival models trained with full supervision. Here's the contrastive loss that makes it happen, and the three ingredients it depends on.

Video breakdown
The animated walkthrough is in production.
Read the full breakdown below in the meantime ↓
01

Learning by comparison

Labels are expensive; raw images are nearly free. Self-supervised learning tries to build good representations from unlabeled data by inventing a task the data itself can grade. SimCLR's invented task is contrastive: given a representation, judge whether two inputs are "the same thing seen differently" or "different things." No categories, no annotations — just same-or-different.

The elegant part is where the supervision comes from. Take one image, apply two random transformations — crop it here, jitter its colors, blur it — and you have two views that you know depict the same content. That known relationship is the label the model never had. Learn to pull those two views together in representation space while pushing away every other image, and you have learned what makes an image what it is, invariant to the incidental stuff.

The one-sentence version

Two augmented views of one image should be close; all other images should be far — that single contrastive rule, trained at scale, learns visual features with no labels.

02

Positives and negatives

Concretely: take a batch of images. For each one, create two augmented views. The two views of the same image are a positive pair — they should end up close. Every view of a different image in the batch is a negative — it should end up far. So each anchor view has exactly one positive to attract and many negatives to repel, all supplied by the batch itself for free.

One contrastive step
AugmentTwo random views per image (crop, color, blur) → the positive pair.
EncodeA shared encoder + projection head maps each view to a vector.
CompareCosine similarity of the anchor to its positive and to all negatives.
ContrastPull the positive close, push negatives away — the NT-Xent loss.

Nothing here required a human to say "this is a dog." The batch is its own answer key: same image, positive; different image, negative. That is what makes it self-supervised, and why more images in a batch simply means more negatives to learn from.

03

The NT-Xent loss

The loss that enforces all this is NT-Xent — normalized, temperature-scaled cross-entropy. For an anchor view i with positive partner j, it is a softmax classification where the "correct class" is the positive and every negative is a wrong class. Similarities are cosine (that's the "normalized"), scaled by a temperature τ:

Li = − log   exp( sim(zi, zj) / τ )  /  Σk≠i exp( sim(zi, zk) / τ )

Minimizing this maximizes the positive's share of the softmax — it rises as the positive similarity grows, and falls as any negative creeps closer, so one loss both attracts the positive and repels negatives. The temperature τ controls how sharply the model focuses on the hardest (closest) negatives — smaller τ, sharper focus. And because the denominator sums over every negative, a bigger batch makes the task harder and the features stronger. The runnable version below shows the loss dropping as the positive dominates and rising as negatives multiply.

04

Three ingredients

SimCLR's other contribution was measuring what actually matters. Three choices proved decisive:

IngredientWhy it matters
Strong augmentationThe augmentations define the invariances learned. The composition — especially random crop plus color distortion — was critical; weak augmentation gives weak features.
Projection headA small MLP applied before computing the loss. Contrasting in this projected space, then discarding the head and keeping the layer beneath, gave markedly better representations.
Large batchesMore images per batch = more and harder negatives per step. SimCLR benefited from very large batches (and long training) more than supervised learning does.

The projection-head finding is a subtle, influential one: the representation you train the contrastive loss on is not the best representation to use downstream. Keeping the pre-projection features — which retain more information the loss would have thrown away — is now standard practice.

RUN IT YOURSELF

Pull the positive, push the negatives

NT-Xent is a temperature-scaled softmax where the positive pair is the right answer. This computes it from cosine similarities: the loss falls as the positive pair gets more similar, rises when a negative creeps closer (a hard negative), rises as you add more negatives (the bigger-batch effect — 0.07 with one negative, 1.5 with fifty), and collapses toward zero once the positive dominates. Change the similarities, the temperature, or the number of negatives and watch the contrast respond.

CPython · WebAssembly
05

What it achieved

SimCLR closed much of the gap between self-supervised and supervised vision. Its headline results reset expectations for learning without labels:

ResultSignificance
Near-supervised linear probeA linear classifier on frozen SimCLR features approached fully-supervised accuracy on ImageNet — features that good, with no labels.
Great low-label fine-tuningWith only 1% of labels, fine-tuning the pre-trained encoder far outperformed training from those labels alone.
Scales with model and batchBigger encoders and larger batches kept helping — the recipe rewarded scale.
SimplicityNo memory bank, no momentum encoder (as in prior methods) — just augmentation, an encoder, a projection head, and NT-Xent.

The simplicity was itself a contribution: earlier contrastive methods leaned on extra machinery like memory banks. SimCLR showed that with enough negatives (big batch) and the right augmentations, you didn't need them — a cleaner recipe that others could build on.

06

Contrastive vs masked

SimCLR crystallized the contrastive family of self-supervised learning — learn by comparison, pull positives together and push negatives apart — and its influence runs straight into multimodal work: CLIP uses the same contrastive idea across images and text. The lineage of follow-ups (MoCo, BYOL, SimSiam) mostly explored how to keep the quality while dropping the need for huge batches of negatives.

It's illuminating to set it beside masked autoencoders, the other great self-supervised family. Contrastive methods need augmentations and negatives and learn invariances; masked methods need neither and learn by reconstruction. Two very different routes to the same destination — strong features without labels — and modern vision draws on both. SimCLR is the clearest statement of the contrastive route.

Worth knowing

The temperature τ is more important than it looks: too high and the model treats all negatives equally and learns loosely; too low and it obsesses over the single hardest negative. A well-tuned τ (often ~0.1–0.5) is part of every contrastive method's recipe.

Frequently asked

Quick answers

What is SimCLR in one line?

A contrastive self-supervised method: two augmented views of an image are a positive pair against a batch of negatives, trained so same-image views are close and different images are far.

What is NT-Xent?

The loss — a temperature-scaled softmax over cosine similarities where the positive pair is the correct class. It pulls positives together and pushes negatives apart in one term.

Why do batch size and augmentation matter?

Every other image in the batch is a negative, so bigger batches give more/harder negatives; augmentations define the invariances the model learns, and their composition is critical.

Contrastive or masked pre-training?

Contrastive (SimCLR) learns by comparison with negatives and augmentation; masked (MAE) learns by reconstruction with neither. Both learn strong features without labels.

A Simple Framework for Contrastive Learning of Visual Representations · Chen, Kornblith, Norouzi, Hinton · ICML 2020 · read the original paper on arXiv → · Vibe Engines · 2026
Finished this one? 0 / 101 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns