Qdrant is a Rust-based vector similarity search engine and vector database with payload filtering, for semantic search and recommendation.
nmslib/hnswlib
Header-only C++ library with Python bindings for fast approximate nearest neighbor search using the HNSW graph algorithm.
- Stars
- 5,364
- Forks
- 862
- Open issues
- 311
- Last commit
- 2 months ago
What is it?
Hnswlib is a header-only C++ implementation of Hierarchical Navigable Small World (HNSW) graphs for approximate nearest neighbor search. It indexes high-dimensional vectors so that finding the closest matches to a query vector is much faster than brute-force comparison, at the cost of returning results that are approximately, not exactly, the nearest.
The library ships Python bindings that work with NumPy arrays and support L2, inner product, and cosine distances. Indexes can be built incrementally, updated by re-inserting labels, marked as deleted, and saved to or loaded from disk. Python indexes can also be pickled. Custom distance functions can be supplied from C++.
The C++ core has no dependencies beyond C++11. Recent versions add stream-based save and load and an optional no-exceptions API for builds compiled with -fno-exceptions.
Key features
- 01Header-only C++ implementation with no dependencies beyond C++11.
- 02Python bindings for NumPy arrays with L2, inner product, and cosine distances.
- 03Incremental insertion, updates of existing labels, and deletion marking.
- 04Index save and load to disk, plus pickle support in Python.
- 05Filtered search with a boolean function, and custom distances in C++.
Use cases
- Building a semantic search or recommendation backend over embedding vectors.
- Finding similar images or products by their feature vectors.
- Adding a fast nearest-neighbor index to a C++ application without pulling in a large dependency.
- Maintaining a vector index where items are frequently added, updated, or removed.
Things to know
- The README describes version 0.10.0rc2, a release candidate that should not be treated as a stable release.
- Filtered search in Python is limited by the GIL and runs slowly in multithreaded mode.
In collections
Topics
FAQ
- What is hnswlib?
- Header-only C++ library with Python bindings for fast approximate nearest neighbor search using the HNSW graph algorithm. Hnswlib is a header-only C++ implementation of Hierarchical Navigable Small World (HNSW) graphs for approximate nearest neighbor search. It indexes high-dimensional vectors so that finding the closest matches to a query vector is much faster than brute-force comparison, at the cost of returning results that are approximately, not exactly, the nearest.
- Is hnswlib free to use? What license does it have?
- hnswlib is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is hnswlib still maintained?
- Updated within 6 months. The last commit to hnswlib was on Sep 15, 2026.
- What can I use hnswlib for?
- Building a semantic search or recommendation backend over embedding vectors. Finding similar images or products by their feature vectors. Adding a fast nearest-neighbor index to a C++ application without pulling in a large dependency. Maintaining a vector index where items are frequently added, updated, or removed.
- Where can I get hnswlib?
- The source code and installation instructions are on GitHub: https://github.com/nmslib/hnswlib
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A C++ library for large-scale approximate nearest neighbor vector search, with index build, search, and distributed serving toolkits.
A Postgres extension in Rust that adds a DiskANN-based index and label filtering on top of pgvector for faster, cheaper vector search.
Open-source vector similarity search extension for Postgres, storing and querying embeddings alongside your relational data.
A single-file C++ library for approximate nearest-neighbor vector search and clustering, with bindings for Python, JavaScript, Rust, Java, Go, Swift and more.
A C++ library with Python bindings for efficient similarity search and clustering of dense vectors, with optional GPU acceleration.