QA
Intermediate LevelAI, LLMs, Embeddings & MCP

How does the HNSW (Hierarchical Navigable Small World) graph index execute O(log N) vector search?

❓ Interview Prompt: Explain HNSW proximity graph layers, skip-lists, M parameter, efConstruction, and sub-linear ANN search.

Hierarchical Navigable Small World (HNSW) is the industry-standard graph-based index for Approximate Nearest Neighbor (ANN) vector search.

Multi-Layer Graph Architecture:

•
Inspired by probabilistic Skip-Lists.
•
Top Layers: Contain long-range "expressway" links between distant vectors for fast coarse traversal.
•
Bottom Layer (Layer 0): Contains dense local links between close vectors for fine-grained nearest neighbor lookup.

Key Index Tuning Parameters:

•
`M`: Maximum number of bidirectional connection links per node (e.g. M = 16).
•
`efConstruction`: Size of dynamic candidate list during graph building (higher = better recall, slower build).

Code Implementation Example

typescript
// Qdrant vector index config with HNSW parameters
const hnswConfig = {
  hnsw_config: {
    m: 16,               // Max links per node layer
    ef_construct: 100,   // Construction search list size
    full_scan_threshold: 10000
  }
};
💡Configuring HNSW vector graph index parameters.
🎯 Interview Key Takeaway

HNSW builds multi-layer proximity graphs with skip-list connections, achieving sub-linear O(log N) vector search.

#HNSW#ANN#Graph Index#Vector DB#Intermediate
Back to all AI, LLMs, Embeddings & MCP Questions→

More AI, LLMs, Embeddings & MCP Interview Questions

Beginner LevelAI, LLMs, Embeddings & MCP

What are Vector Embeddings and Cosine Similarity in AI Semantic Search?

Beginner LevelAI, LLMs, Embeddings & MCP

What is the Model Context Protocol (MCP) and how does it connect LLMs to external tools?

Beginner LevelAI, LLMs, Embeddings & MCP

What is Retrieval-Augmented Generation (RAG) and how does it prevent LLM hallucinations?