USearch

USearch and FAISS both employ the same HNSW algorithm.

Verified

Core facts

Read by a script from the official API, not rewritten by a model.

License
Apache-2.0
Languages
C++
Maintainer
unum-cloud
Verified

What it is

USearch and FAISS both employ the same HNSW algorithm. The project describes USearch as a simple and extensible single C++11 header library. The project says USearch is compact and broadly compatible without sacrificing performance, primarily focusing on user-defined metrics and fewer dependencies. HNSW does not require vectors to be identical in length.

Main features

  1. USearch lists SIMD-optimized metrics and user-defined metrics with JIT compilation.

  2. Large indexes can be viewed from disk without loading into RAM.

  3. USearch lists heterogeneous lookups, renaming/relabeling, and on-the-fly deletions.

  4. USearch is compatible with OpenMP and custom executors for fine-grained parallelism.

  5. USearch lists binary Tanimoto and Sorensen coefficients for genomics and chemistry applications.

  6. In USearch you can pass a predicate function to the search method, and it is applied directly during graph traversal.

Getting started

  1. The default storage and quantization level depends on the hardware, and the project recommends bf16 for most modern CPUs.

  2. You can pass pre-quantized buffers from NumKong with the explicit dtype parameter on add and search, or let USearch handle the quantization internally from higher-precision inputs.

  3. You can use Numba, Cppyy, or PeachPy to define a custom metric in Python.

  4. Built-in metrics return distances, so a smaller Match.distance means closer.

  5. The Haversine distance is available out of the box, and you can also define more complex relationships, like the Vincenty formula, which accounts for the Earth's oblateness.

  6. Similar to vector and molecule search, USearch can be used for Geospatial Information Systems.

From the README · py
# pip install usearch

import numpy as np
from usearch.index import Index

index = Index(ndim=3)               # Default settings for 3D vectors
vector = np.array([0.2, 0.6, 0.4])  # Can be a matrix for batch operations
index.add(42, vector)               # Add one or many vectors in parallel
matches = index.search(vector, 10)  # Find 10 nearest neighbors

assert matches[0].key == 42
assert matches[0].distance <= 0.001
assert np.allclose(index[42], vector, atol=0.1) # Ensure high tolerance in mixed-precision comparisons

Who it is for

USearch supports multiple forms of serialization. Serialization can target a file defined with a path. Serialization can target a stream defined with a callback, serializing or reconstructing incrementally.

Serialization can target a buffer of fixed length or a memory-mapped file that supports random access. Using USearch, one can implement sub-quadratic complexity approximate, fuzzy, and semantic joins. Instead of constructing one extensive index, you can build multiple smaller ones and view them together.

When quantization is enabled, the get-like functions cannot recover the original data. Quantizing to i8_t integers is only valid for cosine-like metrics. Quantizing to b1x8_t single-bit representations is only valid for binary metrics like Jaccard and Hamming.

Sources

This page is written from the official sources below. Open them to check the original text.

Verified ·

This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.