# tensorflow/similarity

TensorFlow Similarity is a python package focused on making similarity learning quick and easy.

Repository: https://github.com/tensorflow/similarity
Canonical: https://ross.abutalabs.com/products/tensorflow-similarity
Language: Python
License: Apache-2.0
License Family: permissive
Topics: similarity-learning, metric-learning, similarity-search, nearest-neighbor-search, nearest-neighbors, deep-learning, tensorflow, contrastive-learning, machine-learning, unsupervised-learning, clustering, python, simclr, simclr2, barlow-twins, simsiam, cosine-similarity, knn
Archived: true
Last push: 2024-05-06T14:57:49+00:00

## Health v2 (maintenance only)
Score: 10/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 2270, "days_push": 849, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: archived
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1020, forks 105 (observed 2026-08-28T04:03:15.261379+00:00)

## What it is
TensorFlow Similarity is a Python library built on TensorFlow for training and serving similarity and metric learning models, including self-supervised and contrastive methods. It provides losses, metrics, samplers, visualizers, and an indexing subsystem for embedding-based nearest neighbor search.

## Use cases
- train a metric learning model to output embeddings for image similarity search
- pretrain a model with self-supervised contrastive learning on unlabeled images
- find nearest neighbors of images in a large corpus using learned embeddings
- cluster unseen examples by similarity after training on few classes
- fine-tune a contrastively pretrained model on a small labeled dataset
- evaluate retrieval quality with metrics like Precision@K

## When to choose
- you use TensorFlow and need metric or contrastive learning with losses like SimCLR, Barlow Twins, or VicReg
- you want an integrated pipeline from training embeddings to indexing and querying nearest neighbors
- you need self-supervised pretraining to boost accuracy on small labeled datasets

## When to avoid
- you work in PyTorch or another framework rather than TensorFlow
- you need a stable, production-guaranteed API - the library is in beta and may have breaking changes
- you only need off-the-shelf embeddings without training your own similarity model

## Facets
- artifact type: library
- maturity: maintenance
- function: machine-learning, deep-learning, search-engine, data-visualization
- domain: machine-learning, deep-learning, computer-vision
- platform: python
- tags: similarity-learning, metric-learning, contrastive-learning, self-supervised-learning, embeddings, nearest-neighbor-search, tensorflow, knn, simclr, barlow-twins, search

## Member repositories
- tensorflow/similarity (main) score 10

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:15.261379+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:09:19.881557+00:00, confidence not recorded.
  - readme: https://github.com/tensorflow/similarity (fetched 2026-08-28T04:03:15.261379+00:00, sha ed5d0d9ea95a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
