AI Term 1 min read

HNSW (Hierarchical Navigable Small World)

What it is: A graph-based algorithm that organizes vectors in multiple layers, like a highway system for finding similar vectors.

How it works:

  • Creates a multi-level graph where each vector connects to its nearest neighbors
  • Top layers have fewer nodes but longer connections (like highways)
  • Bottom layers have more nodes with local connections (like city streets)
  • Search starts at the top layer and navigates down to find the closest match

Why it matters: Very fast and accurate for similarity search, especially with millions of vectors. Used by many modern vector databases.

Real-world analogy: Like using Google Maps - you start with major highways to get to the right area, then use local streets to find the exact address.