Contrastive Learning
How models learn rich representations without human labels by comparing augmented views of the same image.
Reconstructing raw pixels spends model capacity memorising noisy backgrounds. Instead of recreating an image, contrastive learning asks the model to compare views. It learns a representation space by grouping similar things together and pushing different things apart, using the data itself as the label.
The Positive Pair
To teach the model identity, you create two augmented views of the same image. A random crop or colour shift defines what the model should ignore. These two views form a positive pair that share an identity.
Pull and Push
The mechanism is a ranking task. The loss function pulls the embeddings of the positive pair closer together. Simultaneously, it pushes the anchor away from all other unrelated images in the batch, treating them as negatives.
Organised by Identity
Over time, the embedding space organises itself. Images with the same underlying identity cluster tightly together, while distinct classes separate. The model has learned rich, linearly separable features without seeing a single human label.
Where It Breaks
The model assumes every other image in the batch is a true negative. If two photos of a deer happen to be in the same batch, the loss forces them apart. This false negative collision limits how well the clusters can form.
The Quick Version
- Contrastive learning groups data without human labels.
- Positive pairs are created by augmenting the same original image.
- The loss pulls positives together and pushes batch negatives apart.
- The learned space clusters by identity, not raw pixel appearance.
- False negatives in the batch force identical classes apart.