#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
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| Rank | Project | Score |
|---|---|---|
| 1 | transformersPython library defining open models for text, vision, audio and multimodal tasks | 94 out of 100 |
| 2 | pytorchPython tensor library with GPU support and tape-based autograd | 93 out of 100 |
| 3 | ultralyticsPython library and CLI for training and running YOLO vision models | 93 out of 100 |
| #4 | pytorch-image-modelsPyTorch library of image models, pretrained weights and training scripts | 93 out of 100 |
| #5 | supervisionPython toolkit for loading, annotating and counting computer vision detections | 92 out of 100 |