Self-Supervised & Contrastive Learning
Q: How do models learn without labels?
Create a supervised task from the data itself:
- Masked prediction: BERT (mask tokens), MAE (mask image patches) — reconstruct what's hidden.
- Next-token prediction: GPT-style language modelling.
- Contrastive: SimCLR/MoCo (two augmentations of the same image are positives, others negatives), CLIP (image–caption pairs). Loss = InfoNCE:
−log exp(sim(q,k⁺)/τ) / Σ exp(sim(q,k)/τ); needs many negatives (large batches or memory queues). - Non-contrastive: BYOL, DINO — avoid collapse with stop-gradient / momentum teachers. Pretrain on huge unlabeled data, then fine-tune or linear-probe with few labels.