Understand HNSW algorithm, ANN vs exact search, embedding dimensions, scalar quantization, and when to use each approach.
0 / 5 completed
1 / 5
What does the HNSW algorithm stand for and what is its core idea?
HNSW: inspired by skip lists and small-world networks. The top layer has few nodes connected with long edges (fast navigation), the bottom layer has all nodes with short edges (precise search). Entry starts at the top, greedily descends to the nearest node at each layer, achieving logarithmic search complexity with high recall.
2 / 5
What is ANN search and why is it used instead of exact nearest-neighbour search in vector databases?
ANN search: for millions of 1536-dimensional vectors, exact search is too slow for real-time retrieval. ANN algorithms build indices that skip unlikely candidates, accepting a small percentage of missed true nearest neighbours (controlled by an ef_search parameter in HNSW) in exchange for orders-of-magnitude faster queries.
3 / 5
What is the significance of embedding dimensions when choosing a vector database configuration?
Embedding dimensions: a collection of 10M vectors at 1536 dimensions requires ~60GB of float32 memory just for raw vectors, before index overhead. Choosing a model with smaller dimensions (e.g. 384-d) reduces cost dramatically. Matryoshka embeddings allow truncating to smaller dimensions with graceful quality degradation.
4 / 5
What is scalar quantization in the context of vector databases?
Scalar quantization: float32 vectors use 4 bytes per dimension. Int8 quantization maps each dimension to a byte, reducing size by 4×. Binary quantization maps to a single bit, giving 32× compression. Qdrant and Weaviate support these modes — they keep quantized vectors in RAM for fast approximate search, fetching full-precision vectors only for the final reranking step.
5 / 5
When would you choose exact kNN over an ANN index in a vector database?
Exact vs approximate: ANN indices have build costs and approximate results. For a catalogue of 5,000 products, flat (brute-force) kNN is fast enough and guarantees perfect recall. ANN pays off at hundreds of thousands of vectors where exhaustive scan becomes too slow for interactive latency targets.