liveBook · Manning

HNSW

Also called Hierarchical Navigable Small World

HNSW is a graph-based approximate nearest-neighbor indexing and search method that organizes data points in a hierarchy of navigable proximity graphs.

How 11 Manning books explain it

Just Use Postgres!

An HNSW index is a graph-based approximate nearest-neighbor index using a hierarchical navigable small-world graph.

How it is used
Optimizes vector similarity search for generative-AI applications such as movie recommendations.
How deep it goes
Explains graph layers, traversal, index creation, execution plans, recall, and ef_search, without deeper implementation theory.
Examples
Demonstrates movie-embedding searches, PostgreSQL index definitions, execution plans, returned movie rows, and ef_search tuning.
What you can do after
Operate/configure HNSW in PostgreSQL, inspect its query plan, and adjust search accuracy with ef_search.

Read how Just Use Postgres! explains HNSW →

Generative AI in Action

HNSW is a graph-based approximate nearest-neighbor indexing algorithm that organizes vectors in navigable hierarchical layers.

How it is used
Speeds similarity search over embeddings for retrieval and matching workflows.
How deep it goes
Defines graph organization, contrasts HNSW with brute-force FLAT, and specifies metrics and schema settings without deriving graph internals.
Examples
Uses a Redis blog-post index with FLOAT32 embeddings, 1536 dimensions, and COSINE distance.
What you can do after
Operate/configure Redis vector search by selecting HNSW and setting vector type, dimensions, and distance metric.

Read how Generative AI in Action explains HNSW →

Retrieval Augmented Generation, The Foundational Ideas

HNSW is a graph-based approximate nearest-neighbor indexing method that navigates layered connections between vectors.

How it is used
Deploys HNSW for ultra-fast approximate vector search when real-time retrieval matters more than maximum recall.
How deep it goes
Explains layered graph navigation and trade-offs, but stops short of construction algorithms or query-parameter tuning.
Examples
Uses FAISS configuration code and compares HNSW with flat and IVF indexing strategies.
What you can do after
Apply it via FAISS by constructing an HNSW index and adding embedding vectors.

Read how Retrieval Augmented Generation, The Foundational Ideas explains HNSW →

AI-Powered Search

HNSW is a graph-based approximate nearest neighbor indexing and search algorithm that builds a multilayer hierarchy of proximity graphs.

How it is used
Supports dense-vector retrieval and semantic autocomplete when full-corpus similarity comparison is too expensive.
How deep it goes
Explains multilayer graph construction and gives an implementation workflow, while deferring detailed algorithm internals.
Examples
Demonstrates concept autocomplete for “bag,” “mountain hike,” and “dehyd” using nearest-neighbor result lists.
What you can do after
Apply HNSW via NMSLIB by indexing normalized embeddings and querying filtered nearest neighbors.

Read how AI-Powered Search explains HNSW →

Natural Language Processing in Action, Second Edition

Hierarchical Navigable Small World is a graph-based approximate nearest-neighbor algorithm that organizes navigable proximity graphs into progressively sparser layers.

How it is used
Balances semantic-search speed, memory use, and recall when choosing a vector database index.
How deep it goes
Explains neighbor graphs, sparse layers, and traversal intuition, but defers detailed index tuning.
Examples
Uses social-network degrees of separation, international travel, and a Haystack QA application backed by Faiss.
What you can do after
Operate HNSW through Faiss and Haystack while evaluating speed, RAM requirements, and recall for semantic retrieval.

Read how Natural Language Processing in Action, Second Edition explains HNSW →

Enterprise RAG

HNSW is an approximate nearest-neighbor search algorithm that uses a navigable multilayer graph to find similar vectors efficiently.

How it is used
Guides vector-search configuration choices in Azure AI Search according to dataset size, speed requirements, and memory overhead.
How deep it goes
Explains HNSW’s performance and memory trade-off but stops short of its graph construction or search procedure.
Examples
Uses a small Azure AI Search dataset and a correctly configured vector-index figure to illustrate method selection.
What you can do after
Operate/configure Azure AI Search by choosing HNSW or Exhaustive KNN and accounting for index-memory costs.

