#5656th of 168 in ML frameworks and libraries

pytorch-metric-learning

PyTorch library of metric learning losses, miners, and distances for embedding models

Stars
6.3k
License
MIT
Last commit
Nov 2026
Last release
Nov 2026
Language
Python
Stars, last 29 weeks+53
21 Apr 2026: 6,290 stars28 Apr 2026: 6,295 stars5 May 2026: 6,299 stars12 May 2026: 6,299 stars19 May 2026: 6,301 stars26 May 2026: 6,303 stars2 Jun 2026: 6,305 stars9 Jun 2026: 6,309 stars16 Jun 2026: 6,310 stars23 Jun 2026: 6,311 stars30 Jun 2026: 6,313 stars7 Jul 2026: 6,317 stars14 Jul 2026: 6,319 stars21 Jul 2026: 6,319 stars28 Jul 2026: 6,322 stars4 Aug 2026: 6,323 stars11 Aug 2026: 6,324 stars18 Aug 2026: 6,326 stars25 Aug 2026: 6,327 stars1 Sept 2026: 6,328 stars8 Sept 2026: 6,329 stars15 Sept 2026: 6,330 stars22 Sept 2026: 6,330 stars29 Sept 2026: 6,332 stars6 Oct 2026: 6,333 stars13 Oct 2026: 6,335 stars20 Oct 2026: 6,336 stars27 Oct 2026: 6,340 stars3 Nov 2026: 6,341 stars10 Nov 2026: 6,343 stars

6,290 on 21 Apr 20266,343 on 10 Nov 2026

From GitHub's daily star counts.

Checked on GitHub.

Overview

A PyTorch library for training embedding models with composable losses, hard-example miners, distances, reducers, and regularizers. Components drop into an existing training loop, taking embeddings and integer labels where equal labels mark positive pairs. Retrieval metrics are included, with an optional Faiss backend and scikit-learn for NMI/AMI clustering metrics.

Who it is for: ML engineers training embedding models for retrieval, clustering, or recognition

Strengths

  • Losses, miners, distances and reducers are separate components that can be combined
  • Fits into a plain PyTorch loop; core needs only PyTorch and NumPy
  • Each component's docs page states its signature, defaults, tensor contract, and paper
  • Optional extras for Faiss retrieval and scikit-learn clustering metrics

Weaknesses

  • Version 3 requires Python 3.12+, PyTorch 2.14.0+ and NumPy 2.5.3+
  • Upgrading from version 2 requires a migration guide because names changed
  • Library only: no training CLI, pretrained models, or serving layer
  • Pair and triplet setup relies on integer labels in batches

What it needs

  • GPU optional
  • Needs PyTorch, NumPy, Faiss (optional), scikit-learn (optional)
  • Models: Any torch.nn.Module that outputs embeddings

Quick answers

Is pytorch-metric-learning open source?

Yes. Its code is on GitHub under the MIT license.

Does pytorch-metric-learning need a GPU?

No. It runs on a CPU and can use a GPU when you have one.

Also in ML frameworks and libraries

See all 168
Also in ML frameworks and libraries
RankProjectScore
1transformersPython library defining open models for text, vision, audio and multimodal tasks168.8k stars+1,522 (+0.9%) in 30 daysApache-2.094 out of 100
2pytorchPython tensor library with GPU support and tape-based autograd105.4k stars+1,043 (+1.0%) in 30 dayscustom license93 out of 100
3ultralyticsPython library and CLI for training and running YOLO vision models63.3k stars+1,015 (+1.6%) in 30 daysAGPL-3.093 out of 100
#4pytorch-image-modelsPyTorch library of image models, pretrained weights and training scripts37.3k stars+101 (+0.3%) in 30 daysApache-2.093 out of 100
#5supervisionPython toolkit for loading, annotating and counting computer vision detections Live demo ↗ (opens in a new tab)51.6k stars+514 (+1.0%) in 30 daysMIT92 out of 100