Expand description
Lightweight HNSW (Hierarchical Navigable Small World) index for approximate nearest neighbors.
Scientific basis: Malkov & Yashunin, “Efficient and Robust Approximate Nearest Neighbor using Hierarchical Navigable Small World Graphs” (IEEE TPAMI 2018).
This is a minimal implementation optimized for lean-ctx’s embedding dimensions (384-d). For indices under BRUTE_FORCE_THRESHOLD chunks, falls back to exact linear scan with binary-heap top-k selection (O(n log k) instead of O(n log n)).
Structs§
- AnnIndex
- Approximate nearest neighbor index using HNSW for large datasets, with brute-force fallback for small ones.
Functions§
- brute_
force_ topk - O(n log k) brute-force top-k selection using a min-heap.