# ANN Benchmarks

Source: https://zilliz.com/glossary/ann-benchmarks
Published: 2024-09-02T20:56:49.833Z

Imagine you're building a search engine that needs to quickly find the most similar items from a database containing billions of images, text documents, or other [unstructured data](https://zilliz.com/glossary/unstructured-data). How do you ensure your search algorithm not only returns accurate results but also does so at lightning speed? This is where [Approximate Nearest Neighbor](https://zilliz.com/glossary/anns) (ANN) search comes into play. ANN search is crucial in many real-world applications, from recommendation systems to large-scale image retrieval. 

With so many ANN search solutions available in the market, how do we evaluate the effectiveness of different ANN algorithms, especially at scale? Enter the ANN Benchmarks, which have become the gold standard for testing the performance of ANN search methods on large datasets.

In this blog, we'll explore ANN benchmarks, why they matter, and how they help developers and algorithm engineers choose the right [vector search](https://zilliz.com/learn/vector-similarity-search) solutions for the job. We'll also look at some of the most popular benchmarks used today and what makes them essential in vector search.


<iframe class="video-player" src="https://www.youtube.com/embed/GcNY7lWtcVM?list=PLPg7_faNDlT7SC3HxWShxKT-t-u7uKr--&start=1844" title="SF Unstructured Data Meetup January 16 2024" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>


## What is ANN Search and How Does It Work?

