hnswlib
activeby nmslib contributors · since 2017 · also known as nmslib hnswlib
Header-only C++ HNSW library with Python bindings, from the authors of the HNSW algorithm.
Overview
hnswlib is the reference implementation of Hierarchical Navigable Small World graphs, maintained under the nmslib organisation with contributions from HNSW co-author Yury Malkov. It is a small header-only C++ library with Python bindings that supports incremental inserts, deletions via marking, filtering callbacks and saving/loading indexes, using L2, inner product or cosine distance. Many early vector databases and RAG tools embedded it directly, and it remains a common baseline. It is a library with no metadata store or server, and releases are infrequent (0.9.0 in March 2026, 0.10 in release candidates).
Strengths & trade-offs
Strengths
- +Reference HNSW implementation with excellent recall/speed trade-offs
- +Header-only and dependency-free
- +Incremental inserts and soft deletes
- +Simple Python API used by many tools
Trade-offs
- −RAM-only index, no quantization
- −No metadata storage or server
- −Slow release cadence
- −Single distance family per index
Great for
- +Embedding HNSW in applications
- +Baseline for ANN benchmarks
- +Small in-process semantic search
Think twice for
- −Datasets larger than RAM
- −Teams needing a database with filters and CRUD
Capabilities
Native or official first-party support · 2 of 25 tracked
Scale & consistency
- Comfortable data size
- Medium · ≤ 10 TB
- Horizontal scaling
- Manual
- Multi-region
- No
- Transactions
- None
- Consistency
- Strong
- Schema
- Schemaless
- Architecture
- Embedded, In memory
- Query languages
- Library API
Whole index lives in RAM in one process; tens to hundreds of millions of vectors on a large machine.
Deployment
Ecosystem
Alternatives to hnswlib
Meta's C++/Python library for fast dense-vector similarity search and clustering, CPU and GPU.
hnswlib vs faiss →Single-header C++ HNSW library with SIMD distance kernels and bindings for a dozen languages.
hnswlib vs usearch →Spotify's memory-mapped random-projection-tree ANN library; stable but no longer evolving.
hnswlib vs annoy →Google Research's ANN library using anisotropic quantization; the tech behind Vertex AI and AlloyDB vectors.
hnswlib vs scann →Rust vector search engine with rich payload filtering, quantization and a managed cloud.
hnswlib vs qdrant →Kubernetes-native distributed vector search engine built on Yahoo Japan's NGT.
hnswlib vs vald →hnswlib FAQ
What is hnswlib?
hnswlib is a vector database by nmslib contributors, first released in 2017. hnswlib is the reference implementation of Hierarchical Navigable Small World graphs, maintained under the nmslib organisation with contributions from HNSW co-author Yury Malkov. It is a small header-only C++ library with Python bindings that supports incremental inserts, deletions via marking, filtering callbacks and saving/loading indexes, using L2, inner product or cosine distance. Many early vector databases and RAG tools embedded it directly, and it remains a common baseline. It is a library with no metadata store or server, and releases are infrequent (0.9.0 in March 2026, 0.10 in release candidates).
Is hnswlib open source?
Yes. hnswlib is open source. License: Apache License 2.0.
Does hnswlib support ACID transactions?
No. hnswlib does not provide ACID transactions; its consistency model is strong.
Does hnswlib scale horizontally?
hnswlib has no built-in sharding; scaling out means partitioning data in your application. It is comfortable at medium scale (≤ 10 TB).
How can I run hnswlib?
You can self-host it and embed it in your application.
What is hnswlib best for?
hnswlib is a strong fit for embedding HNSW in applications, baseline for ANN benchmarks and small in-process semantic search. Think twice for datasets larger than RAM.
What are the best alternatives to hnswlib?
Common alternatives to hnswlib include Faiss, USearch, Annoy, ScaNN and Qdrant. The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.
How popular is hnswlib?
hnswlib ranks #211 of 844 databases on the WhichDB Score (15.5/100), and #12 among vector databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.