hnswlib-rs
Pure-Rust implementation of HNSW algorithm for approximate nearest neighbor search. Decouples graph from vector storage for flexible deployment. Supports dense floating point and quantized int8 vectors. This is an OSS library.
About this tool
Overview
hnswlib-rs is a pure-Rust implementation of the HNSW (Hierarchical Navigable Small World) algorithm inspired by the original C++ hnswlib. Designed with a decoupled architecture separating graph structure from vector storage.
Key Features
- Decoupled Architecture: Graph separated from vector storage for flexibility
- External Key Support: Map your external keys to internal NodeId
- Multiple Precision: f32, f16, bf16, and per-vector quantized int8
- Pure Rust: Memory-safe implementation without C dependencies
- Flexible Storage: Provide vectors on demand via VectorStore interface
Architecture
The library intentionally decouples components:
Hnsw<K, M>: Owns the graph + mapping from external key K to internal NodeIdVectorStore: Keyed by NodeId, supplies vectors on demand- This design allows flexible storage backends and memory management
Supported Data Types
- f32: Standard 32-bit floating point
- f16: 16-bit floating point for memory efficiency
- bf16: Brain floating point for ML applications
- int8: Quantized 8-bit integers for maximum compression
Use Cases
- Approximate nearest neighbor search
- Embedding similarity search
- Large-scale vector retrieval
- Custom storage backend integration
- Applications requiring memory-efficient vector search
Installation
Available on crates.io:
[dependencies]
hnswlib-rs = "*"
Comparison to Other Implementations
vs. C++ hnswlib
- Memory safety guarantees from Rust
- No C dependencies or FFI overhead
- Modern Rust ecosystem integration
vs. Other Rust HNSW
- Unique decoupled architecture
- Flexible vector storage
- Support for multiple precision formats
Repository
GitHub: jean-pierreBoth/hnswlib-rs Crates.io: https://crates.io/crates/hnswlib-rs
Technical Details
Implements the algorithm from: "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs" by Yu. A. Malkov and D. A. Yashunin
Pricing
Free and open-source under MIT or Apache 2.0 license. No licensing costs.
Loading more......
Information
Categories
Tags
Similar Products
6 result(s)Header-only C++/Python library for fast approximate nearest neighbor search implementing the HNSW algorithm. Used by Spotify and others, offers 10x speed increase over Annoy. This is an OSS library.
Hora is an efficient, open-source library for approximate nearest neighbor search, written in Rust. It offers high-performance vector search capabilities for AI and machine learning applications.
PostgreSQL extension for scalable, low-latency vector search written in Rust. Features 20x faster HNSW than pgvector, with support for FP16, INT8, and binary vectors. This is an OSS extension.
HelixDB is a powerful, open-source graph-vector database built in Rust, designed for intelligent data storage for Retrieval-Augmented Generation (RAG) and AI applications. It combines graph database features with vector search, making it directly relevant to AI and machine learning workflows that require vector data management.
GPU-accelerated vector search and clustering library from NVIDIA RAPIDS. Provides 8-12x faster index building and queries with multiple language support (C, C++, Python, Rust). This is an OSS library.
Python implementation of Nearest Neighbor Descent for k-neighbor-graph construction and ANN search. Targets 80%-100% accuracy with fast performance and supports wide variety of distance metrics. This is an OSS library.