Skip to content
AI.info

Advanced techniques

Contrastive and Bootstrap Representation Learning

Understand how contrastive and non-contrastive methods organize representation space and why pair construction matters.

By the end you can

Visual

The forces acting on an embedding space

A representation objective is easier to understand as a set of geometric pressures. Two views of the same underlying item are created. Both are encoded into a shared space. Similarity between them is increased. Then something has to stop the encoder from answering with a single point for every input.

That last pressure is where the families diverge: explicit negatives, a variance or covariance constraint, or the asymmetry of a slow-moving target network and a stop-gradient. It is also the part of the design that has been measured rather than assumed. The sections that follow replace an intuition about each pressure with a published number — what a shortcut cue is worth in accuracy, what a positive pair can be reduced to, and what happens the moment the anti-collapse term is deleted.

FigureProcess · 5 steps
  1. 1

    Create related views

    Generate two observations that should represent the same underlying item.

  2. 2

    Encode both views

    Map them into a shared representation space.

  3. 3

    Apply attraction

    Increase similarity between positive representations.

  4. 4

    Apply separation or anti-collapse pressure

    Use negatives, variance constraints, or teacher asymmetry.

  5. 5

    Evaluate neighborhood quality

    Check whether semantic neighbors and downstream decisions improve.

The training objective defines the local neighborhoods the model will create.

The positive-pair definition is a hidden label

When two augmented images are declared a positive pair, the method is told that the transformation should not change identity. The declaration can be far thinner than that and still work.

In unsupervised SimCSE the entire positive-pair definition is a second forward pass. The same sentence is encoded twice under standard dropout, and two different dropout masks are the only thing separating the views. That is enough for an average Spearman correlation of 76.3% over seven STS tasks with BERT-base. The supervised variant, which takes entailment pairs from NLI as positives and contradictions as hard negatives, reaches 81.6%. The authors state the mechanism in the abstract, in 2021: “We find that dropout acts as minimal data augmentation and removing it leads to a representation collapse.”

The number did not stay inside one group. The team behind DiffCSE reproduced the unsupervised model in-house a year later at 76.16%, and took 76.25% as the baseline their own method would “raise the averaged Spearman's correlation from 76.25% to 78.49%”.

So the pairing rule is the specification, and it is a weak label smuggled into the data pipeline. In recommender systems, co-consumed items might be treated as related. False positives collapse distinctions that matter. False negatives push related items apart. Instance discrimination, where every other item is treated as a negative, can work surprisingly well at scale, but it becomes a problem when many samples share semantics. Supervised contrastive variants use labels to construct more meaningful positive sets — exactly what supervised SimCSE does when it promotes entailment pairs to positives. Temperature changes how strongly the loss emphasizes the hardest similarities. Batch size or a memory bank changes the number and diversity of negatives. None of this is only an optimization detail. It is the geometry.

Pair construction is the semantic specification of a contrastive system.

Comparison

Contrastive negatives versus bootstrap asymmetry

Both families learn view-consistent representations. They prevent trivial solutions differently, and the difference has been argued out in public with numbers on both sides.

BYOL showed that explicit negatives are not required. Its online network predicts the target network representation of another augmented view, while the target is updated as “a slow-moving average of the online network”. DeepMind reported the result in 2020: “BYOL reaches 74.3% top-1 classification accuracy on ImageNet using the standard linear evaluation protocol with a standard ResNet-50 architecture and 79.6% with a larger ResNet.” The larger network is a ResNet-200 (2×), 250M parameters. The figure then survived a rival lab. Chen and He at Facebook AI Research reproduced every competitor in-house in 2021, and their Table 4 recovers exactly 74.3% for BYOL at 800 epochs — 66.5%, 70.6% and 73.2% at 100, 200 and 400 — against 70.4% for their improved SimCLR reproduction and 71.3% for SimSiam.

Whether the bootstrap really escapes negatives was then contested. Take the normalisation out of BYOL's MLPs and the method stops working. Abe Fetterman and Josh Albrecht, then at Untitled AI and now Imbue, trained a ResNet-18 with BYOL on STL-10 and published the sweep on 24 August 2020. Batch normalisation in both MLPs gave 57.7% linear-evaluation accuracy. No normalisation gave 28.3%, layer norm gave 29.4%, and the random baseline is 28.8%. Removing batch statistics left the encoder indistinguishable from an untrained one. Batch statistics, they argued, act as implicit negatives.

Two months later DeepMind answered with a batch-independent scheme, group normalisation plus weight standardisation, reaching 73.9% against vanilla BYOL's 74.3% ImageNet top-1 with ResNet-50. The abstract does not hedge: “Our finding disproves the hypothesis that the use of batch statistics is a crucial ingredient for BYOL to learn useful representations.” The dispute was settled the way such disputes are settled. Somebody re-ran the thing without the ingredient.

