Metric Learning
Training models so similar items land closer together and dissimilar items move farther apart.
When should two images be neighbors?
A ceramics archive needs matches by vessel shape. A tall blue jug and a tall white jug share a silhouette, while a shallow blue bowl shares only the first jug’s glaze.
Positive example
Put the differently colored jugs near one another if shape is the declared target.
Hard negative
Give the matching blue bowl as a difficult counterexample, since color alone would produce the wrong grouping.
Test the learned distance
Retrieve neighbors for vessels from another collection. If background cloth or photographic lighting determines the matches, the distance has learned a collection shortcut.
Metric learning is a training approach in which a model learns a similarity space rather than only learning to assign class labels. Instead of just deciding what category an image belongs to, the model learns how close or far apart different examples should be in an embedding space.
Why It Matters
Metric learning matters because many AI tasks are really retrieval problems. A user may want the most similar product photo, the closest matching medical case, the most visually related wildlife sighting, or the nearest face embedding. In those settings, what matters is not only whether the model can classify an item correctly, but whether it places similar items near one another in a way that supports search and ranking.
How It Works
Common approaches use triplets, pairs, or contrastive examples. The model may see an anchor item, a positive match, and a negative example, then learn to pull the positive closer and push the negative farther away. The exact loss can vary, but the principle stays the same: similarity should become something the model is explicitly trained to represent.
Where You See It
Metric learning shows up in face recognition, product search, re-identification, recommendation, and visual search. It also overlaps with transfer learning and self-supervised learning, since strong pretrained models are often later adapted with similarity-focused objectives.
Follow the idea
Related Yenra articles
Related concepts (5)
Source · Schroff and colleagues on learning a distance representation
Return to Metric Learning in the A–Z glossary