Expand description
HNSW (Hierarchical Navigable Small World) Index
Production-quality implementation of the HNSW algorithm for approximate nearest neighbor search in high-dimensional vector spaces.
§Algorithm Overview
HNSW builds a multi-layer graph structure where:
- Layer 0 contains all vectors
- Higher layers contain progressively fewer vectors (exponentially decaying)
- Each layer is a navigable small world graph with bounded degree
- Search proceeds from top layer down, greedy navigating to nearest neighbors
§Performance Characteristics
- Search: O(log n) approximate nearest neighbor queries
- Insert: O(log n) amortized insertion time
- Space: O(n * M) where M is max connections per layer
- Accuracy: Configurable via ef_construction and ef_search parameters
§References
- Malkov, Y. A., & Yashunin, D. A. (2018). “Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs” IEEE Transactions on Pattern Analysis and Machine Intelligence.
Structs§
- Hnsw
Config - HNSW index configuration
- Hnsw
Index - HNSW index for approximate nearest neighbor search
- Hnsw
Search Result - Search result with distance and metadata
- Hnsw
Stats - Statistics about the HNSW index structure
Enums§
- Distance
Metric - Distance metrics supported by HNSW