Before diving into benchmarks, it’s important to understand the Approximate Nearest Neighbor (ANN) Search, or ANNS, and how it operates. ANN Search is a powerful technique in machine learning (ML) that allows for efficient [semantic similarity](https://zilliz.com/glossary/semantic-similarity) search in large datasets often found in [vector databases](https://zilliz.com/learn/what-is-vector-database) like [Zilliz Cloud](https://zilliz.com/cloud). It can quickly find items closest to a given query item in a dataset. Unlike exact search methods, which ensure 100% accuracy, ANNS trades off a small amount of accuracy for significant improvements in speed and scalability.


### How ANN Search Works:

* **Data Representation:** Each item in the dataset is represented as a [vector](https://zilliz.com/glossary/vector-embeddings) in a multi-dimensional space. Vectors are usually encoded by an [embedding model](https://zilliz.com/ai-models) such as [OpenAI text embedding models](https://zilliz.com/learn/guide-to-using-openai-text-embedding-models), Cohere [multilingual models](https://zilliz.com/ai-models/embed-multilingual-v3.0), and OpenAI [multimodal models](https://zilliz.com/ai-models/clip-vit-base-patch32). For instance, an image might be represented as a vector of features, such as color or shape, in a 128-dimensional space. 

* **Query Processing:** When a query is made, the ANN Search algorithm retrieves the dataset for vectors close to the query vector, using approximations to speed up the process.

* **Result Ranking:** The algorithm ranks the nearest neighbors based on their distance from the query in the high-dimensional space, often using metrics like Euclidean distance or [cosine similarity](https://zilliz.com/blog/similarity-metrics-for-vector-search). The closer the vectors are located, the more similar and relevant they are. 

* **Efficiency:** ANN Search's key advantage is its ability to deliver results in a fraction of the time it would take for an exact search, making it ideal for large-scale datasets.

ANNS methods use various strategies to quickly approximate the nearest neighbors:

* **Tree-based Methods:** Techniques such as KD-Trees and Ball Trees organize data hierarchically to simplify the search process. While effective in lower dimensions, their performance degrades as dimensionality increases.

* **Hashing Methods:** [Locality-sensitive hashing (LSH)](https://zilliz.com/learn/mastering-locality-sensitive-hashing-a-comprehensive-tutorial) groups similar data points into the same hash buckets, reducing the number of comparisons required during the search.

* **Graph-based Methods**: Algorithms like Navigable Small World (NSW) graphs and [Hierarchical Navigable Small World](https://zilliz.com/learn/hierarchical-navigable-small-worlds-HNSW) (HNSW) graphs create networks of data points to expedite neighbor lookups.

* **Quantization Methods**: Techniques such as [Product Quantization](https://zilliz.com/learn/scalar-quantization-and-product-quantization) (PQ) compress the data into a more manageable form, enhancing search efficiency.

By leveraging these methods, ANNS algorithms can balance between search accuracy and performance, making them suitable for large-scale datasets.

### ANN Search vs. KNN Search

Exact [K-nearest neighbor](https://zilliz.com/blog/k-nearest-neighbor-algorithm-for-machine-learning) search (KNN) and Approximate Nearest Neighbor Search (ANNS) are two fundamental approaches used in vector search, each with its own advantages and trade-offs. 

Exact KNN provides precise results by evaluating the distance between the query point and every data point in the dataset, ensuring that the identified neighbors are the closest possible. However, this method can be computationally intensive and slow due to its brute-force nature, particularly when dealing with large datasets or high-dimensional spaces. This makes exact KNN suitable for smaller datasets or scenarios where precision is paramount and computational resources are less of a concern.

In contrast, ANNS offers a practical solution for handling large-scale data by sacrificing some degree of accuracy for faster performance. ANNS employs various algorithms and techniques, such as tree-based structures, hashing methods, and [graph-based approaches](https://zilliz.com/learn/what-is-knowledge-graph), to approximate the nearest neighbors efficiently. This approach significantly reduces computational costs and scales well with massive datasets, making it ideal for real-time applications like search engines and [recommendation systems](https://zilliz.com/vector-database-use-cases/recommender-system) where speed is crucial. While ANNS may not always provide the exact closest neighbors, its ability to deliver near-accurate results quickly makes it a valuable tool in modern data retrieval and analysis tasks.

For more information, see our [ANNS glossary page](https://zilliz.com/glossary/anns). 

## What is ANN Benchmark?

The [ANN Benchmark](https://github.com/erikbern/ann-benchmarks/) is a comprehensive evaluation tool designed to measure and compare the performance of different ANNS algorithms. Hosted on[ ](https://ann-benchmarks.com/index.html)[ann-benchmarks.com](http://ann-benchmarks.com), it provides standardized tests and metrics to assess various aspects of ANNS methods, including: 

* **Search Speed**: How quickly the algorithm can find the nearest neighbors.

* **Accuracy:** The degree to which the algorithm's results approximate the true nearest neighbors.

* **Scalability:** How well the algorithm performs as the dataset size or dimensionality increases.

This benchmark offers a range of datasets and evaluation criteria, allowing developers to gauge the effectiveness of different algorithms under various conditions on a level playing field. 

### Key Metrics in ANN Benchmarks:

* **Recall:** The percentage of true nearest neighbors successfully retrieved by the algorithm. High recall indicates better accuracy.

* **Search Time:** The time it takes for the algorithm to return a result. Faster search times are crucial for applications that require real-time responses.

* **Memory Usage:** The amount of memory the algorithm requires to store and search the dataset. Efficient memory usage is important for scalability.

* **Scalability:** The algorithm’s ability to maintain performance as the dataset size increases. Scalability is a critical factor in real-world applications where datasets can grow rapidly.

### Key datasets used in ANN Benchmarks 

ANN Benchmark uses diverse datasets to test algorithms. These datasets cover a range of domains, such as image features, text embeddings, and synthetic data. Key datasets used in the benchmarks include:

| **Dataset**                                                       | **Dimensions** | **Train size** | **Test size** | **Neighbors** | **Distance** | **Download**                                                               |
| ----------------------------------------------------------------- | -------------- | -------------- | ------------- | ------------- | ------------ | -------------------------------------------------------------------------- |
| [DEEP1B](http://sites.skoltech.ru/compvision/noimi/)              | 96             | 9,990,000      | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/deep-image-96-angular.hdf5) (3.6GB)       |
| [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) | 784            | 60,000         | 10,000        | 100           | Euclidean    | [HDF5](http://ann-benchmarks.com/fashion-mnist-784-euclidean.hdf5) (217MB) |
| [GIST](http://corpus-texmex.irisa.fr/)                            | 960            | 1,000,000      | 1,000         | 100           | Euclidean    | [HDF5](http://ann-benchmarks.com/gist-960-euclidean.hdf5) (3.6GB)          |
| [GloVe](http://nlp.stanford.edu/projects/glove/)                  | 25             | 1,183,514      | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/glove-25-angular.hdf5) (121MB)            |
| GloVe                                                             | 50             | 1,183,514      | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/glove-50-angular.hdf5) (235MB)            |
| GloVe                                                             | 100            | 1,183,514      | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/glove-100-angular.hdf5) (463MB)           |
| GloVe                                                             | 200            | 1,183,514      | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/glove-200-angular.hdf5) (918MB)           |
| [Kosarak](http://fimi.uantwerpen.be/data/)                        | 27,983         | 74,962         | 500           | 100           | Jaccard      | [HDF5](http://ann-benchmarks.com/kosarak-jaccard.hdf5) (33MB)              |
| [MNIST](http://yann.lecun.com/exdb/mnist/)                        | 784            | 60,000         | 10,000        | 100           | Euclidean    | [HDF5](http://ann-benchmarks.com/mnist-784-euclidean.hdf5) (217MB)         |
| [MovieLens-10M](https://grouplens.org/datasets/movielens/10m/)    | 65,134         | 69,363         | 500           | 100           | Jaccard      | [HDF5](http://ann-benchmarks.com/movielens10m-jaccard.hdf5) (63MB)         |
| [NYTimes](https://archive.ics.uci.edu/ml/datasets/bag+of+words)   | 256            | 290,000        | 10,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/nytimes-256-angular.hdf5) (301MB)         |
| [SIFT](http://corpus-texmex.irisa.fr/)                            | 128            | 1,000,000      | 10,000        | 100           | Euclidean    | [HDF5](http://ann-benchmarks.com/sift-128-euclidean.hdf5) (501MB)          |
| [Last.fm](https://github.com/erikbern/ann-benchmarks/pull/91)     | 65             | 292,385        | 50,000        | 100           | Angular      | [HDF5](http://ann-benchmarks.com/lastfm-64-dot.hdf5) (135MB)               |



### Tested ANN Algorithms or Vector Search Engines 

The ANN Benchmarks have evaluated a wide range of ANN algorithms and vector search engines, including [Annoy](https://zilliz.com/learn/approximate-nearest-neighbor-oh-yeah-ANNOY), [Faiss](https://zilliz.com/learn/faiss), Knowhere ([Milvus](https://zilliz.com/what-is-milvus)'s search engine), and Glass ([Zilliz Cloud](https://zilliz.com/cloud)'s legacy search engine). The number of tested algorithms continues to grow. Below is a list of algorithms and search engines tested as of September 2024.

* [Annoy](https://github.com/spotify/annoy) 

* [FLANN](http://www.cs.ubc.ca/research/flann/) 

* [scikit-learn](http://scikit-learn.org/stable/modules/neighbors.html): LSHForest, KDTree, BallTree

* [Weaviate](https://github.com/weaviate/weaviate) 

* [PANNS](https://github.com/ryanrhymes/panns) 

* [NearPy](http://pixelogik.github.io/NearPy/) 

* [KGraph](https://github.com/aaalgo/kgraph) 

* [NMSLIB (Non-Metric Space Library)](https://github.com/nmslib/nmslib) : SWGraph, HNSW, BallTree, MPLSH

* [hnswlib (a part of nmslib project)](https://github.com/nmslib/hnsw) 

* [RPForest](https://github.com/lyst/rpforest) 

* [FAISS](https://github.com/facebookresearch/faiss) 

* [DolphinnPy](https://github.com/ipsarros/DolphinnPy) 

* [Datasketch](https://github.com/ekzhu/datasketch) 

* [nndescent](https://github.com/brj0/nndescent) 

* [PyNNDescent](https://github.com/lmcinnes/pynndescent) 

* [MRPT](https://github.com/teemupitkanen/mrpt) 

* [NGT](https://github.com/yahoojapan/NGT) : ONNG, PANNG, QG

* [SPTAG](https://github.com/microsoft/SPTAG) 

* [PUFFINN](https://github.com/puffinn/puffinn) 

* [N2](https://github.com/kakao/n2) 

* [ScaNN](https://github.com/google-research/google-research/tree/master/scann)

* [Vearch](https://github.com/vearch/vearch) 

* [Elasticsearch](https://github.com/elastic/elasticsearch) : HNSW

* [Elastiknn](https://github.com/alexklibisz/elastiknn) 

* [ExpANN](https://github.com/jacketsj/expANN) 

* [OpenSearch KNN](https://github.com/opensearch-project/k-NN) 

* [DiskANN](https://github.com/microsoft/diskann) : Vamana, Vamana-PQ

* [Vespa](https://github.com/vespa-engine/vespa) 

* [scipy](https://docs.scipy.org/doc/scipy/reference/spatial.html): cKDTree

* [vald](https://github.com/vdaas/vald) 

* [Qdrant](https://github.com/qdrant/qdrant) 

* [HUAWEI(qsgngt)](https://github.com/WPJiang/HWTL_SDU-ANNS.git)

* [Milvus](https://github.com/milvus-io/milvus) : [Knowhere](https://github.com/milvus-io/knowhere)

* [Zilliz(Glass)](https://github.com/hhy3/pyglass)

* [pgvector](https://github.com/pgvector/pgvector) 

* [pgvecto.rs](http://pgvecto.rs) 

* [RediSearch](https://github.com/redisearch/redisearch) 

* [pg_embedding](https://github.com/neondatabase/pg_embedding) 

* [Descartes(01AI)](https://github.com/xiaoming-01ai/descartes)

* [kgn](https://github.com/Henry-yan/kgn)

**Note:** Zilliz Cloud has launched a new search engine called [Cardinal](https://zilliz.com/blog/cardinal-most-performant-vector-search-engine), which delivers three times the performance of the legacy Glass engine and offers search throughput (QPS) up to ten times that of [Milvus](https://zilliz.com/what-is-milvus). However, due to time constraints and other factors, Cardinal's performance is not included in the ANN benchmark results. In the following section, you can explore its performance using VectorDBBench.

### Benchmark Results 

The graph below demonstrates the results of testing recall/queries per second of various algorithms based on the GIST1M dataset (1M vectors with 960 dimensions). It plots the recall rate on the x-axis against QPS on the y-axis, illustrating each algorithm's performance at different levels of retrieval accuracy.

![Figure 1: ANN Benchmark results on the GIST1M dataset](https://assets.zilliz.com/Recall_Queries_Per_Second_3bde2f0da5.png)

*Figure 1: ANN Benchmark results on the GIST1M dataset*

According to the results shown in the graph above, Knowhere (Milvus’ search engine), Glass (Zilliz Cloud’s legacy search engine), and HNSW libraries achieved the top three best results when processing 1,000,000 vectors with 960 dimensions. 

For more benchmarking results, see [ANN-Benchmark’s website](https://ann-benchmarks.com/).

## VectorDBBench: An Open-source Benchmarking Tool for Vector Databases 

[Vector search](https://zilliz.com/learn/vector-similarity-search), or vector similarity search, is a broader concept that refers to the process of finding similar vectors within a dataset. ANNS represents a set of algorithms that power vector search. [Vector databases](https://zilliz.com/learn/what-is-vector-database) are purpose-built solutions for efficient vector similarity searches. 

Although the ANN-Benchmark is incredibly useful for selecting and comparing different vector searching algorithms, it does not provide a comprehensive overview of vector databases. We must also consider factors like resource consumption, data loading capacity, and system stability. Moreover, the ANN Benchmark misses many common scenarios, such as[filtered vector searches](https://zilliz.com/blog/metadata-filtering-hybrid-search-or-agent-in-rag-applications). 

To address such challenges, Zilliz developers proposed [VectorDBBench](https://github.com/zilliztech/VectorDBBench), an open-source benchmarking tool designed for open-source vector databases like [Milvus and Weaviate](https://zilliz.com/comparison/milvus-vs-weaviate) and fully managed services like [Zilliz Cloud and Pinecone](https://zilliz.com/comparison/pinecone-vs-zilliz-vs-milvus). Because many fully managed vector search services do not expose their parameters for user tuning, VectorDBBench displays QPS and recall rates separately.

The charts below demonstrate the testing results for QPS and the recall rate of various mainstream vector databases when processing 1,000,000 vectors with 768 dimensions. 

![Figure 2: Benchmark results for QPS ](https://assets.zilliz.com/Benchmarking_Mainstream_Vector_Databases_QPS_1_M_b84b6968ae.png)

![Figure 3: Benchmark results for recall rate ](https://assets.zilliz.com/Benchmarking_Mainstream_Vector_Databases_Recall_Rate_1_M_02298817ae.png)

Based on the results in the charts above, purpose-built vector databases like Milvus and Zilliz demonstrated outstanding performance in both QPS and recall rates. These results indicate that purpose-built vector databases can quickly process vast amounts of data and retrieve more precise results. In contrast, vector search add-ons based on traditional databases showed poorer performance.

Download VectorDBBench from its [GitHub repository](https://github.com/zilliztech/VectorDBBench) to reproduce our benchmark results or obtain performance results on your own datasets. 

### VectorDBBench Leaderboard 

VectorDBBench also offers a dedicated [leaderboard page](https://zilliz.com/vector-database-benchmark-tool?database=ZillizCloud%2CMilvus%2CElasticCloud%2CPgVector%2CPinecone%2CQdrantCloud%2CWeaviateCloud&dataset=medium&filter=none%2Clow%2Chigh&tab=1) designed to streamline the presentation of test results and deliver a thorough performance analysis report. This leaderboard allows us to select key metrics such as Queries Per Second (QPS), Query Price ($) metrics, and latency for a comprehensive performance assessment. 

![a screenshot of the vectordbbench leaderboard](https://assets.zilliz.com/a_screenshot_of_the_vectordbbench_leaderboard_b23b03f868.png)


*Figure 4: A screenshot of the VectorDBBench Leaderboard*

## ANN Benchmarks vs. VectorDBBench

ANN Benchmarks evaluate vector index algorithms, aiding in selecting and comparing different vector-searching libraries. However, they are unsuitable for assessing complex and mature vector databases and overlook situations like filtered vector searching.

The engineers at [Zilliz](https://zilliz.com/) created VectorDB Bench to be tailored for comprehensive [vector database](https://zilliz.com/learn/beginner-guide-to-implementing-vector-databases) evaluation. It considers essential factors such as resource consumption, data loading capacity, and system stability. By segregating the test client and vector database and ensuring independent deployment, VectorDB Bench allows for testing that closely mirrors real-world production environments.

## Factors Influencing Performance Evaluation 

Several factors impact the performance of a vector database or an ANN algorithm, including the dataset, network conditions, and database configuration.

### Network

Network conditions are critical. **Latency** can slow query responses, while **limited bandwidth** affects data transfer rates. **Network stability** is also important, as fluctuations can cause inconsistent performance.

### Datasets

**Dataset size** influences memory and disk usage—larger datasets require more resources. [**Vector dimensionality**](https://zilliz.com/glossary/curse-of-dimensionality-in-machine-learning) affects operation complexity and query times. The **data distribution** and **indexing structure** (e.g., hierarchical, flat) also impact search efficiency and accuracy.

### Database Configuration

**Index parameters** (e.g., number of trees) and **search settings** (e.g., nearest neighbors) directly affect retrieval efficiency and speed. **Caching** can improve response times for frequently accessed data.

### Environmental Factors

The **operating system** and background processes can influence resource availability and system responsiveness, affecting overall performance.

Considering these factors helps you understand and optimize your vector database’s performance.

## Further Resources

* Website: <https://ann-benchmarks.com/> 

* [ANN Benchmarks GitHub](https://github.com/erikbern/ann-benchmarks)

* [Benchmark Vector Database Performance: Techniques & Insights ](https://zilliz.com/learn/benchmark-vector-database-performance-techniques-and-insights)

* [Why Qdrant Benchmark Results are Misleading](https://zilliz.com/blog/demystify-benchmark-result-divergence-milvus-vs-qdrant)

* [VectorDBBench: Open-Source Vector Database Benchmark Tool](https://zilliz.com/learn/open-source-vector-database-benchmarking-your-way)
