arroy

Library Listed

Annoy-inspired Approximate Nearest Neighbors in Rust, based on LMDB and optimized for memory usage

Checked · Sources

Downloads
22,053
Dependents
6
Stars
314
Forks
18
Contributors
8
Commits
562
Latest release
0.9.0 ·

About

From the project README ·

Arroy (Approximate Rearest Reighbors Oh Yeah) is a Rust library with an interface close of the Annoy Python library to search for vectors in space that are near a targeted vector. It is based on LMDB, a memory-mapped key-value store, so many processes may share the same data and atomically modify the vectors.

Background

There are some other libraries to do nearest neighbor search. However, most of them are memory-bound, and none use LMDB for their storage. Annoy considered using LMDB as a backend since 2015. We built Meilisearch on top of LMDB; therefore, it was an obvious choice. As Annoy highly inspires it, we benefit from the same low memory footprint.

Why is this useful? If you want to find the nearest neighbors and have many CPUs, you only need to build the index once. Any thread will be able to query the LMDB-based index and will be able to do lookups immediately, even while another index is modifying it.

We use it inside Meilisearch. This library helps our users search for similar documents. Our users have many millions of them in a high-dimensional space (i.e., 768 on average and 1536 for OpenAI), so memory usage is a prime concern.

Read the full README

Arroy was built by @Kerollmops and @irevoire with the help of @dureuill in a week by porting the original C++ source code of Annoy.

Summary of features

  • Euclidean distance, Manhattan distance, cosine distance, or Dot (Inner) Product distance
  • Cosine distance is equivalent to Euclidean distance of normalized vectors i.e., sqrt(2-2*cos(u, v))
  • Works better if you don't have too many dimensions (like <100) but seems to perform surprisingly well even up to 1,000 dimensions
  • Small memory usage
  • Lets you share memory between multiple processes using LMDB
  • Index creation is separate from lookup (in particular, you can not add more items once the tree has been created)
  • Build index on disk to enable indexing big datasets that won't fit into memory using LMDB
  • Multithreaded tree building using rayon
  • Additional features compared to Annoy
    • Filter when querying
    • Incrementally update the tree without rebuilding it from scratch
    • Store and modify different indexes atomically using LMDB (indexes are identified by an u16)
    • Modify the items list in place while performing queries using LMDB
    • Storage based on LMDB using LMDB
    • Safer to use API, i.e., check dimensions, distances, etc
    • The database size does not depend on the highest item ID but on the number of items
    • Generic over your random number generator

Missing features

  • No Python support
  • No Hamming distance support
  • Generally slower due to the log(n) lookups and non-aligned vectors due to LMDB

Tradeoffs

Only two main parameters are needed to tune Arroy: the number of trees n_trees and the number of nodes to inspect during searching search_k.

  • n_trees is provided during build time and affects the build time and the index size. A larger value will give more accurate results but larger indexes.
  • search_k is provided in runtime and affects the search performance. A larger value will give more accurate results but will take a longer time to return.

If search_k is not provided, it will default to n * n_trees where n is the number of approximate nearest neighbors. Otherwise, search_k and n_trees are roughly independent, i.e., the value of n_trees will not affect search time if search_k is held constant and vice versa. Basically, it's recommended to set n_trees as large as possible given the amount of memory you can afford, and it's recommended to set search_k as large as possible given the time constraints you have for the queries.

How does it work

Using random projections and by building up a tree. At every intermediate node in the tree, a random hyperplane is chosen, which divides the space into two subspaces. This hyperplane is determined by sampling two points from the subset and taking the hyperplane equidistant from them.

We do this k times so that we get a forest of trees. k has to be tuned to your needs by looking at what tradeoff you have between precision and performance.

Dot Product distance (originally contributed by @psobot and @pkorobov) reduces the provided vectors from dot (or "inner-product") space to a more query-friendly cosine space using a method by Bachrach et al., at Microsoft Research, published in 2014.

Benchmarks

The benchmarks are available in another repository. It shows the performances of arroy in terms of recall, disk size usage, search and indexing performances with different parameters compared to other competitors.

Source code