Read how Enterprise RAG explains HNSW →

MongoDB 8.0 in Action, Third Edition

HNSW is a graph-based approximate nearest-neighbor search algorithm that organizes data points into multiple navigable layers.

How it is used
Accelerates approximate similarity search for large-scale, real-time applications.
How deep it goes
Explains layered graph construction and greedy descent, but does not specify index-tuning parameters or implementation code.
Examples
Uses layered vector graphs and Atlas $vectorSearch queries with exact set to false as concrete examples.
What you can do after
Apply HNSW through Atlas Vector Search indexes and $vectorSearch for fast approximate retrieval of semantically similar documents.

Read how MongoDB 8.0 in Action, Third Edition explains HNSW →

Outlier Detection in Python

HNSW is a graph-based approximate nearest-neighbor data structure that organizes navigable connections between data points.

How it is used
Accelerates approximate nearest-neighbor searches in large-scale numeric outlier-detection workflows.
How deep it goes
Demonstrates index construction and querying, but stops short of explaining internal navigation mechanics or accuracy trade-offs.
Examples
Uses 1,000 random ten-feature rows, a NumPy Euclidean distance function, sequential insertion, and a ten-neighbor query.
What you can do after
Apply it via datasketch to build an index and query approximate nearest neighbors for numeric vectors.

Read how Outlier Detection in Python explains HNSW →

Designing AI Systems

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

How it is used
Supports approximate vector search in a PostgreSQL data service when retrieval quality outweighs memory and construction costs.
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.

Read how Designing AI Systems explains HNSW →

Building Reliable AI Systems

Hierarchical Navigable Small World is an approximate nearest-neighbor search algorithm that organizes vectors in a multilayer graph.

How it is used
Accelerates approximate nearest-neighbor search across vector collections without scanning every vector.
How deep it goes
Explains graph navigation, complexity, tuning parameters, and trade-offs, then demonstrates FAISS configuration without deriving the algorithm.
Examples
Shows a FAISS index for 10,000 128-dimensional vectors and policy retrieval through Pinecone.
What you can do after
Apply HNSW through FAISS to index vectors and retrieve nearest neighbors, then benchmark against alternatives for the workload.

Read how Building Reliable AI Systems explains HNSW →

LLM Customization and Fine-Tuning

A graph-based approximate nearest-neighbor indexing method commonly used for fast vector search.

How it is used
Speeds up top-k similarity search in production vector indexes.
How deep it goes
Positions HNSW as a practical ANN choice but stops short of graph construction or parameter tuning.
Examples
Names Pinecone, Weaviate, Qdrant, and pgvector as systems using HNSW.
What you can do after
Evaluate HNSW as a fast ANN option against exhaustive search and IVF.

Read how LLM Customization and Fine-Tuning explains HNSW →

What to know first

Related concepts

Questions about HNSW

What is HNSW?

HNSW is a graph-based approximate nearest-neighbor indexing and search method that organizes data points in a hierarchy of navigable proximity graphs.

Which Manning books explain HNSW?

Just Use Postgres!, Generative AI in Action, Retrieval Augmented Generation, The Foundational Ideas, AI-Powered Search, Natural Language Processing in Action, Second Edition, Enterprise RAG, MongoDB 8.0 in Action, Third Edition, Outlier Detection in Python and 3 more.

What should I know before learning HNSW?

Manning books that teach HNSW usually introduce embedding, similarity search, recall and distance first.

What is the difference between HNSW and exhaustive knn?

HNSW is a graph-based approximate nearest-neighbor indexing and search method that organizes data points in a hierarchy of navigable proximity graphs. Exhaustive KNN is a nearest-neighbor search method that compares a query vector with every candidate vector to identify the closest matches.

What is HNSW also called?

HNSW is also called Hierarchical Navigable Small World.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.