← Back to modules

Vector Databases & ANN Search — Advanced

HNSW/IVF/PQ internals, OPQ and ScaNN, scalar/binary quantization + rescoring, filtered ANN, disk-based indexes, MIPS, and distributed sharded search.

Hard50 questions

Sample questions

1

HNSW search keeps a candidate list of size 'ef' per layer. What does that beam do?

  • It caps the candidates the greedy search tracks
  • It stores the metadata payloads for filtering
  • It sets the number of graph layers built
  • It encrypts the visited nodes

Why

ef caps the size of the dynamic candidate set the search maintains while hopping the graph; a larger ef explores more neighbors before stopping, raising recall at higher latency. It isn't payload storage, the layer count, or encryption.

2

How does HNSW decide which layer a newly inserted vector reaches?

  • A random level, exponentially decaying by layer
  • By the vector's L2 norm
  • By its insertion timestamp
  • By its cosine similarity to the origin

Why

Each node's maximum layer is sampled so that higher layers get exponentially fewer nodes, creating the sparse long-range top and dense bottom that make search efficient. It's not based on norm, timestamp, or similarity to the origin.

3

Why are deletions notoriously awkward in an HNSW graph index?

  • HNSW cannot store more than a million vectors
  • Removing a node breaks connectivity; use tombstones
  • Deletion doubles the index memory
  • Deleted vectors still appear in every result

Why

A node may be an important hub linking regions, so truly removing it risks disconnecting the graph; systems typically mark it deleted (tombstone) and periodically rebuild/compact. HNSW scales past millions, deletion doesn't double memory, and tombstoned nodes are filtered out.

4

In Product Quantization, a vector is split into m sub-vectors, each quantized with a codebook of 2^b centroids. How many bytes encode one vector (b=8)?

  • 2^b bytes regardless of m
  • One byte for the whole vector
  • m bytes, one code per sub-vector
  • The original dimension in bytes

Why

With b=8, each sub-vector's nearest centroid id is one byte, so m sub-vectors take m bytes total — a large compression versus the raw float vector. It's not 2^b bytes, a single byte, or the original size.

5

PQ search typically uses 'asymmetric distance computation' (ADC). What is asymmetric about it?

  • The query stays full-precision while database vectors are quantized
  • The query is quantized but database vectors are not
  • Only half the dimensions are compared
  • The distance is computed twice and averaged

Why

ADC keeps the query in full precision and precomputes its distance to each sub-codebook centroid, then looks up distances to the quantized database codes — more accurate than quantizing the query too. It's not query-only quantization, half-dimension, or double computation.

Free account

Take the full module

These are the first few of 50 questions. A free account opens the rest as a scored drill.

  • Every question in this module
  • Instant feedback and supporting reading
  • Your score and progress, saved

Free · your email is used for progress only.