Search

Search IconIcon to open search

HNSW

Last updatedUpdated: by Jakub Žovák · 1 min read

Properties
created 09.08.2025, 16:54
modified 28.11.2025, 17:42
published Empty
topics HNSW, ANN Indexes, Graph-based Indexes, Navigable Small World
authors Empty
ai-assisted No

Hierarchical NSW incrementally builds a multi-layer structure consisting from hierarchical set of proximity graphs (layers) for nested subsets of the stored elements. The maximum layer in which an element is present is selected randomly with an exponentially decaying probability distribution. This allows producing graphs similar to the previously studied Navigable Small World (NSW) structures while additionally having the links separated by their characteristic distance scales. Starting search from the upper layer together with utilizing the scale separation boosts the performance compared to NSW and allows a logarithmic complexity scaling.

# Technical Aspects

  • Complexity
    • ​Search - (poly)logarithmic
    • ​Build - $n \times log(n)$
  • Parameters
    • M – number of neighbors added on insertion​
    • efConstruction​
    • efSearch​
    • L – number of layers​
    • m_L (recommended 1/ln(M)) - level multiplier that normalizes prob. func

# Modifications

# Additional Topics

  • Some strange mention of caching that I do not understand (Maybe just upsell?)
    • HNSW can be used for large indexes when combined with an effective caching strategy. Aerospike uses a distributed cache with query steering approach which allows you to have many indexes, including large ones and load them into memory as your application needs them. ( Source)