FigureComparison · 3 columns

Contrastive learning

Attract positives and separate selected negatives.

  • Explicitly shapes relative similarity
  • Benefits from diverse negatives
  • Can suffer false-negative conflicts
  • Example: SimCLR and MoCo

Bootstrap learning

Predict a target-network representation of another view.

  • Can work without explicit negatives
  • Uses asymmetry such as stop-gradient and moving targets
  • Collapse prevention is less intuitive
  • Example: BYOL

Redundancy-reduction methods

Encourage informative dimensions without pairwise negatives.

  • Use variance, covariance, or cross-correlation constraints
  • Target dimension-level diversity
  • Sensitive to normalization choices
  • Examples: Barlow Twins and VICReg

Example

Design choices that change the learned neighborhoods

Each choice should be justified by downstream semantics, and the sensitivity is usually larger than intuition suggests. The rate at which a target network is updated is not a default to inherit. It is a tuned hyperparameter with measured cliffs on both sides.

MoCo's momentum ablation reports ResNet-50 accuracy of 55.2%, 57.8%, 59.0% and 58.9% for momentum m = 0.9, 0.99, 0.999 and 0.9999 with a 4096-key queue. At the bottom of the range it does not degrade, it fails: “When m is too small (e.g., 0.9), the accuracy drops considerably; at the extreme of no momentum (m is 0), the training loss oscillates and fails to converge.” BYOL's Table 5a shows the mirror image on its own scale. Target decay 0.999 gives 69.8%, 0.99 gives 72.5%, 0.9 gives 68.4%. An instantaneously updated target (τ = 0) gives 0.3%, and a frozen random target (τ = 1) gives 18.8% ± 0.7. One number, moved a little, spans the distance between a working encoder and chance.

  • Crop strength: Aggressive crops encourage object-level invariance but can remove the only target-relevant region.
  • Color distortion: Useful when colour is nuisance — in SimCLR's ablation it is worth 59.6% to 64.5% unsupervised top-1 — and harmful when colour determines the class or condition.
  • Negative source: In-batch negatives are efficient but depend strongly on batch composition; MoCo's 4096-key queue is what decouples the number of negatives from the batch.
  • Projection head: Training geometry can live in a projection space while downstream features use an earlier representation.
  • Temperature: Lower values emphasize close competitors and can sharpen gradients around hard pairs.
  • Target update rate: BYOL's Table 5a runs from 72.5% at decay 0.99 to 0.3% with an instantaneously updated target, so the teacher's speed is a first-class design decision rather than a default.

Case

Augmentation composition decided what SimCLR learned

SimCLR's own conclusion is about the augmentation pipeline, not the architecture: “composition of data augmentations plays a critical role in defining effective predictive tasks”. A learnable nonlinear transformation between the representation and the contrastive loss improved quality again. The paper appeared in 2020.

The headline result is one sentence of the abstract: “A linear classifier trained on self-supervised representations learned by SimCLR achieves 76.5% top-1 accuracy, which is a 7% relative improvement over previous state-of-the-art, matching the performance of a supervised ResNet-50.” The architecture behind that figure is the part usually dropped in retelling. It is a ResNet-50 (4×), 375M parameters. DeepMind's BYOL paper reprints the same row in its Table 1 — “SimCLR ResNet-50 (4×) 375M 76.5 93.2” — next to SimCLR's ResNet-50 (1×) result of 69.3%. Two labs, one number, and a seven-point gap between the wide model and the standard one. Fine-tuned on 1% of the labels, the same representations gave “85.8% top-5 accuracy”.

Key idea

Augmentations can create an unintended recognition game

If positive views share a camera artifact, crop boundary, timestamp, or preprocessing signature, the encoder may match that cue instead of the intended semantics. SimCLR measured exactly this failure on itself. Most crops of one image share a colour distribution, so colour alone identifies the source image: “Figure 6 shows that color histograms alone suffice to distinguish images. Neural nets may exploit this shortcut to solve the predictive task.”

Table 1 prices the fix. Composing cropping with colour distortion lifts unsupervised ResNet-50 linear top-1 from 59.6% at colour-distortion strength 1/8 to 63.2% at strength 1, and to 64.5% once blur is added. The supervised baseline moves the other way over the same settings, 77.0% down to 75.7%. The augmentation that costs a supervised model accuracy is the one that makes the unsupervised task worth solving. It destroys the cue the encoder would otherwise have won with. A 2021 paper asking whether contrastive learning can avoid shortcut solutions states the general form: “the contrastive loss does not always sufficiently guide which features are extracted ... by inadvertently suppressing important predictive features.” The opposite failure is real too. If augmentations remove too much content, positives may no longer represent the same concept.

