Contrastive Learning
The Method
Contrastive learning is an approach to training representations without explicit labels: the model learns to bring together in vector space objects that should be similar (positive pairs) and push apart those that are not (negative pairs).
flowchart LR
A["positive pair (anchor + positive)"] -->|closer| C["common space"]
B["negative pair (anchor + negative)"] -->|farther| C
How It Works
- Pairs are formed: positive (two views of the same object, text + image) and negative (different objects).
- The model encodes them into embeddings.
- A loss function (e.g., InfoNCE) pulls the positive closer to the anchor and pushes the negatives farther.
Where It Is Used
A classic example is CLIP: the model learns to match an image and its textual description in a common space through a contrastive 'image ↔ caption' task.
The method is also used in multimodal alignment and self-supervised learning.