aicoolies logo
hnswlib logo

hnswlib

Header-only C++ implementation of HNSW for fast approximate nearest-neighbor search.

Share
free
Visit Website →

hnswlib is a header-only C++ library implementing the Hierarchical Navigable Small World (HNSW) graph algorithm for approximate nearest-neighbor search, with Python bindings and a tiny dependency footprint. Originally developed by the nmslib team, it has become the default HNSW implementation embedded inside many vector databases and search products. Engineers use it directly when they want HNSW retrieval without pulling in a heavyweight vector DB.

hnswlib is the canonical open-source implementation of the HNSW algorithm — a graph-based ANN structure that delivers state-of-the-art recall-versus-latency curves for in-memory vector search. The library is intentionally minimal: header-only C++ for the core, lightweight Python bindings for everyday use, and an interface focused on building, querying, saving, and loading indexes without ceremony.

The library has spread far beyond standalone use because of how cleanly it embeds. Vector databases including Milvus, Weaviate, Qdrant, and pgvector have either integrated hnswlib directly or based their HNSW implementations on its data structures and tuning conventions. For ML teams that need a single-process, in-memory index attached to a Python service, hnswlib is the path of least resistance — pip install, build the index, query in milliseconds.

Where hnswlib stops short is at the system layer. It is a single-machine library, not a distributed search engine: no sharding, replication, or persistence beyond a flat-file dump and reload. Development cadence has slowed compared to its early years, with fewer commits in 2024 and 2025, but the library remains stable and widely deployed. Apache-2.0 licensed.

Pricing

Open-source Apache-2.0 licensed library — no commercial tier.

Platforms

Header-only C++ with Python bindings; cross-platform.

Categories

Tags

Use Cases

Alternatives

Qdrant logo

Qdrant

High-performance vector database written in Rust for similarity search at scale.

Qdrant is a high-performance vector similarity search engine and database written in Rust. Designed for production-grade AI applications with advanced filtering, payload indexing, and distributed deployment. Supports billion-scale vector collections with sub-second query times. Popular choice for RAG, recommendation systems, and anomaly detection.

freemiumOpen Source
Weaviate logo

Weaviate

Open-source vector database for AI-native applications and semantic search.

Weaviate is an open-source vector database purpose-built for AI applications. Supports vector, keyword, and hybrid search with built-in vectorization modules for OpenAI, Cohere, Hugging Face, and more. Used for RAG pipelines, semantic search, recommendation engines, and multimodal search. Written in Go for high performance.

freemiumOpen Source
Milvus logo

Milvus

GPU-accelerated open-source vector database

Milvus is an open-source vector database with 33K+ GitHub stars for billion-scale similarity search. Features GPU-accelerated indexing, hybrid search combining vector and scalar filtering, multi-tenancy, partitioning, and horizontal scaling. Supports HNSW, IVF, DiskANN, and GPU index types. SDKs for Python, Java, Go, and Node.js. Zilliz Cloud offers a managed version. A production-grade foundation for RAG pipelines and recommendation systems at enterprise scale.

open-sourceOpen Source
Marqo logo

Marqo

Embedding-first search and discovery engine for AI-powered product experiences.

Marqo is an open-source tensor search engine that combines embedding generation and vector search in a single API, removing the need to manage separate embedding pipelines and vector databases. Built for product discovery and multi-modal search, it lets teams index text, images, and structured data together, returning ranked results based on semantic similarity rather than keyword overlap.

freemium

Related Tools

Deep Lake

AI data runtime for multimodal datasets and vector search

Deep Lake is an open-source AI data runtime from Activeloop for storing, versioning, and querying multimodal data and embeddings. It fits teams building RAG, training, evaluation, or dataset-heavy agent workflows that need a bridge between vector search, structured metadata, and large image, text, audio, or video collections.

open-sourceOpen Source

SeekDB

AI-native state store with hybrid vector and full-text search

SeekDB is an open-source AI-native state store from the OceanBase ecosystem that combines MySQL-compatible data access with hybrid vector and full-text retrieval. It targets agent and AI application teams that need embedded or server deployment, copy-on-write style sandboxes, and searchable state without gluing together several separate storage layers.

open-sourceOpen Source

pgvectorscale

DiskANN-powered vector search extension for PostgreSQL

pgvectorscale is an open-source PostgreSQL extension from Timescale that complements pgvector with DiskANN-based approximate vector search. It is useful for teams that want faster embedding retrieval while keeping vectors, filters, and application data inside the Postgres ecosystem instead of adopting a separate hosted vector database.

open-sourceOpen Source
FAISS logo

FAISS

Library for efficient similarity search and clustering of dense vectors at billion-scale.

FAISS is Meta AI Research's open-source library for efficient similarity search and clustering of dense vectors. It implements approximate nearest-neighbor algorithms designed to scale to billions of vectors, with optimized indexes that fit in RAM and GPU acceleration for the largest workloads. Engineering teams use FAISS as the retrieval primitive underneath custom RAG pipelines, recommendation systems, and large-scale embedding search infrastructure.

free
VectorChord logo

VectorChord

High-recall Postgres vector search at billion scale

VectorChord is a Postgres extension from TensorChord that brings high-recall vector search to PostgreSQL. As the spiritual successor to pgvecto.rs, it combines IVF indexes with RaBitQ quantization to deliver Pinecone-class performance at billion-vector scale while keeping all data inside a single Postgres database — no separate vector store, no two-system sync, no rewrites when the workload grows.

open-sourceOpen Source
Infinity logo

Infinity

AI-native database for hybrid RAG retrieval

Infinity is an AI-native database from InfiniFlow that unifies dense vectors, sparse vectors, tensors, and full-text search in a single engine. Built for retrieval-augmented generation (RAG) at scale, it powers hybrid search workflows where lexical matching, semantic similarity, and reranking all happen against one storage layer instead of four loosely coupled services.

open-sourceOpen Source