Database / Milvus Vector database Interview questions
What is HNSW, and why is it commonly used in Milvus?
HNSW (Hierarchical Navigable Small World) is a graph-based approximate nearest neighbor algorithm that organizes vectors into multiple layers of a navigable graph, with sparser, "long-range" connections at higher layers and denser, "short-range" connections at lower layers. A search starts at the top layer and greedily navigates toward the query vector, descending through layers to refine the result, similar in spirit to a skip list.
index_params.add_index( field_name="embedding", index_type="HNSW", metric_type="L2", params={"M": 16, "efConstruction": 200} )
HNSW is a common default in Milvus because it consistently delivers a strong balance of high recall and low query latency across a wide range of dataset sizes and dimensionalities, without needing the dataset-specific tuning some other index types benefit from. Its main cost is memory: the graph structure itself takes meaningful RAM, which is why very large collections sometimes reach for a disk-based option like DiskANN instead.
More Related questions...