It's all written in Rust and based on LMDB without a handful of ugly optimizations for performance and memory usage. You have been warned :)

The code should support Windows, thanks to LMDB and the Rust programming language.

Big thanks to the open-source community

  • Thanks to Qdrant for their SIMD distances functions
  • Thanks to Spotify for the original idea of Annoy
Runs on
GPU support unknown
What shows it
  • no dependency or feature matches a backend row
Native code
Required
  • Binds native code: lmdb-master-sys
Python bindings
No Python binding crate found
License
MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

arroy beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
arroy This page Listed

Annoy-inspired Approximate Nearest Neighbors in Rust, based on LMDB and optimized for memory usage

22,053 downloads over 30 days 6 314 0.9.0 GPU support unknown Binds native code: lmdb-master-sys MIT
kiddo Featured

A high-performance, flexible, ergonomic k-d tree library. Ideal for geo- and astro- nearest-neighbour and k-nearest-neighbor queries

481,504 downloads over 30 days 56 179 6.3.0 GPU support unknown Build uses a native toolchain: cc (feature cpp_competitors) Apache-2.0 OR MIT
kdtree-rs Featured

K-dimensional tree in Rust for fast geospatial indexing and nearest neighbors lookup

388,481 downloads over 30 days 29 286 0.8.1 GPU support unknown No native code found Apache-2.0 OR MIT
hnsw Listed Dormant

Fast approximate nearest neighbors

15,542 downloads over 30 days 13 268 0.11.0 GPU support unknown No native code found MIT
splintr Listed

Tokenizer for Rust and Python: pure Rust by default, with 18 bundled vocabularies and four backends covering BPE, SentencePiece and WordPiece. Its output matches Hugging Face tokenizers id for id on 14 model families, including GPT-2, Qwen, Whisper, T5 and BERT.

Python bindings

8,204 downloads over 30 days 7 63 0.22.2 GPU support unknown Binds native code: pcre2-sys (feature pcre2) MIT
granne Listed Dormant

Graph-based Retrieval of Approximate Nearest Neighbors

34 downloads over 30 days 0 319 0.5.2 GPU support unknown Binds native code: blas, blas-sys (feature blas) MIT

Fast minimal implementation of HNSW maps for approximate nearest neighbors searches

96,520 downloads over 30 days 36 343 0.6.1 GPU support unknown No native code found Apache-2.0 OR MIT
Why ListedNo archive, New or Featured rule places it, so it is Listed.

What it lacks for Featured

  • It has 0.5 active dependents and 0 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 314 stars, 18 forks and 8 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.

What else the check found

  • The last activity is on 22 Oct 2026, 18 days ago. The rules expect an update within 365 days. Dormancy rule
  • The oldest outside issue waits 1034 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule

Exact rules: Listed, Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.9.0 base 140, raised to the 365-day floor: E = 365 days
  • dormancy: last activity 2026-10-22, 18 days ago, E = 365: active
  • rot: oldest unanswered issue 1034 days (limit 270), no maintainer reply in 365 days
  • featured: not featured: active_users 0.5 < 11 and new_adopters 0 < 9 and repository route stars 314 (needs 4539), forks 18 (needs 434), contributors 8 (needs 79)
  • listed: listed: no archive, new or featured rule applies

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption1 active dependents, 0 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents0.5crates.io database dumpYes
New dependents (365 days)0crates.io database dumpYes
Peak active dependents4.25crates.io database dumpYes
Active dependents as a share of the peak0.9313crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 12 months ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2025-10-16GitHub repositoryYes
Latest release2026-10-22crates.io database dumpYes
First release2023-11-30crates.io database dumpYes
Latest version0.9.0crates.io database dumpYes
Days the oldest outside issue waits for a reply1034GitHub repositoryYes
Maintainer replies over 365 days0GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution14 releases, 22,053 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases14crates.io database dumpYes
Downloads over 30 days22053crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository314 stars, 18 forks, 8 contributors, 562 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars314GitHub repositoryYes — one part of the repository route
GitHub forks18GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account8GitHub contributorsYes — one part of the repository route
Commits on the default branch562GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseMITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesBinds native code: lmdb-master-syscrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly6crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.