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.
| id | location | free | sleeps | cluster |
|---|---|---|---|---|
| L42 | Paris | Mar 3 to Mar 7 | 4 | 17 |
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.
| HNSW | IVF | IVF with PQ | |
|---|---|---|---|
| Memory per vector | Full vector plus graph links | Full vector plus an id | A few bytes of codes plus an id |
| Speed and recall dial | Search depth | Clusters probed | Clusters probed, plus rescoring |
| Updates and deletes | Hard; deletes break the graph | Reassign a cluster id | Reassign and re-encode |
| Works with index filters | Poorly at Airbnb | As a filter field | As a filter field |
| Pick it when | Static, memory to spare | Frequent updates, heavy filtering | Too 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.