meilisearch/arroy

An Approximate Nearest Neighbors library in Rust, based on random projections and LMDB and optimized for memory usage :boom:

What it solves

Arroy provides a way to perform approximate nearest neighbor searches—finding vectors similar to a target vector—while keeping memory usage low and allowing multiple processes to share and modify the same data. Unlike many other libraries that are strictly memory-bound, Arroy uses LMDB (a memory-mapped key-value store) to handle large datasets that might not fit entirely in RAM.

How it works

Arroy builds a forest of trees using random projections. It selects random hyperplanes to divide vector space into subspaces, creating a structure that allows for efficient searching. Because it is built on top of LMDB, the index is stored on disk, enabling multiple threads or processes to perform lookups simultaneously, even while the index is being modified. Users can tune performance and accuracy using two parameters: n_trees (to control index size and build time) and search_k (to control query speed and precision).

Who it’s for

This library is designed for Rust developers who need to perform high-dimensional vector searches—such as finding similar documents—in environments where memory efficiency is critical and data needs to be shared across multiple processes.

Highlights

  • Supports multiple distance metrics: Euclidean, Manhattan, Cosine, and Dot Product.
  • Enables memory sharing between processes via LMDB.
  • Allows for incremental updates to the tree without requiring a full rebuild.
  • Highly memory-efficient, making it suitable for large datasets.
  • Includes features for filtering during queries and atomic modifications of indexes.

Related

  • Project
  • Project
  • Project
  • Project
  • Project