█

AI/TLDR

Buy me a coffee
Buy me a coffee

Voyager

Fast approximate nearest-neighbor search for embeddings, with matching Python and Java bindings

Vector DatabasesOpen source
Language
Python, Java
License
Apache-2.0
$pip install voyager
IN SHORT

What is Voyager?

Voyager is a library for fast approximate nearest-neighbor search over an in-memory collection of vectors. It is built on the HNSW algorithm (based on the hnswlib package) and adds extra features for convenience and speed. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python, Java and licensed Apache-2.0.

Overview

Voyager is a library for fast approximate nearest-neighbor search over an in-memory collection of vectors. It is built on the HNSW algorithm (based on the hnswlib package) and adds extra features for convenience and speed. Spotify uses it in production, where it is queried hundreds of millions of times per day.

It is an embedded, in-process library rather than a separate database server: you build an index inside your application, query it directly, and save or load it from disk. It ships bindings for both Python and Java (and Scala via the Java artifact) with feature parity and index compatibility, so an index built in one language can be loaded in the other.

It fits the embedded vector-database category and is aimed at developers who need similarity search over embeddings without running a standalone service. The project positions itself as a successor to Spotify's Annoy, offering higher recall.

What it does

  • HNSW-based approximate nearest-neighbor search over in-memory vectors
  • Python and Java bindings with feature parity and cross-language index compatibility
  • Indexes can be saved to disk and reloaded later, including across languages
  • Used in production at Spotify, serving hundreds of millions of queries per day
  • Higher recall than Annoy, the library it is intended to succeed
  • Prebuilt wheels for Linux, macOS, and Windows across Python 3.9-3.13

Getting started

Install the package for your language, then build an index, add vectors, and query for nearest neighbors.

Install for Python

Install Voyager from PyPI.

bashbash
pip install voyager

Install for Java

Add the Voyager artifact to your pom.xml. Check the Releases page for the latest version.

xmlxml
<dependency>
  <groupId>com.spotify</groupId>
  <artifactId>voyager</artifactId>
  <version>2.1.0</version>
</dependency>

Build an index and query it (Python)

Create an Index, add vectors, query for the closest items, and save the index to disk.

pythonpython
import numpy as np
from voyager import Index, Space

# Create an empty Index object that can store vectors:
index = Index(Space.Euclidean, num_dimensions=5)
id_a = index.add_item([1, 2, 3, 4, 5])
id_b = index.add_item([6, 7, 8, 9, 10])

print(id_a)  # => 0
print(id_b)  # => 1

# Find the two closest elements:
neighbors, distances = index.query([1, 2, 3, 4, 5], k=2)
print(neighbors)  # => [0, 1]
print(distances)  # => [0.0, 125.0]

# Save the index to disk to reload later (or in Java!)
index.save("output_file.voy")

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Add similarity search over text or image embeddings to an app without running a separate vector database service
  • Power recommendation and related-item features by querying nearest neighbors in an embedding space
  • Build an index in Python during offline processing, then load and serve it from a Java or Scala application
  • Migrate from Annoy to get higher recall while keeping an embedded, in-process workflow

How Voyager compares

Voyager alongside other open-source vector databases tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Supabase★ 116kManaged Postgres backend whose Vector toolkit (pgvector) stores, indexes, and queries embeddings next to transactional data.
Redis Cloud★ 77.8kFully-managed Redis with built-in vector search, offering low-latency similarity and hybrid queries over any embeddings.
Milvus★ 46.8kA distributed vector database for storing and searching billions of embeddings at scale, with multiple index types and Kubernetes-native deployment.
FAISS★ 42kA library from Meta for efficient similarity search and clustering of dense vectors, with both exact and approximate indexes.
Qdrant★ 35.8kA Rust-based vector search engine that stores embeddings with rich payload filtering for semantic search and recommendation systems.
Chroma★ 29.8kA developer-focused vector database designed for quickly building retrieval and RAG features with a simple Python and JavaScript API.
pgvector★ 23.9kA PostgreSQL extension that adds a vector data type and similarity search so you can store and query embeddings inside an existing Postgres database.
Voyager★ 1.6kFast approximate nearest-neighbor search for embeddings, with matching Python and Java bindings