Fast hybrid vector search, built in Rust.

Dense and sparse retrieval in one index. Native multivector / ColBERT reranking. Embeddable as a Rust library or served over HTTP. Beats hnswlib on the recall–latency Pareto frontier up to 96% recall.

0.18ms
p50 latency
ef=32 · EC2
83.6%
recall
@ above config
0.440
macro nDCG@10
5 BEIR corpora

EC2NYT256 · 290K docs · 256-D angularm16+rcm+sq8ef=322026-10-01 full methodology

# Rust
cargo add annex

# Python
pip install ANNexDB

v0.3.0 · Apache-2.0 / MIT · one maintainer, actively developed

● returned   ○ exact neighbors  ·  5 of 6 found. The one miss is the dashed ring.


Capabilities

ANNex is a Rust-native embedded library with hybrid dense-sparse retrieval, multivector / late-interaction reranking, and WAL-backed persistence. Compare with the most commonly evaluated alternatives.

Feature ANNex Qdrant FAISS hnswlib
Dense vector search ✓ ✓ ✓ ✓
Sparse / BM25 ✓ ✓ ✗ ✗
Hybrid RRF fusion ✓ ✓ ✗ ✗
Multivector / ColBERT ✓ ✓ ✗ ✗
Payload filters ✓ ✓ ✗ ✗
Embedded (no server) ✓ ✗ ✓ ✓
HTTP server ✓ ✓ ✗ ✗
Rust-native library ✓ ✗ ✗ ✗
Python bindings ✓ ✓ ✓ ✓
Snapshots + WAL ✓ ✓ ✗ ✗
Detailed comparison: ANNex vs Qdrant → ANNex vs FAISS →

Performance

ANNex leads hnswlib across the full recall frontier from 83% to 96% recall on NYT256. The gap widens at higher recall targets — where the engineering cost of approaching exactness usually hurts most.

At 87% recall
2.2× faster
ANNex 0.30ms vs hnswlib 0.66ms
At 90% recall
2.6× faster
ANNex 0.47ms vs hnswlib 1.24ms
At 96% recall
3.4× faster
ANNex 2.70ms vs hnswlib 9.16ms
0.80 0.85 0.90 0.95 1.00 0.2ms 0.5ms 1ms 2ms 5ms 10ms p50 latency (ms, log scale) recall ANNex hnswlib M=16
NYT256 · 290K documents · 256-D angular · Apple M2 · 3 rounds · offset=1000. ANNex uses PQ screening and combined-stop filters at each operating point. Full data, raw results, and methodology →

Quickstart

Bring your own embeddings: ANNex stores and searches the vectors you give it. These three steps run as written against the published packages.

1

Build and search from Python

Build an index from a NumPy array, search it, and save it. No Rust needed.

Install
python -m pip install ANNexDB numpy
build_search.py
import annexdb
import numpy as np

# One row per item: your embeddings, float32.
vectors = np.array(
    [
        [0.9, 0.1, 0.0, 0.0],
        [0.8, 0.2, 0.1, 0.0],
        [0.0, 0.1, 0.9, 0.2],
        [0.1, 0.0, 0.8, 0.3],
    ],
    dtype=np.float32,
)

index = annexdb.Index.build(vectors, metric="cosine")  # row i gets id i

query = np.array([0.85, 0.15, 0.05, 0.0], dtype=np.float32)
ids, scores = index.search(query, k=3)
for i, s in zip(ids, scores):
    print(f"id={i} score={s:.4f}")

index.save("segment.bin")  # a snapshot Rust can load too
Output
id=0 score=0.0037
id=1 score=0.0044
id=3 score=0.8319

For cosine, the score is a distance (1 − cosine similarity), so lower is closer. dot is a similarity (higher is closer) and euclidean is squared distance (lower is closer).

The Python package does dense vector search: build, search, save and load. For hybrid search, payload filters and multivector search, use the Rust library (step 2) or the HTTP server (step 3).

2

Search and filter from Rust

Build a small cosine index, search it, filter on a payload field, and save a snapshot.

Cargo.toml
[dependencies]
annex = "0.3.0"
src/main.rs
use std::collections::HashMap;

