Jump to content

Hierarchical navigable small world

From Wikipedia, the free encyclopedia

The Hierarchical navigable small world (HNSW) algorithm is a graph-based approximate nearest neighbor search technique used in many vector databases.[1][2] Nearest neighbor search without an index involves computing the distance from the query to each point in the database, which for large datasets is computationally prohibitive. For high-dimensional data, tree-based exact vector search techniques such as the k-d tree and R-tree do not perform well enough because of the curse of dimensionality. To remedy this, approximate k-nearest neighbor searches have been proposed, such as locality-sensitive hashing (LSH) and product quantization (PQ) that trade performance for accuracy.[2] The HNSW graph offers an approximate k-nearest neighbor search which scales logarithmically even in high-dimensional data.

It is an extension of the earlier work on navigable small world graphs presented at the Similarity Search and Applications (SISAP) conference in 2012 with an additional hierarchical navigation to find entry points to the main graph faster.[3] HNSW-based libraries are among the best performers in the approximate nearest neighbors benchmark.[4][5][6]

Use in vector databases

[edit]

HNSW is a key method for approximate nearest neighbor search in high-dimensional vector databases, for example in the context of embeddings from neural networks in large language models. Databases that use HNSW as search index include:

Several of these use either the hnswlib library[10] provided by the original authors, or the FAISS library.

References

[edit]
  1. ^ Malkov, Yu A.; Yashunin, D. A. (2016). "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs". arXiv:1603.09320 [cs.DS].
  2. ^ a b Malkov, Yury A; Yashunin, Dmitry A (1 April 2020). "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs". IEEE Transactions on Pattern Analysis and Machine Intelligence. 42 (4): 824–836. arXiv:1603.09320. doi:10.1109/TPAMI.2018.2889473. PMID 30602420.
  3. ^ Malkov, Yury; Ponomarenko, Alexander; Logvinov, Andrey; Krylov, Vladimir (2012). "Scalable Distributed Algorithm for Approximate Nearest Neighbor Search Problem in High Dimensional General Metric Spaces". In Navarro, Gonzalo; Pestov, Vladimir (eds.). Similarity Search and Applications. Lecture Notes in Computer Science. Vol. 7404. Berlin, Heidelberg: Springer. pp. 132–147. doi:10.1007/978-3-642-32153-5_10. ISBN 978-3-642-32153-5.
  4. ^ Aumüller, Martin; Bernhardsson, Erik; Faithfull, Alexander (2017). "ANN-Benchmarks: A Benchmarking Tool for Approximate Nearest Neighbor Algorithms". In Beecks, Christian; Borutta, Felix; Kröger, Peer; Seidl, Thomas (eds.). Similarity Search and Applications. Lecture Notes in Computer Science. Vol. 10609. Cham: Springer International Publishing. pp. 34–49. arXiv:1807.05614. doi:10.1007/978-3-319-68474-1_3. ISBN 978-3-319-68474-1.
  5. ^ Aumüller, Martin; Bernhardsson, Erik; Faithfull, Alexander (2020). "ANN-Benchmarks: A benchmarking tool for approximate nearest neighbor algorithms". Information Systems. 87: 101374. arXiv:1807.05614. doi:10.1016/j.is.2019.02.006.
  6. ^ "ANN-Benchmarks". ann-benchmarks.com. Retrieved 2024-03-19.
  7. ^ "MariaDB Vector". MariaDB.org. Retrieved 2024-07-30.
  8. ^ "MongoDB Atlas Vector Search". mongodb.com. Retrieved 2024-09-17.
  9. ^ "How to Pick a Vector Index in Your Milvus Instance: A Visual Guide". zilliz.com. Retrieved 2024-10-10.
  10. ^ nmslib/hnswlib, nmslib, 2024-03-18, retrieved 2024-03-19