# USearch

> Single-file similarity search and clustering engine for vectors across many languages

- Category: Retrieval & Knowledge (RAG) / Vector Databases
- Language: C++
- Licence: Apache-2.0
- Repository: https://github.com/unum-cloud/USearch
- Website: https://unum-cloud.github.io/usearch/
- Canonical page: https://ai-tldr.dev/tools/usearch/

## In short

USearch is an embedded similarity search engine for vectors, built around a single C++11 header and the HNSW algorithm for approximate nearest-neighbor search. It runs in-process inside your own application rather than as a separate server, so you create an index, add vectors, and query it directly from your code. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in C++ and licensed Apache-2.0.

## Overview

USearch is an embedded similarity search engine for vectors, built around a single C++11 header and the HNSW algorithm for approximate nearest-neighbor search. It runs in-process inside your own application rather than as a separate server, so you create an index, add vectors, and query it directly from your code.

It is aimed at developers who need to search over embeddings without standing up a full vector database. The same core ships with bindings for many languages, including Python, JavaScript, Java, Rust, C, C99, Objective-C, Swift, C#, Go, and Wolfram, and runs on Linux, macOS, Windows, iOS, Android, and WebAssembly.

Within the embedded / in-process vector category, USearch focuses on a compact codebase, few dependencies, and user-defined metrics. It supports half- and quarter-precision types such as bf16, e5m2, and i8, can view large indexes from disk without loading them fully into RAM, and handles on-the-fly deletions and relabeling.

## What it does

- HNSW-based approximate nearest-neighbor search from a single C++11 header library
- Bindings for many languages, including Python, JavaScript, Java, Rust, C, Swift, C#, and Go
- SIMD-optimized distance functions plus user-defined metrics with JIT compilation
- Half- and quarter-precision support (bf16, e5m2, i8) for memory efficiency
- View large indexes directly from disk without loading them entirely into RAM
- On-the-fly deletions, renaming/relabeling, and heterogeneous lookups

## Getting started

Install the binding for your language, then create an index, add vectors, and search. The example below uses the Python package.

1. Install the Python package

   Install USearch from PyPI.

```bash
pip install usearch
```

2. Index and search vectors

   Create an index with a fixed dimensionality, add a vector under a key, then search for the nearest matches.

```python
import numpy as np
from usearch.index import Index

index = Index(ndim=3)
vector = np.array([0.2, 0.6, 0.4])
index.add(42, vector)
matches = index.search(vector, 10)

assert matches[0].key == 42
```

3. Use another language (optional)

   USearch also ships as an npm package for JavaScript and as crates/packages for Rust, Java, C#, Go, and more.

```bash
npm install usearch
```

## When to use it

- Adding semantic or embedding-based search to an app without running a separate vector database server
- Nearest-neighbor lookup on edge or mobile targets, including iOS, Android, and WebAssembly
- Searching very large vector sets by viewing the index from disk instead of holding it all in RAM
- Domain-specific similarity (for example Genomics or Chemistry) using built-in binary metrics or custom user-defined ones
