17/36
Part 2 of 5 · Stages and retrievalLearn and do

Airbnb picked IVF for its updates and filters

Now run the numbers for this catalog. Assume 64 float32 dimensions per listing, 4 bytes each. 7,000,000 × 64 × 4 bytes is 1.8 GB.

That fits in memory on any serving machine. So compression isn't the question here. The choice turns on updates and filters, and that's how Airbnb decided.

idlocationfreesleepscluster
L42ParisMar 3 to Mar 7417

With IVF, retrieval is one more filter: the cluster is among the top few for the query.

Airbnb compared IVF and HNSW. HNSW scored slightly better on recall, its main evaluation metric. Airbnb still found that IVF offered the best trade-off between speed and performance (1 source). It gave two reasons:

  • Prices and availability change all the time, so the index takes a high volume of updates every second. That made the memory of the HNSW index grow too large.
  • Most searches carry filters, especially on location, and HNSW retrieval alongside filters had poor latency.

With IVF, the clusters are built ahead of time, and each listing's cluster becomes one more field in the existing search index. At serving time, retrieval is a normal filter: listings from the top clusters.

HNSWIVFIVF with PQ
Memory per vectorFull vector plus graph linksFull vector plus an idA few bytes of codes plus an id
Speed and recall dialSearch depthClusters probedClusters probed, plus rescoring
Updates and deletesHard; deletes break the graphReassign a cluster idReassign and re-encode
Works with index filtersPoorly at AirbnbAs a filter fieldAs a filter field
Pick it whenStatic, memory to spareFrequent updates, heavy filteringToo big for memory uncompressed

IVF is only as good as its clusters are even. If one cluster holds a big share of the homes, picking it narrows almost nothing. Airbnb tried dot product and Euclidean distance as the measure of closeness. Both did about as well as a model, but Euclidean distance gave much more balanced clusters.

In the editor, write vectors_gb(n, dims), the memory for the whole catalog's vectors, and scan_share(assign, probed), the share of listings a query scans. In the example, 3 of 4 listings sit in cluster 0, so probing it scans 75% of them.