Triplet loss is a contrastive learning objective that trains a model using data triplets: an anchor sample, a positive sample (similar to the anchor), and a negative sample (dissimilar to the anchor). The function minimizes the distance between the anchor and positive embeddings while maximizing the distance between the anchor and negative embeddings. This creates a metric space where semantic similarity corresponds to spatial proximity, which is fundamental for tasks like face recognition and semantic search.
