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).

Level: intermediateTopic: NLP embeddings

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.