What is Contrastive learning?
In Turkish: Karşıtsal öğrenme · Topic: Models and training
A training approach that learns meaningful representations, often from unlabeled data, by pulling similar examples closer together in representation space and pushing dissimilar ones apart.
How does it work?
The model turns each example into a vector of numbers, called an embedding. Pairs judged similar are treated as positives and unrelated pairs as negatives; for instance, two different crops of the same photo form a positive pair. The loss function gets smaller when the vectors of positive pairs are close and those of negatives are far apart. Under this pressure the model discovers on its own the features that tell examples apart. That reduces the need for human-assigned class labels.
Why does it matter?
Labeling is expensive, while unlabeled data is plentiful. Contrastive learning is one of the main ways to extract strong representations from such data. Text embedding models, visual representations and multimodal systems can all be trained this way, and it is useful in search and recommendation systems too.
Example
A text embedding model sees a question and the paragraph containing its answer as a positive pair, while unrelated paragraphs are negatives. A search system then retrieves the paragraphs whose vectors are closest to the question.
FAQ
How is it different from supervised learning?
Supervised learning gives a correct label for every example. Contrastive learning only needs to know whether examples are similar or not, and that information often comes from the data itself.
Why are negative examples needed?
If only positives are pulled together, the model can take a shortcut and map everything to the same point. Negatives keep the representations spread apart. Some methods work without negatives but use other safeguards to prevent that collapse.