SPANN: Highly-efficient Billion-scale Approximate Nearest Neighborhood Search

Qi Chen, Bing Zhao, Haidong Wang, Mingqin Li, Chuanjie Liu, Zengzhong Li, Mao Yang, Jingdong Wang

TL;DR

SPANN is a memory-disk hybrid search system that proves a refined inverted index approach can outperform complex graph-based methods for billion-scale vector search. By combining balanced clustering with smart data replication and dynamic pruning, it achieves 90% recall in just 1 millisecond—twice as fast as the current state-of-the-art, DiskANN, while using only 10% of the memory required by traditional in-memory solutions.

What Problem Does This Paper Address?

Approximate Nearest Neighbor Search (ANNS) is the engine behind modern recommendation systems and web search. As datasets grow to billions of vectors, keeping everything in RAM becomes prohibitively expensive.

Recent "hybrid" solutions try to solve this by keeping a compressed index in memory and the full-precision data on SSDs. However, most current leaders (like DiskANN) are graph-based. While effective, they often rely on lossy compression in memory and can require many random disk reads to traverse the graph, which severely hurts latency.

The authors of SPANN argue that the "old school" inverted index—storing centroids in memory and lists of vectors on disk—has been unfairly overlooked. It can actually be more efficient if three specific challenges are solved:

  1. Posting Length Limitation: Unbalanced clusters lead to unpredictable disk access times.
  2. The Boundary Issue: Vectors near the edge of a cluster might be missed if only the closest cluster is searched.
  3. Diverse Search Difficulty: Some queries are "easy" and need few cluster checks, while others are "hard."

Methods

To revitalize the inverted index, SPANN introduces three core techniques:

  • Hierarchical Balanced Clustering (HBC): Instead of standard k-means, which produces clusters of wildly different sizes, SPANN uses a hierarchical approach to ensure every "posting list" (cluster) on the disk is roughly the same size. This guarantees that a single disk read always returns a predictable amount of data.
Hierarchical Balanced Clustering
  • Closure Clustering & RNG Rule: To solve the "boundary issue" where a query's true neighbor is just across the border in another cluster, SPANN duplicates boundary vectors into multiple nearby clusters. To prevent the index from bloating, they use a Relative Neighborhood Graph (RNG) rule to only replicate vectors into clusters that provide a truly different "view" of the space, avoiding redundant storage.
  • Query-Aware Dynamic Pruning: Rather than searching a fixed number of clusters for every query, SPANN dynamically decides which clusters to load based on their distance from the query. If the second-closest cluster is much further away than the first, it might skip it entirely to save time.

Datasets

The authors evaluated SPANN on several massive, industry-standard benchmarks:

  • SIFT1B: 1 billion 128-dimensional byte vectors.
  • DEEP1B: 1 billion 96-dimensional float vectors from a deep image classification model.
  • SPACEV1B: 1 billion 100-dimensional byte vectors from a commercial search engine (Microsoft Bing).
  • SIFT1M: A smaller 1-million vector set used for detailed ablation studies.

Key Insights and Ideas

  • Simplicity Wins: While the field has moved toward complex graph structures, SPANN shows that a well-engineered inverted index can be more "disk-friendly." Because it loads entire clusters in one go, it maximizes the sequential read throughput of modern SSDs.
  • Balance is Better than Perfection: The move from pure k-means to balanced clustering is crucial. In a disk-based system, the "tail" (the largest cluster) dictates the worst-case latency. By forcing balance, SPANN tames that tail.
  • Redundancy is a Feature, Not a Bug: Strategic data replication (closure clustering) is the secret sauce for high recall. By storing a vector in multiple clusters instead of just one, the system becomes much more robust to the "boundary issue" without significantly increasing disk usage.
The Boundary Issue

Key Results

  • 2x Speedup: On billion-scale datasets, SPANN is twice as fast as DiskANN (the previous state-of-the-art) when reaching the same 90% recall level.
  • Ultra-Low Latency: It achieves 90% recall@1 and recall@10 in approximately 1 millisecond.
  • Memory Efficiency: It operates with only about 10% of the memory cost of traditional all-in-memory solutions.
  • Scalability: When extended to a distributed environment, SPANN's workload reduction techniques allowed it to save over 80% of computation and IO costs compared to traditional random partitioning.

Limitations and Future Work

  • Index Size: Because SPANN replicates boundary vectors, the total disk footprint is larger than a non-replicated index (roughly 20% larger in their tests).
  • Update Complexity: The paper primarily focuses on static datasets. Handling frequent real-time insertions and deletions in a balanced, replicated hierarchical structure remains a challenge for future research.
  • Hardware Specifics: The performance gains are heavily tied to SSD IOPS. While standard on modern servers, performance might vary on different storage tiers.

Summary updated

BibTeX
@inproceedings{chen2021spann,
  author = {Qi Chen and Bing Zhao and Haidong Wang and Mingqin Li and Chuanjie Liu and Zengzhong Li and Mao Yang and Jingdong Wang},
  title = {{SPANN: Highly-efficient Billion-scale Approximate Nearest Neighborhood Search}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=fls7pMuaeBS},
}
Figure