pynndescent
Nearest Neighbor Descent
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 pynndescentuv
uv add pynndescentpoetry
poetry add pynndescentInstalling 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
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
annoyAnnoy searches for approximate nearest…
permissive · top 5,000 on PyPI
pyspark-hnswProvides a PySpark-compatible implementation of…
unclear · top 15,000 on PyPI
rtreeRtree wraps libspatialindex to provide spatial…
permissive · top 5,000 on PyPI
nmslibnmslib provides efficient similarity search in…
unclear · top 15,000 on PyPI
scannScaNN performs efficient vector similarity…
permissive · top 15,000 on PyPI
cuvs-cu12Provides GPU-accelerated approximate nearest…
permissive · top 15,000 on PyPI
libcuvs-cu12GPU-accelerated vector search and clustering…
permissive · top 15,000 on PyPI
missingpyFills missing values in data arrays using…
copyleft · top 15,000 on PyPI
kdtreeConstructs, modifies, and searches…
permissive · top 15,000 on PyPI
umap-learnUMAP reduces high-dimensional data to lower…
permissive · top 5,000 on PyPI