AI engineering glossary · NLP embeddings
What is triplet loss?
Triplet loss: A loss that uses an anchor, a positive example similar to it and a negative example unlike it, and penalises the model unless the anchor is closer to the positive than to the negative by a margin: L = max(0, d(a, p) - d(a, n) + margin).
Triplet loss: an example
With d(a, p) = 0.4, d(a, n) = 0.5 and margin 0.2, loss = max(0, 0.4 - 0.5 + 0.2) = 0.1.
Related terms
More NLP embeddings terms
- Truncation
- Unicode normalisation
- Unigram
- Unigram language model tokeniser
- Viterbi algorithm
- Vocabulary
- Vocabulary size
- Word analogy
Where you learn it
Triplet loss is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.