liveBook · Manning

HNSW

As explained in Designing AI Systems

HNSW is a graph-based approximate nearest-neighbor index that organizes vectors into layered networks of nearby connections.

HNSW is a graph-based approximate nearest-neighbor index for vector search. It connects each vector to nearby neighbors in layered networks: search begins with coarse, long-range links at the top and descends toward increasingly similar vectors. The approach can be built on an empty table and generally produces higher-quality results than IVFFlat, at the cost of more memory and longer construction time. section 5.4.3

Choose HNSW when search quality and flexible index creation matter more than construction cost or memory usage:

  • Prefer HNSW when the vector table may initially be empty; IVFFlat needs representative ingested data to form effective clusters. section 5.4.3
  • Accept higher memory consumption and slower index construction in exchange for generally higher-quality approximate results. section 5.4.3
  • Use the index within pgvector so PostgreSQL performs vector comparison, metadata filtering, ranking, and top-result selection in one query. section 5.4.3

How Designing AI Systems covers it

How deep it goes
Explains layered traversal and tradeoffs, but does not specify HNSW configuration parameters or implementation code.
Examples
Uses layered neighbor graphs, empty-table construction, and IVFFlat comparison as concrete illustrations.
What you can do after
Evaluate HNSW against IVFFlat when selecting a pgvector index for production vector retrieval.
How it connects
Connects HNSW to approximate nearest-neighbor search, vector embeddings, pgvector, PostgreSQL, and IVFFlat.

Also explained in

Compare how 11 books explain HNSW →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.