use annex::{DistanceMetric, Filter, Payload, PayloadValue, Segment};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // A tiny 4-dimensional cosine index: M=16, ef=64 (the build width, also the default search width), level cap 16.
    let mut seg = Segment::with_config(DistanceMetric::Cosine, 16, 64, 16, 4);

    // (id, vector, topic): you bring the embeddings, ANNex stores and searches them.
    let docs = [
        (1, [0.9, 0.1, 0.0, 0.0], "pets"),
        (2, [0.8, 0.2, 0.1, 0.0], "pets"),
        (3, [0.0, 0.1, 0.9, 0.2], "cars"),
        (4, [0.1, 0.0, 0.8, 0.3], "cars"),
    ];
    for (id, vector, topic) in docs {
        let mut payload = Payload(HashMap::new());
        payload.set("topic", PayloadValue::Str(topic.into()));
        seg.insert_with_id(id, vector.to_vec(), Some(payload))?;
    }

    // Nearest neighbours of a query that looks like the "pets" documents.
    let query = vec![0.85, 0.15, 0.05, 0.0];
    for hit in seg.search(&query, 3)? {
        println!("id={} score={:.4}", hit.id, hit.raw_score);
    }

    // The same search, restricted by a payload filter.
    let cars = Filter::Match { key: "topic".into(), value: PayloadValue::Str("cars".into()) };
    println!("-- topic = cars");
    for hit in seg.search_with_filter(&query, 2, Some(&cars))? {
        println!("id={} score={:.4}", hit.id, hit.raw_score);
    }

    // Persist it. The Python bindings load this file.
    seg.save_to_path("segment.bin")?;
    println!("saved segment.bin");
    Ok(())
}
Output
id=1 score=0.0037
id=2 score=0.0044
id=4 score=0.8319
-- topic = cars
id=4 score=0.8319
id=3 score=0.9252
saved segment.bin

For cosine, the score is a distance (1 − cosine similarity), so lower is closer. Ids 1 and 2 are the near neighbours of this query.

Cargo.toml: annex = "0.3.0" also accepts later 0.3.x releases. The snapshot is the same format the Python package writes: Segment::load_from_path("segment.bin") opens the file from step 1.

3

Hybrid search over HTTP

Combine keyword (BM25) and vector search with a metadata filter in one request. Start the server, add three documents, query.

Start the server
# Install and start the HTTP server (compiles from source, so the first install takes a few minutes)
cargo install annex-multivector
annex-multivector --dimension 2 --centroids 2 --path ./data --listen 127.0.0.1:8080
Add documents (text, metadata and a dense vector each)
curl localhost:8080/v1/vectors/upsert -H 'content-type: application/json' -d '{"documents":[
  {"id":"runbook-e123","text":"E123 recovery procedure for the payments service",
   "metadata":{"team":"support"},"representations":{"semantic":{"kind":"dense","vector":[1,0]}}},
  {"id":"backup-restore","text":"How to restore a database from a backup",
   "metadata":{"team":"support"},"representations":{"semantic":{"kind":"dense","vector":[0.9,0.1]}}},
  {"id":"holiday-policy","text":"Office holiday schedule and leave policy",
   "metadata":{"team":"hr"},"representations":{"semantic":{"kind":"dense","vector":[0,1]}}}
]}'
Query: BM25 + dense, only team = support
curl localhost:8080/v1/retrieve -H 'content-type: application/json' -d '{
  "prefetch": [
    {"kind":"bm25","text":"E123 recovery"},
    {"kind":"dense","field":"semantic","vector":[0.95,0.05]}
  ],
  "filter": {"op":"eq","field":"team","value":"support"},
  "limit": 3
}'
Response (trimmed to id, score and sources)
{"matches": [
  {"id": "runbook-e123",   "score": 0.18181819,  "sources": [0, 1]},
  {"id": "backup-restore", "score": 0.083333336, "sources": [1]}
]}

runbook-e123 matches both the exact term "E123" and the vector, so both channels return it and it ranks first. backup-restore is found by the vector alone. holiday-policy is excluded by the filter.

sources lists which prefetch entries found each document (0 = BM25, 1 = dense). Scores are fused with reciprocal rank fusion (RRF). The full response also includes each document's text, metadata and a timing trace.

More: API docs on docs.rs · HTTP API reference · benchmarks · changelog


Is it for you?

Choose ANNex when

  • →You want an embeddable library: no server process, no network hop, integrated directly into your Rust binary.
  • →You need dense and sparse retrieval in one index, with hybrid fusion (RRF), payload filters, or multivector / ColBERT-style late interaction.
  • →You want snapshots and a write-ahead log built in, with Python bindings (NumPy batch search) for the read path.

Look elsewhere when

  • →You need a managed cloud service, SLAs or vendor support. ANNex is self-hosted only.
  • →You need distributed or sharded search across several nodes. ANNex is single-node.
  • →You need GPU acceleration, or a system hardened for production at scale. ANNex v0.3.0 is for development, evaluation and early-stage applications.

Errata & known gaps

These are real constraints, not caveats. If any of them are blocking for your use case, ANNex is probably not the right choice yet.

No managed cloud
ANNex is self-hosted only. There is no hosted offering or managed service. You run and operate it.
Single-node
No distributed or sharded mode. All data lives on one machine. Horizontal scaling is not supported in v0.3.0.
Production hardening in progress
ANNex is well-suited for development, evaluation, and early-stage applications. The benchmark policy and RESULTS.md are explicit about what has and has not been established.