MCPcopy Index your code
hub / github.com/erikbern/ann-benchmarks

github.com/erikbern/ann-benchmarks @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
647 symbols 1,614 edges 81 files 71 documented · 11% 7 cross-repo links updated 13mo ago★ 5,69693 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Benchmarking nearest neighbors

Build Status

Doing fast searching of nearest neighbors in high dimensional spaces is an increasingly important problem with notably few empirical attempts at comparing approaches in an objective way, despite a clear need for such to drive optimization forward.

This project contains tools to benchmark various implementations of approximate nearest neighbor (ANN) search for selected metrics. We have pre-generated datasets (in HDF5 format) and prepared Docker containers for each algorithm, as well as a test suite to verify function integrity.

Evaluated

Data sets

We have a number of precomputed data sets in HDF5 format. All data sets have been pre-split into train/test and include ground truth data for the top-100 nearest neighbors.

Dataset Dimensions Train size Test size Neighbors Distance Download
DEEP1B 96 9,990,000 10,000 100 Angular HDF5 (3.6GB)
Fashion-MNIST 784 60,000 10,000 100 Euclidean HDF5 (217MB)
GIST 960 1,000,000 1,000 100 Euclidean HDF5 (3.6GB)
GloVe 25 1,183,514 10,000 100 Angular HDF5 (121MB)
GloVe 50 1,183,514 10,000 100 Angular HDF5 (235MB)
GloVe 100 1,183,514 10,000 100 Angular HDF5 (463MB)
GloVe 200 1,183,514 10,000 100 Angular HDF5 (918MB)
Kosarak 27,983 74,962 500 100 Jaccard HDF5 (33MB)
MNIST 784 60,000 10,000 100 Euclidean HDF5 (217MB)
MovieLens-10M 65,134 69,363 500 100 Jaccard HDF5 (63MB)
NYTimes 256 290,000 10,000 100 Angular HDF5 (301MB)
SIFT 128 1,000,000 10,000 100 Euclidean HDF5 (501MB)
Last.fm 65 292,385 50,000 100 Angular HDF5 (135MB)
COCO-I2I 512 113,287 10,000 100 Angular HDF5 (136MB)
COCO-T2I 512 113,287 10,000 100 Angular HDF5 (136MB)

Results

These are all as of April 2025, running all benchmarks on a r6i.16xlarge machine on AWS with --parallelism 31 and hyperthreading disabled. All benchmarks are single-CPU.

glove-100-angular

glove-100-angular

sift-128-euclidean

glove-100-angular

fashion-mnist-784-euclidean

fashion-mnist-784-euclidean

nytimes-256-angular

nytimes-256-angular

gist-960-euclidean

gist-960-euclidean

glove-25-angular

glove-25-angular

TODO: update plots on http://ann-benchmarks.com.

Install

The only prerequisite is Python (tested with 3.10.6) and Docker.

  1. Clone the repo.
  2. Run pip install -r requirements.txt.
  3. Run python install.py to build all the libraries inside Docker containers (this can take a while, like 10-30 minutes).

Running

  1. Run python run.py (this can take an extremely long time, potentially days).
  2. Run python plot.py --x-scale logit --y-scale log to plot results.
  3. Run python create_website.py to create a website with lots of plots.

You can customize the algorithms and datasets as follows:

  • Check that ann_benchmarks/algorithms/{YOUR_IMPLEMENTATION}/config.yml contains the parameter settings that you want to test
  • To run experiments on SIFT, invoke python run.py --dataset glove-100-angular. See python run.py --help for more information on possible settings. Note that experiments can take a long time.
  • To process the results, either use python plot.py --dataset glove-100-angular or python create_website.py. An example call: python create_website.py --plottype recall/time --latex --scatter --outputdir website/.

Including your algorithm

Add your algorithm in the folder `ann

Core symbols most depended-on inside this repo

Shape

Method 394
Function 163
Class 90

Languages

Python100%

Modules by API surface

ann_benchmarks/algorithms/subprocess/module.py39 symbols
ann_benchmarks/algorithms/milvus/module.py37 symbols
ann_benchmarks/datasets.py29 symbols
ann_benchmarks/algorithms/pgvector/module.py19 symbols
ann_benchmarks/algorithms/faiss/module.py19 symbols
ann_benchmarks/definitions.py16 symbols
ann_benchmarks/algorithms/kgn/module.py16 symbols
ann_benchmarks/algorithms/elastiknn/module.py16 symbols
ann_benchmarks/algorithms/diskann/module.py16 symbols
ann_benchmarks/plotting/metrics.py15 symbols
ann_benchmarks/algorithms/luceneknn/module.py15 symbols
create_website.py14 symbols

Dependencies from manifests, versioned

ansicolors1.1.8 · 1×
datasets3.4.0 · 1×
docker7.1.0 · 1×
h5py3.13.0 · 1×
jinja23.1.6 · 1×
matplotlib3.10.1 · 1×
numpy2.2.4 · 1×
psutil7.0.0 · 1×
pytest8.3.5 · 1×
pyyaml6.0.2 · 1×
requests2.32.3 · 1×
scikit-learn1.6.1 · 1×

For agents

$ claude mcp add ann-benchmarks \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page