Inspect nearest neighbors before and after each major augmentation change. Use domain experts to judge whether the learned invariances make sense. An embedding that scores well on one benchmark can still organize production examples around nuisance features.

The geometry will faithfully reflect the pair-generation pipeline, including its mistakes.

Analogy

Arranging a library by “belongs near” and “belongs apart” cards

The library has no shelf labels. What arrives instead is a pile of cards saying which books should sit near each other and, for some methods, which should be far apart. If the cards encode topic, the library becomes useful for discovery. If they encode cover color, the arrangement is consistent but semantically poor. The colour-histogram result above is that failure, caught with a number.

Bootstrap methods resemble using an older draft of the shelf plan as a moving target. That can settle the shelves into a stable order without explicit “far apart” cards. The draft has to be old enough to be stable and new enough to be informative, which is what the target-decay sweep is measuring. The process still needs safeguards against putting every book on one shelf.

Representation learning succeeds when the pair rules encode the relationships users will later need.

Steps

An embedding audit before downstream deployment

Treat the embedding as a product with observable neighborhoods, and make the collapse check a measurement rather than an impression.

SimSiam reaches 67.7% ImageNet linear accuracy at 100 epochs. Delete a single element of the architecture, nothing else changed, and Chen and He report what happens: “Solely removing stop-gradient, the accuracy becomes 0.1%, which is the chance-level guess in ImageNet.” The failure is visible before any probe is trained, because the std of the l2-normalised output falls to zero. Every input has been mapped to the same point. Chaoning Zhang and colleagues reproduced the collapse independently in 2022, in symmetric variants on CIFAR-100 with a ResNet-18 — SimSiam at 66.62% top-1 against 1% for Mirror SimSiam, Naive Siamese and Symmetric Predictor — while refuting SimSiam's own alternating-optimisation explanation of why the stop-gradient works.

That is the shape of a good audit step: a statistic that separates a working encoder from a dead one by two orders of magnitude, computed before anything downstream is fitted. Variance and norm statistics first. Then nearest neighbors across slices, then linear and few-label probes, then augmentation-sensitivity tests, then retrieval at the depth the product will actually show. Retest under domain shift last, because neighborhoods reorganize on new devices and populations.

FigureProcess · 6 steps
  1. 1. Measure variance and norm statistics

    Check for collapse, dead dimensions, or unstable scale.

  2. 2. Inspect nearest neighbors

    Review semantic and nuisance similarities across slices.

  3. 3. Run linear and few-label probes

    Measure accessible downstream information.

  4. 4. Test augmentation sensitivity

    Confirm intended invariances without erasing target signal.

  5. 5. Evaluate retrieval at operating depth

    Use recall or precision at the number of neighbors the product will show.

  6. 6. Retest under domain shift

    Embedding neighborhoods can reorganize on new devices or populations.

Steps

Audit the pair generator before tuning the encoder

Most contrastive failures begin with assumptions about which views should agree or disagree. Those assumptions are not abstractions. They are a dataset somebody can open.

LAION-5B was assembled by crawling Common Crawl and keeping image–alt-text pairs whose CLIP similarity was high enough. A similarity threshold was the pair rule, and effectively the only gate. On 23 December 2023 David Thiel at the Stanford Internet Observatory published an audit of it: “Through this process, we identified 3,226 dataset entries of suspected CSAM, much of which was confirmed as CSAM by third parties.” LAION withdrew the dataset. On 30 August 2024 it published Re-LAION-5B — 5,526,641,167 pairs, with 2,236 links removed using hash lists from the Internet Watch Foundation and the Canadian Centre for Child Protection, a removal set that “subsume[s] 1008 links found by the Stanford Internet Observatory report in Dec 2023”.

The precedent is the point. A pair generator is a data pipeline with a public record. An outside party can inspect what the rule admitted, and the maintainer can republish with a changed count and a dated explanation. Do the same at your own scale, before tuning the encoder. Define what two positive views must share. Find pairs labelled different that are the same entity. Stress the augmentations for erased target signal. Measure how batch sampling changes negative difficulty and class coverage. Evaluate the frozen geometry with retrieval and probes before any end-to-end fine-tuning. Track feature variance, rank, and target-network behaviour as collapse indicators.

FigureProcess · 6 steps
  1. 1. Define positive semantics

    Explain what information two positive views must share.

  2. 2. Identify false negatives

    Find pairs labeled different that may represent the same class or entity.

  3. 3. Stress augmentations

    Check whether transformations erase target-relevant details.

  4. 4. Inspect batch composition

    Measure how sampling changes negative difficulty and class coverage.

  5. 5. Evaluate frozen geometry

    Use retrieval, probes, and neighborhood inspection before end-to-end fine-tuning.

  6. 6. Test collapse indicators

    Track feature variance, rank, and target-network behavior when applicable.

Key takeaways