A New Default for Vector Search at Spotify
For roughly a decade, Spotify's recommendation and personalization systems have leaned on approximate nearest-neighbor (ANN) search to surface similar tracks, artists, and albums without running expensive machine learning models in real time. In 2013, the company open-sourced Annoy, a library that has powered features from Discover Weekly to the Home screen. But the state of the art has moved substantially since then, and Spotify has been running a successor in production for nearly a year. Today, that library is public: Voyager.
Voyager is a new ANN search library based on hnswlib, built to replace Annoy as Spotify's recommended tool for production nearest-neighbor lookup. It pairs the speed and accuracy gains of Hierarchical Navigable Small World (HNSW) graphs with what Spotify describes as battle-tested, well-documented bindings for both Java and Python.
Why Not Just Improve Annoy?
The immediate question is why Spotify didn't simply upgrade Annoy. The answer lies in how much the ecosystem has changed. In ANN benchmarks, Annoy now sits in the middle of the pack. Competing systems can return results twice as accurate in the same time, or match Annoy's quality in one-tenth the time. Meanwhile, vector search has become a standard feature in databases: offerings like Weaviate, Pinecone, Vespa, and ChromaDB all include it, and PostgreSQL has gained the pgvector extension.
But Spotify's engineering needs go beyond raw speed and accuracy. The company identifies several other constraints:
- Flexibility: Different use cases demand different trade-offs between performance, throughput, latency, and cost. Engineers need to customize nearly every part of the search algorithm to find the right balance.
- Statelessness: Many Spotify systems run ANN indexes in memory. This enables stateless Kubernetes deployments and avoids the operational overhead of a stateful database cluster.
- Language support: Production backend systems at Spotify favor JVM languages like Java and Scala for performance, while machine learning work typically happens in Python. Many newer ANN libraries either lack good non-Python support or require running a separate database process.
- Cost: The fastest, most accurate algorithms often need large amounts of memory. For many workloads, it makes sense to trade some accuracy for much lower cost.
Spotify had been experimenting with the open-source hnswlib since 2018, which offered a tenfold speed improvement over Annoy. But scaling it revealed a long list of desired changes — to the on-disk format, the API, and the underlying architecture. Those changes would break backward compatibility, and hnswlib's roughly 700,000 monthly downloads made that a non-starter. Building a new package from the ground up was the cleaner path.
What Voyager Brings
Voyager's design philosophy is to be a stable, dependency-light library rather than a research vehicle. The feature set reflects that:
- More than 10 times the speed of Annoy at equal recall, or up to 50 percent more accuracy at equal speed
- Up to 4 times less memory usage than Annoy, thanks to E4M3 8-bit floating point support
- Fully multithreaded index creation and querying
- Identical Python and Java bindings, both fully supported
- Fault-tolerant index files with corruption detection
- Google Cloud Platform–compatible stream-based I/O, so indices can be streamed directly from cloud storage
- Built-in string identifiers, enabling queries by URI
- 16 times less memory usage than hnswlib during index creation
- Dependency-free installs — Python requires only NumPy (any version), and Java has zero dependencies
- Support for macOS, Windows, and Linux on both x86 and arm64
From Internal Tool to Public Library
Voyager is not a promise of future work. Spotify has been serving production traffic with it internally since 2022, across multiple teams. The library is now available on GitHub, and the quickest way to start is pip install voyager in Python. Full documentation is at spotify.github.io/voyager, and the team discusses the project in more depth in episode 23 of NerdOut@Spotify.



