A self-supervised technique that learns representations by comparing similar and dissimilar data pairs.
Contrastive learning is a self-supervised representation learning approach that trains neural networks by teaching them to distinguish between similar and dissimilar data points, without requiring manually labeled examples. The core idea is to construct pairs or groups of samples — often called positive and negative pairs — and optimize an embedding space where similar inputs are pulled together while dissimilar inputs are pushed apart. This is typically achieved through loss functions such as InfoNCE, triplet loss, or NT-Xent, which quantify the relative distances between representations in a learned latent space.
In practice, positive pairs are usually created through data augmentation: two different augmented views of the same image, audio clip, or text passage are treated as a matching pair, while samples drawn from different instances serve as negatives. During training, the model learns to encode semantically meaningful structure into its representations purely from these relational signals. Frameworks such as SimCLR, MoCo, and BYOL popularized this paradigm around 2020, demonstrating that contrastive pretraining on unlabeled data could produce representations competitive with — or even surpassing — fully supervised baselines on downstream tasks.
Contrastive learning matters because it dramatically reduces dependence on expensive labeled datasets. By leveraging the natural structure of unlabeled data, models can develop rich, transferable feature representations that generalize well across tasks. This has proven especially impactful in computer vision, natural language processing, and multimodal learning — exemplified by models like CLIP, which aligns image and text representations using a contrastive objective across hundreds of millions of image-caption pairs.
Despite its strengths, contrastive learning presents practical challenges. Performance is sensitive to the choice and diversity of negative samples; too few or too similar negatives can lead to degenerate representations. Large batch sizes or memory banks are often required to maintain a sufficient pool of negatives, increasing computational cost. Recent work has explored negative-free alternatives and theoretical explanations grounded in mutual information maximization, pushing the boundaries of what self-supervised learning can achieve.