USearch
Smaller and faster single-file vector search and clustering engine
Repository Health
Technical Analysis
USearch is a compact, high-performance vector similarity search and clustering engine built around a single-header C++11 HNSW implementation, with idiomatic bindings for many languages including Rust. It focuses on being smaller and faster than alternatives like FAISS while remaining simple to embed.
The engine supports SIMD-accelerated and user-defined distance metrics with JIT compilation, half- and quarter-precision quantization, memory-mapped indexes that can be viewed from disk without loading fully into RAM, on-the-fly insertions and deletions, and heterogeneous lookups — making it suitable for semantic search, recommendations, genomics, and other approximate-nearest-neighbor workloads.
What You Get
- A fast HNSW approximate-nearest-neighbor index with add/search/remove operations
- SIMD-optimized built-in metrics plus support for user-defined distance functions
- Half- and quarter-precision quantization (bf16, i8) to shrink index memory
- Memory-mapped indexes that can be served from disk without full RAM loading
- A single-file, dependency-light core with bindings across many languages
Common Use Cases
- Semantic search over text or image embeddings
- Powering recommender systems with nearest-neighbor lookups
- Clustering and deduplicating large vector datasets
- Similarity search in genomics/chemistry using binary Tanimoto/Sorensen metrics
Under The Hood
Architecture — The engine’s core is a single-header C++11 HNSW implementation under include/, and the Rust crate (rust/lib.rs) is a thin, safe wrapper over a C++ shim (rust/lib.cpp/lib.hpp) bridged through the cxx FFI layer, compiled by build.rs/cxx-build. The same core is exposed to a dozen languages (python/, javascript/, java/, golang/, csharp/, swift/, c/, wasm/, sqlite/), so the Rust binding is one facade over shared index, metric, and serialization logic.
Tech Stack — Rust (edition 2024) using cxx for C++ interop, with an optional numkong SIMD kernel dependency and simsimd/openmp feature flags; the underlying engine is SIMD-optimized C++ with JIT-compiled user metrics. Dev tests use fork_union, rand, and rand_chacha.
Code Quality — USearch is mature and heavily adopted (trusted by ClickHouse, DuckDB, and others), with benchmarks (BENCHMARKS.md), concurrency tests, CI across many platforms, and thorough documentation. The multi-language surface is kept consistent through the shared C++ core.
API Design — The Rust API is concise: build an Index from options (metric, dimensions, connectivity), then add, search, and remove by key. Quantization and disk-backed views are opt-in, keeping the common path simple while exposing advanced tuning for performance-critical use.