Database / Qdrant Vector DB Interview questions
How does the HNSW graph work internally in Qdrant?
Qdrant's HNSW implementation builds and searches a layered graph where each node is a vector, and edges connect a vector to a set of its approximate nearest neighbors — the specific structure and traversal algorithm are what let search converge quickly without ever comparing the query against every stored vector.
Each vector is assigned to a random maximum layer when inserted (following a probability distribution that keeps higher layers sparse), and it's connected to a configured number of nearest neighbors at each layer it belongs to; search starts at a fixed entry point in the sparsest top layer and greedily descends, using each layer's search result as the starting point for a more focused search in the layer below.
Once the bottom layer is reached, Qdrant performs a wider, more exhaustive local search among the bottom layer's dense connections to refine the candidate set, since the upper layers exist mainly to get the search close to the right neighborhood quickly, while the bottom layer's density is what ensures the final result set has good accuracy relative to a true nearest-neighbor search.
More Related questions...