# Uczenie metryk podobieństwa

EN: **Deep metric learning** · id `metriclearning` · aliases: metric learning, uczenie metryki, similarity metric learning

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Sieci i modele generatywne](https://aiatlasgraph.com/t/neural.md) › [Reprezentacje i embeddingi](https://aiatlasgraph.com/t/representations.md) › Uczenie metryk podobieństwa

## Description

- PL: Uczenie przestrzeni embeddingów, w której odległość odzwierciedla podobieństwo semantyczne, stratami parowymi, trypletowymi lub opartymi na proxy.
- EN: Learning an embedding space where distance reflects semantic similarity, using pairwise, triplet or proxy-based losses.

## In one sentence

- PL: Model uczy się mierzyć podobieństwo tak, żeby podobne rzeczy lądowały blisko siebie, a różne daleko.
- EN: A model learns to measure similarity so that alike things land close together and different ones far apart.

## Problem it solves

- PL: Gdy rodzajów jest za dużo albo ciągle dochodzą nowe, nie da się wytrenować zwykłego klasyfikatora dla każdego.
- EN: When there are too many kinds, or new ones keep appearing, you can't train an ordinary classifier for each.

## What it does

- PL: Zamiast zapamiętywać każdą klasę, uczy się porównywać, jak ochroniarz sprawdzający, czy twarz pasuje do zdjęcia na przepustce.
- EN: Instead of memorising every class it learns to compare, like a guard checking whether a face matches the photo on a pass.

## Everyday example

- PL: Sklep pozwala zrobić zdjęcie butów na ulicy i pokazuje najbardziej podobne modele z katalogu.
- EN: A shop lets you snap a photo of shoes on the street and shows the most similar pairs from its catalogue.

## This concerns you if you…

- PL: szukasz podobnych zdjęć, dźwięków lub produktów
- PL: nowe kategorie pojawiają się częściej, niż możesz trenować model
- EN: search for similar photos, sounds or products
- EN: new categories appear faster than you can retrain

## Keywords

triplet loss · contrastive loss · siamese networks · ArcFace · proxy anchor loss · hard negative mining · pytorch-metric-learning · Recall@K

## How it works

- PL: Sieć, często syjamska ze wspólnymi wagami, koduje przykłady jako wektory. Strata kontrastowa lub trypletowa przybliża pary tej samej klasy i oddala różne o margines; ważny jest dobór trudnych negatywów. Gotowe wektory porównuje się odległością i wyszukuje najbliższych sąsiadów.
- EN: A network, often siamese with shared weights, encodes examples as vectors. A contrastive or triplet loss pulls same-class pairs together and pushes different ones apart by a margin; mining hard negatives matters. The vectors are compared by distance and searched by nearest neighbours.

## Limits

- PL: Wynik mocno zależy od doboru par i protokołu oceny; porównania w jednakowych warunkach pokazały, że wiele raportowanych postępów znikało. Wyszukiwanie trudnych negatywów jest kosztowne.
- EN: Results depend heavily on pair selection and evaluation protocol; like-for-like comparisons showed many reported gains vanished. Mining hard negatives is costly.

## Key terms

- PL: **strata trypletowa**: Kara, gdy przykład jest bliżej obcego niż swojego o mniej niż margines.
- PL: **sieć syjamska**: Dwie kopie tej samej sieci porównujące dwa wejścia.
- PL: **trudny negatyw**: Przykład innej klasy, który model łatwo myli z właściwą.
- EN: **triplet loss**: A penalty when an example isn't closer to its own than to a stranger by a margin.
- EN: **siamese network**: Two copies of one network comparing two inputs.
- EN: **hard negative**: An example of another class the model easily confuses with the right one.

## Know first

- [Funkcje straty (entropia krzyżowa, MSE) (Loss functions (cross-entropy, MSE))](https://aiatlasgraph.com/t/lossfunctions.md)

## Related topics

Untyped, symmetric "see also" links.

- [Bazy wektorowe (Vector databases)](https://aiatlasgraph.com/t/vectordb.md)
- [Uczenie samonadzorowane (Self-supervised learning)](https://aiatlasgraph.com/t/selfsupervised.md)

## Sources

- [A Metric Learning Reality Check](<https://arxiv.org/abs/2003.08505>) `musgrave-metric-reality-2020` · by Kevin Musgrave, Serge Belongie, Ser-Nam Lim
- [FaceNet: A Unified Embedding for Face Recognition and Clustering](<https://arxiv.org/abs/1503.03832>) `schroff-facenet-2015` · by Florian Schroff, Dmitry Kalenichenko, James Philbin

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/metriclearning · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
