How does contrastive learning work?
hardAnswer
- Create two augmented views of the same example (positive pair) and treat other examples as negatives.
- Train an encoder so positives are close in embedding space and negatives are far, using a loss like InfoNCE.
- Examples: SimCLR, MoCo, CLIP (contrasts image with text).
- Produces general-purpose embeddings useful for many downstream tasks.
Check yourself — multiple choice
- It pulls all embeddings toward a single point
- It pulls positive pairs together and pushes negatives apart
- It requires human labels for each pair
- It only works with text data
Positives close, negatives far — that's the InfoNCE-style objective.
#representation-learning
Practise Unsupervised Learning
214 interview questions in this topic.