Skip to main content

Module hnsw

Module hnsw 

Source
Expand description

HNSW (Hierarchical Navigable Small World) Index

§Table of Contents

  • HnswIndex: Main HNSW graph structure for ANN search
  • HnswNode: Node in the HNSW graph with multi-layer connections
  • HnswConfig: Configuration parameters (M, ef_construction, ef_search)
  • Search Algorithm: Greedy beam search with layer traversal

§Algorithm Overview

HNSW builds a multi-layer graph where:

  • Higher layers have fewer nodes (exponential decay)
  • Each node connects to M neighbors per layer
  • Search starts from top layer, greedily descends
  • Bottom layer search uses beam width ef_search for recall

Structs§

HnswIndex
HNSW Index for approximate nearest neighbor search
HnswNode
HNSW node representing a vector in the graph
HnswStats
HNSW index statistics