skillfed

pynndescent

Nearest Neighbor Descent

pynndescent v0.6.0 7.0M downloads/30d#1,804 on PyPI969
Permissive license BSD-2-Clause Active released

What it is and what it does

PyNNDescent is a Python library for building approximate nearest neighbor (ANN) search indexes using the nearest neighbor descent algorithm, supplemented with random projection trees for initialization. It supports a large variety of distance metrics including euclidean, manhattan, cosine, hamming, wasserstein, and many others, as well as custom user-defined metrics.

The library provides a simple two-operation interface: construct an index from training data, then query it for the k nearest neighbors of new points. It integrates with scikit-learn and can serve as a drop-in replacement for KNeighborTransformer in algorithms that use nearest neighbor computations. The implementation relies on numba for JIT compilation and joblib for parallelization.

Use it for:

  • Build a searchable index for similarity-based recommendation systems or content retrieval
  • Perform fast approximate k-nearest neighbor queries on high-dimensional embeddings or feature vectors
  • Integrate nearest neighbor search into scikit-learn pipelines as a preprocessing or feature transformation step
  • Find similar items across different distance metrics (e.g., cosine for text embeddings, euclidean for image features)
  • Construct k-neighbor graphs for clustering, graph-based learning, or dimensionality reduction algorithms

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyNNDescent builds approximate nearest neighbor search indexes using nearest neighbor descent algorithms, supporting a wide variety of distance metrics for fast k-neighbor queries on high-dimensional data.

Yes. PyNNDescent is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive BSD-2-Clause license. It solves a well-defined problem with broad metric support and scikit-learn integration. Suitable for production use in recommendation systems, similarity search, and machine learning pipelines.

Install

pynndescent on PyPI

pip

pip install pynndescent

uv

uv add pynndescent

poetry

poetry add pynndescent

Installing pynndescent

Before you install

Low friction: pure Python wheel with five runtime dependencies (scikit-learn, scipy, numba, llvmlite, joblib) that are standard in scientific Python. Last release 218 days ago with active repository maintenance and 969 stars.

License in practice

BSD-2-Clause permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install pynndescent

from pynndescent import NNDescent
index = NNDescent(data)
index.query(query_data, k=15)

Verify before relying

  • Whether the 80%-100% accuracy rate claim applies to all distance metrics or only specific ones
  • Performance comparison details with other ANN libraries beyond the ann-benchmarks reference

Package facts

License BSD-2-Clause (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 5 — scikit-learn, scipy, numba, llvmlite, joblib
Maintenance actively maintained — 218 days since the last release
Last repo commit
First released
Downloads 6,964,792/month — #1,804 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pynndescent-0.6.0-py3-none-any.whl

Keywords: nearest, neighbor, knn, ANN

Development Status :: 3 - AlphaIntended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/EngineeringTopic :: Software Development

Tags

approximate nearest neighbor searchknn indexing libraryann algorithm pythonnearest neighbor graph constructionfast similarity searchk-nearest neighbors indexdistance metric search
approximate-searchknn-indexingdistance-metrics

More Software Development packages