FDEInterviews logo
Machine Learning & Data Science / 52
mediumCohereScaleGlean

Contrastive loss vs triplet loss for training embedding models: when would you reach for each?

Triplet loss contrasts an anchor against one negative; modern contrastive losses like InfoNCE contrast against a whole batch at once, which is why CLIP-style training scales and old triplet pipelines stalled. The mining problem, the batch-size lever, and the call interviewers want.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

Triplet loss contrasts an anchor against one negative; modern contrastive losses like InfoNCE contrast against a whole batch at once, which is why CLIP-style training scales and old triplet pipelines stalled. The mining problem, the batch-size lever, and the call interviewers want.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 523 remaining answers · ₹2,000 / $25
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE

The screen is whether the candidate understands that the real axis is how many negatives you contrast against per step (one for classic triplet, the whole batch for InfoNCE/contrastive) and the downstream consequences: hard-negative mining pain for triplet, large-batch dependence for contrastive. Strong candidates name CLIP/SimCLR/sentence-transformer training as the modern default and reserve triplet for cases with explicit, curated hard triplets (face verification, learned hard-negative pipelines). The reserved follow-up is 'why did large in-batch contrastive win': the answer is free hard negatives at scale without a separate mining stage.

DISCUSSION · 0

No comments yet — be the first to share your approach.