# nmslib/hnswlib

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/nmslib-hnswlib).**

5,253 stars · 831 forks · C++ · Apache-2.0

## Links

- GitHub: https://github.com/nmslib/hnswlib
- Homepage: https://github.com/nmslib/hnswlib
- awesome-repositories: https://awesome-repositories.com/repository/nmslib-hnswlib.md

## Description

hnswlib is a header-only C++ library and vector indexing engine designed for high-dimensional approximate nearest neighbor search. It organizes large collections of embeddings into a searchable graph structure to enable rapid proximity queries and distance calculations.

The system utilizes Hierarchical Navigable Small World graphs to achieve fast vector similarity search. It distinguishes itself by allowing the definition of custom distance metrics and similarity functions to adapt calculations to specific data requirements.

The engine covers the full indexing lifecycle, including incremental index construction and the management of data points through additions and element removal. Query capabilities include both approximate and exact nearest neighbor search, supplemented by boolean search filtering to exclude candidates based on element labels.

The library supports index persistence via binary file serialization and provides configurations for parallel execution to distribute query and indexing tasks across multiple CPU cores.

## Tags

### Data & Databases

- [Hierarchical Proximity Graphs](https://awesome-repositories.com/f/data-databases/hierarchical-proximity-graphs.md) — Utilizes Hierarchical Navigable Small World graphs to achieve logarithmic search complexity through coarse-to-fine navigation.
- [Vector Indexing](https://awesome-repositories.com/f/data-databases/vector-indexing.md) — Implements a high-performance indexing engine specifically designed for high-dimensional vector data and similarity search. ([source](https://github.com/nmslib/hnswlib/blob/master/README.md))
- [Approximate Nearest Neighbor Search](https://awesome-repositories.com/f/data-databases/approximate-nearest-neighbor-search.md) — Utilizes Hierarchical Navigable Small World graphs to trade absolute precision for significantly faster proximity lookups. ([source](https://github.com/nmslib/hnswlib/blob/master/README.md))
- [Graph](https://awesome-repositories.com/f/data-databases/index-construction/graph.md) — Constructs hierarchical proximity graphs by configuring link density to balance memory usage and retrieval recall. ([source](https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md))
- [Vector Indexing Engines](https://awesome-repositories.com/f/data-databases/vector-indexing-engines.md) — Acts as a high-performance engine for organizing vectors to enable rapid proximity queries and distance calculations.
- [HNSW Indexes](https://awesome-repositories.com/f/data-databases/vector-indexing/hnsw-indexes.md) — Provides a high-performance implementation of Hierarchical Navigable Small World (HNSW) indexes for approximate nearest neighbor search.
- [Incremental Vector Sync](https://awesome-repositories.com/f/data-databases/vector-indexing/incremental-vector-sync.md) — Supports incremental index management by adding or removing elements without requiring a full rebuild.
- [Header-only Libraries](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-serialization/json-libraries/c/header-only-libraries.md) — Distributed as a header-only C++ library to enable compiler inlining and simplify integration.
- [Search Index Deletions](https://awesome-repositories.com/f/data-databases/in-memory-data-stores/vector-stores/document-deletions/search-index-deletions.md) — Allows for the removal of specific data points from the search index via unique identifiers. ([source](https://github.com/nmslib/hnswlib))
- [Incremental Indexing Engines](https://awesome-repositories.com/f/data-databases/incremental-indexing-engines.md) — Supports adding and updating vectors within the index without necessitating a full rebuild of the graph structure. ([source](https://github.com/nmslib/hnswlib))
- [Index Persistence Utilities](https://awesome-repositories.com/f/data-databases/k-nearest-neighbor-retrieval/index-persistence-utilities.md) — Enables saving and loading the current index state to binary files for persistence across sessions. ([source](https://github.com/nmslib/hnswlib/blob/master/examples/python/EXAMPLES.md))
- [Search Index Management](https://awesome-repositories.com/f/data-databases/search-index-management.md) — Includes tools for managing the index lifecycle, including marking elements as deleted to reclaim memory. ([source](https://github.com/nmslib/hnswlib/blob/master/README.md))
- [Dynamic Index Updating](https://awesome-repositories.com/f/data-databases/search-indexing-utilities/dynamic-index-updating.md) — Provides mechanisms to update index content and replace elements to ensure the dataset remains current. ([source](https://github.com/nmslib/hnswlib/blob/master/examples/python/EXAMPLES.md))
- [Vector Databases](https://awesome-repositories.com/f/data-databases/vector-databases.md) — Provides the core indexing and retrieval layer necessary for building high-performance vector databases.

### Artificial Intelligence & ML

- [Vector Similarity Search](https://awesome-repositories.com/f/artificial-intelligence-ml/vector-similarity-search.md) — Implements algorithms and data structures for performing similarity search on high-dimensional vector embeddings.

### Scientific & Mathematical Computing

- [Nearest Neighbor Searches](https://awesome-repositories.com/f/scientific-mathematical-computing/nearest-neighbor-searches.md) — Implements algorithms for finding the closest vectors in high-dimensional space based on distance calculations. ([source](https://github.com/nmslib/hnswlib/blob/master/examples/python/EXAMPLES.md))
- [Vector Distance Metrics](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-distance-metrics.md) — Provides the mathematical framework for implementing specialized similarity functions between high-dimensional vectors.
- [Customizable Distance Metrics](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-distance-metrics/customizable-distance-metrics.md) — Allows the definition of custom similarity functions to adapt distance calculations to specific data requirements. ([source](https://github.com/nmslib/hnswlib/blob/master/README.md))
- [Template-Based Metrics](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/mathematical-libraries-and-utilities/core-mathematical-concepts/distance-metrics/template-based-metrics.md) — Uses C++ template polymorphism to inject custom similarity functions without the overhead of virtual function calls.

### Software Engineering & Architecture

- [Greedy Graph Search](https://awesome-repositories.com/f/software-engineering-architecture/entity-management/graph-traversal/greedy-graph-search.md) — Implements greedy search traversal to efficiently navigate the graph layers toward the closest vector.

### Programming Languages & Runtimes

- [Multi-threaded Execution](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/concurrency/execution-models/multi-threaded-execution.md) — Distributes independent search and indexing requests across multiple CPU cores to increase throughput.

### Part of an Awesome List

- [AI & Machine Learning](https://awesome-repositories.com/f/awesome-lists/ai/ai-machine-learning.md) — Fast approximate nearest neighbors library
- [Machine Learning](https://awesome-repositories.com/f/awesome-lists/ai/machine-learning.md) — Fast approximate nearest neighbor search library.
