Positive Pair
Two views of the same example generated through transformations or data augmentations. The model learns to produce close representations for these pairs, capturing invariance under irrelevant transformations.
Learning representations by comparing pairs of similar and dissimilar examples
Contrastive Learning is a machine learning paradigm that trains models by learning to compare examples: bringing closer together in vector space those representations that should be similar (positive pairs) and pushing apart those that should be distinct (negative pairs). This approach allows the model to discover useful structures in the data without the need for manual labels, becoming one of the pillars of modern self-supervised learning.
The central idea can be summarized with an intuitive analogy: the model learns that two different augmentations of the same image should produce close representations to each other, while representations of different images should be far apart. The key component is the contrastive loss function, which guides this process of organizing the latent space.
Contrastive learning is structured around the construction and comparison of two types of pairs
Two views of the same example generated through transformations or data augmentations. The model learns to produce close representations for these pairs, capturing invariance under irrelevant transformations.
Views from different examples in the dataset. The model learns to separate them in the vector space, forcing internal representations to capture semantically significant differences between instances.
The most commonly used loss function is InfoNCE (Noise-Contrastive Estimation), which maximizes the similarity between positive pairs relative to negative ones. Variants such as NT-Xent loss and the frequency-aware loss for biometric signals extend this framework to specific domains.
Four families of algorithms that have defined the state of the art in contrastive learning
Despite its progress, Contrastive Learning faces fundamental challenges that define active research lines in the field
Too-easy negatives don't provide learning; false negatives (similar instances treated as different) degrade representations.
Without negatives or with inappropriate architectures, the model can collapse and assign the same representation to all examples.
Transformations valid for images don't work on time series or EEG; defining which preserve relevant information requires domain knowledge.
Requires large batches or extensive queues of negatives, limiting direct use in resource-constrained environments.
In the GPAIS group at IAFER chair, we apply Contrastive Learning to problems where labeled data is scarce and between-subject variability is high, with special focus on biomedical signals:
Contrastive Learning has growing impact in multiple domains where unlabeled data is abundant but annotations are costly or scarce: