nmslib
Non-Metric Space Library (NMSLIB)
What it is and what it does
nmslib is a cross-platform C++ library with Python bindings for searching in metric and non-metric spaces. It specializes in approximate nearest-neighbor methods and provides tools to evaluate similarity search algorithms. The library is built on pybind11 and depends on scipy and numpy, making it suitable for scientific and machine-learning workflows where fast approximate similarity matching is needed.
Unlike metric-space libraries that assume triangle inequality, nmslib handles generic and non-metric spaces, which is useful for custom distance functions or domain-specific similarity measures. It offers multiple indexing methods and is actively maintained with wheels for modern Python versions and common platforms.
Use it for:
- Build a fast approximate nearest-neighbor index for large-scale vector search in recommendation systems or semantic search applications.
- Evaluate and benchmark different similarity search algorithms on custom datasets or non-metric distance functions.
- Implement similarity matching for embeddings in NLP or computer vision pipelines where exact nearest-neighbor search is too slow.
- Search in non-Euclidean or custom metric spaces where standard libraries assume L2 or cosine distance.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
nmslib provides efficient similarity search in metric and non-metric spaces, with support for approximate nearest-neighbor methods and evaluation tools for search algorithms.
Yes, if you need efficient approximate similarity search and can tolerate medium install friction from compiled bindings. The library is actively maintained with no known vulnerabilities and offers broad platform support. Verify the license terms and Python version compatibility in the repository before adopting in production.
Install
nmslib on PyPI
pip
pip install nmslibuv
uv add nmslibpoetry
poetry add nmslibInstalling nmslib
Before you install
Medium install friction due to compiled C++ bindings via pybind11. Wheels are available for Python 3.10–3.13 across macOS (Intel and ARM), Linux (x86_64 and aarch64), and Windows. Active maintenance with recent commits suggest reliable upkeep.
License in practice
License treatment is unclear—no SPDX identifier or raw license text is recorded in the package metadata. Verify the actual license in the GitHub repository before adopting in proprietary or restricted-license projects.
Quickstart
pip install nmslib
import nmslib
index = nmslib.init(space='l2', method='hnsw')
index.addDataPointsFromMatrix(data)
index.createIndex()
labels, distances = index.knnQuery(query_vector, k=10)
Requires a C++ compiler and build tools at install time; pybind11 is a build dependency. Python version support is unspecified in package metadata.
Verify before relying
- Exact Python version range supported (requires_python is unspecified in metadata)
- Whether the library is suitable for production use at scale (no documented SLA or performance benchmarks in fact sheet)
- Specific license terms and any commercial use restrictions
- Download volume trend and active user base size
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — pybind11, scipy, numpy |
| Maintenance | actively maintained — 295 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 154,328/month — #10,854 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nmslib-2.1.2-cp310-cp310-macosx_10_13_x86_64.whl; nmslib-2.1.2-cp310-cp310-macosx_11_0_arm64.whl; nmslib-2.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; nmslib-2.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; nmslib-2.1.2-cp310-cp310-win_amd64.whl; nmslib-2.1.2-cp311-cp311-macosx_10_13_x86_64.whl; nmslib-2.1.2-cp311-cp311-macosx_11_0_arm64.whl; nmslib-2.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; nmslib-2.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; nmslib-2.1.2-cp311-cp311-win_amd64.whl; nmslib-2.1.2-cp311-cp311-win_arm64.whl; nmslib-2.1.2-cp312-cp312-macosx_10_13_x86_64.whl; nmslib-2.1.2-cp312-cp312-macosx_11_0_arm64.whl; nmslib-2.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; nmslib-2.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; nmslib-2.1.2-cp312-cp312-win_amd64.whl; nmslib-2.1.2-cp312-cp312-win_arm64.whl; nmslib-2.1.2-cp313-cp313-macosx_10_13_x86_64.whl; nmslib-2.1.2-cp313-cp313-macosx_11_0_arm64.whl; nmslib-2.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
scannScaNN performs efficient vector similarity…
permissive · top 15,000 on PyPI
voyagerVoyager performs fast approximate…
permissive · top 15,000 on PyPI
annoyAnnoy searches for approximate nearest…
permissive · top 5,000 on PyPI
libcuvs-cu12GPU-accelerated vector search and clustering…
permissive · top 15,000 on PyPI
usearchUSearch provides approximate nearest-neighbor…
permissive · top 15,000 on PyPI
pynndescentPyNNDescent builds approximate nearest neighbor…
permissive · top 5,000 on PyPI
hnswlibFast approximate nearest neighbor search using…
unclear · top 15,000 on PyPI
pyspark-hnswProvides a PySpark-compatible implementation of…
unclear · top 15,000 on PyPI
mhfpEncodes molecular structures as MinHash…
unclear · top 15,000 on PyPI
kdtreeConstructs, modifies, and searches…
permissive · top 15,000 on PyPI