Skip to main content

   kANNolo

Fast, compact approximate nearest neighbor indexes for dense, sparse and multi-vector embeddings, in Rust 🦀 with Python bindings.

kANNolo provides HNSW, IVF and two-stage (retrieve + rerank) indexes. Every index is generic over how the vectors are stored, so the same index serves f32, f16, Product Quantization, RaBitQ, learned-sparse and compressed-sparse data. The compiler specializes each combination, so there is no dynamic dispatch in the search loop. The storage, compression and distance layer is a separate library, Vectorium.

pip install kannolo

Why kANNolo

  • Faster and smaller than the reference implementations. On dense data:

    • Our HNSW is 1.6–2.8× faster than hnswlib, with an index 2.0–2.2× smaller and comparable build times, on four collections of 0.8M to 21M vectors.
    • On the same collections, our two-stage HNSW is 1.8–3.2× faster than hnswlib, with an index 1.7–2.0× smaller.
    • Our IVF indexes answer queries 1.2–4.1× faster than FAISS at the same accuracy, on two collections.

    On learned sparse data:

    • Our HNSW is 3.2–20.3× faster than PyANNs (winner of the Sparse Track of the NeurIPS 2023 Big-ANN challenge), with 3.1–3.7× less memory.
    • Our two-stage HNSW is 5.2–47.9× faster than PyANNs, with 2.9–3.3× less memory.

    kANNolo's sparse indexes are the most compact of all the state-of-the-art systems we tested, and the fastest graph indexes.

  • Dense, sparse and multi-vector through one API. Search any of the three representations, and combine them freely into two-stage pipelines with RerankIndex: for example, a sparse first stage reranked with multi-vector MaxSim.

  • Easy to use. Python bindings, a Rust library, command-line tools, documentation, examples and notebooks. If something is unclear, open an issue.

Numbers from our paper Modular and Efficient Approximate Nearest Neighbors Search with Vectorium and kANNolo (kANNolo 0.15.1, Vectorium 0.11.1), at 90–99% Accuracy@10. See Reproducing our papers.

When to use something else. On learned sparse retrieval, Seismic, an inverted index also built on Vectorium, is faster than any graph index, ours included. For multi-vector data, kANNolo works best as the reranking step of a two-stage pipeline with a single-vector first stage. For a dedicated multi-vector engine, see TACHIOM. kANNolo's indexes are in-memory and static, built once over a fixed collection: if you need disk-based indexes, or insertions and deletions after construction, look elsewhere for now.

Quick start (Python)

Dense, two-stage: an HNSW over 1-bit RaBitQ codes retrieves 100 candidates, and the f16 vectors rescore them.

import numpy as np
import kannolo

data = np.random.randn(100_000, 768).astype(np.float32)
index = kannolo.build(
    data,
    metric="ip",                                     # or "l2"
    # Encoders, with the code size of a d-dimensional vector:
    #   Plain("f32"), Plain("f16"), Plain("bf16"): 4d or 2d bytes (no compression)
    #   PQ(subspaces=M): M bytes, with M = 8, 16, 32, 64 or 128
    #   RaBitQ(bits=b): about b*d/8 bytes, with b = 1, 2, 4 or 8
    encoder=kannolo.RaBitQ(bits=1),
    index=kannolo.HNSW(),                            # defaults: m=32, ef_construction=200
    rerank=kannolo.Rerank(kannolo.Plain("f16")),
)

dists, ids = index.search(data[42], k=10, k_candidates=100, ef_search=100)
index.save("dense.idx")
index = kannolo.load("dense.idx")                     # the file records how it was built

Sparse: the first stage keeps the components that carry the top 60% of each vector's L1 mass, and the pruned-away residual restores the exact score when a candidate is rescored.

index = kannolo.build(
    "documents.bin",                             # seismic binary format, or numpy/scipy arrays
    encoder=kannolo.Blocked(),
    index=kannolo.HNSW(),
    transform=kannolo.L1Prune(60),
    rerank=kannolo.Rerank(kannolo.Plain("f16"), residual=True),
)
dists, ids = index.search((query_components, query_values), k=10, k_candidates=100, ef_search=100)

Every other composition (single-stage, Flat and IVF indexes, multi-vector and hybrid pipelines, cascades, graph compression, batch search) is one kannolo.build call, covered in docs/PythonUsage.md.

What's inside

Indexes HNSW · IVF (flat, HNSW or IVF centroid index; plain or residual clusters) · RerankIndex (any first stage + any rescoring dataset) · exact FlatIndex
Representations (from Vectorium) dense · sparse · multi-vector (as a rescoring stage)
Encodings (from Vectorium) f32, f16, bf16, 8/16-bit fixed point · Product Quantization · RaBitQ (1 bit) and extended RaBitQ (2/4/8 bits) · blocked sparse · DotPacking8 compressed sparse · multi-vector PQ and two-level PQ
Metrics inner product · squared Euclidean · MaxSim
Graph storage standard · permuted (cache-friendly node order) · compressed (StreamVByte + Elias–Fano; roughly halves the edges memory)
Interfaces Rust library · Python bindings · command-line build/search tools

Rust

[dependencies]
kannolo   = { git = "https://github.com/TusKANNy/kannolo.git",   tag = "v0.15.1" }
vectorium = { git = "https://github.com/TusKANNy/vectorium.git", tag = "v0.11.1" }
use kannolo::rerank::{DenseEncoder, DenseRerankConfig, DenseRerankIndex, RerankSearchParams};
use vectorium::distances::DotProduct;
use vectorium::vector::DenseVectorView;
use vectorium::Index;

// RaBitQ-ext 4-bit first stage, reranked on 8-bit RaBitQ-ext codes.
let (dim, data): (usize, Vec<f32>) = (768, vec![0.0; 768 * 1000]);
let mut cfg = DenseRerankConfig::new(DenseEncoder::RabitqExt { total_bits: 4 });
cfg.rerank_bits = 8;
let index = DenseRerankIndex::<DotProduct>::build(&data, dim, &cfg).unwrap();
let top10 = index.search(DenseVectorView::new(&data[..dim]), 10, &RerankSearchParams::new(100, 100));

The lower-level API composes the parts yourself: build an HNSW over any Vectorium dataset, swap its dataset for a compressed one, and wrap it in a RerankIndex:

type Rescoring = DenseDataset<PlainDenseQuantizer<f16, DotProduct>>;
type Codes = DenseDataset<RabitqQuantizer<DotProduct>>;

let graph: HNSW<Rescoring, Graph> = HNSW::build_index(exact.clone(), &build_config);
let first: HNSW<Codes, Graph> = graph
    .permute_and_encode::<PlainNeighbors>()               // cache-friendly node order
    .convert_dataset_into_ref(RabitqConfig::default());   // vectors -> 1-bit codes
let index = RerankIndex::new(first, exact);               // rescore on f16

Replacing Codes with a PQ or extended-RaBitQ dataset gives another index with no other change. The module docs of kannolo::rerank and kannolo::rerank_index have complete examples.

Always build with RUSTFLAGS="-C target-cpu=native". The distance kernels are plain Rust that the compiler vectorizes for your CPU, and without this flag they fall back to baseline SIMD.

Feature What it enables Default
cli Binaries: hnsw_build, hnsw_search, hnsw_rerank_{build,search}_{dense,sparse}, ivf_build, ivf_search No
multivec Multi-vector data (Vectorium's multi-vector encoders); in the Python bindings, multi-vector stages; with cli, also hnsw_rerank_search No
python PyO3 bindings, enabled automatically by maturin No
dense, sparse, ivf Which representations and index types the Python bindings compile (the Python build enables all of them; see Building a smaller library) No
RUSTFLAGS="-C target-cpu=native" cargo build --release                          # library only
RUSTFLAGS="-C target-cpu=native" cargo build --release --features cli           # + binaries
RUSTFLAGS="-C target-cpu=native" cargo build --release --features "cli,multivec" # + multi-vector

Binaries land in target/release/. docs/Binaries.md documents every flag.

Installing the Python package

pip install kannolo installs a prebuilt wheel with every index: dense, sparse, multi-vector, two-stage and hybrid. If no wheel matches your platform, pip compiles from source. A build from source can also leave out the representations you do not need, which gives a smaller library; see Building a smaller library.

For maximum performance, build from source for your CPU (requires Rust nightly via rustup; the repository pins the toolchain):

RUSTFLAGS="-C target-cpu=native" pip install --no-binary :all: kannolo

Development build (editable install from a clone):

git clone https://github.com/TusKANNy/kannolo.git && cd kannolo
pip install maturin
RUSTFLAGS="-C target-cpu=native" maturin develop --release                # as the published wheels
RUSTFLAGS="-C target-cpu=native" maturin develop --profile dev-python     # faster to compile

The dev-python profile splits the code into 16 codegen units. It compiles about 3x faster (under 3 minutes instead of about 8, on a 32-core machine), which helps while changing the code. However, LLVM can no longer inline across units, and search is about 2% slower.

For benchmarks and papers, always build with the release profile (--release or pip install, which use codegen-units = 1). import kannolo warns when the installed build is a dev-python one, and kannolo.build_profile tells which profile built it.

Documentation

Data formats: dense collections are .npy (float32), sparse collections use the Seismic binary format. scripts/ converts between the two.

Reproducing our papers

kANNolo keeps evolving, so this repository does not track the exact setup of any paper. The versions, configurations and instructions that reproduce the results of our papers are in papers_reproducibility.

📚 Bibliography

  1. Silvio Martinico, Franco Maria Nardini, Cosimo Rulli and Rossano Venturini. "Modular and Efficient Approximate Nearest Neighbors Search with Vectorium and kANNolo." arXiv:2611.03927. 2026. Submitted to Information Systems.
  2. Leonardo Delfino, Domenico Erriquez, Silvio Martinico, Franco Maria Nardini, Cosimo Rulli and Rossano Venturini. "kANNolo: Sweet and Smooth Approximate k-Nearest Neighbors Search." Proc. ECIR. 2025.

Citation

If you use kANNolo for your work (whether be it a research paper, dissertation, article, poster, presentation, or documentation), please cite our papers:

arXiv 2026 (submitted to Information Systems):

@misc{martinico2026modularefficientapproximatenearest,
      title={Modular and Efficient Approximate Nearest Neighbors Search with Vectorium and kANNolo},
      author={Silvio Martinico and Franco Maria Nardini and Cosimo Rulli and Rossano Venturini},
      year={2026},
      eprint={2611.03927},
      archivePrefix={arXiv},
      primaryClass={cs.IR},
      url={https://arxiv.org/abs/2611.03927},
}

ECIR 2025:

@InProceedings{10.1007/978-3-031-88717-8_29,
author =    "Leonardo Delfino and
             Domenico Erriquez and
             Silvio Martinico and
             Franco Maria Nardini and
             Cosimo Rulli and
             Rossano Venturini",
title =     "kANNolo: Sweet and Smooth Approximate k-Nearest Neighbors Search",
booktitle = "Advances in Information Retrieval",
year =      "2025",
publisher = "Springer Nature Switzerland",
pages =     "400--406",
isbn =      "978-3-031-88717-8"
}

Metadata

Release files for kannolo 0.18.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kannolo 0.18.1
File Size Uploaded Provenance Actions
kannolo-0.18.1.tar.gz 810.6 kB Without provenance Details for kannolo-0.18.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for kannolo 0.18.1
File Actions
kannolo-0.18.1-cp313-cp313-manylinux_2_39_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.39+ x86-64 Details for kannolo-0.18.1-cp313-cp313-manylinux_2_39_x86_64.whl
kannolo-0.18.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for kannolo-0.18.1-cp313-cp313-macosx_11_0_arm64.whl
kannolo-0.18.1-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details for kannolo-0.18.1-cp313-cp313-macosx_10_12_x86_64.whl
kannolo-0.18.1-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details for kannolo-0.18.1-cp312-cp312-manylinux_2_39_x86_64.whl
kannolo-0.18.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for kannolo-0.18.1-cp312-cp312-macosx_11_0_arm64.whl
kannolo-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details for kannolo-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl
kannolo-0.18.1-cp311-cp311-manylinux_2_39_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.39+ x86-64 Details for kannolo-0.18.1-cp311-cp311-manylinux_2_39_x86_64.whl
kannolo-0.18.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for kannolo-0.18.1-cp311-cp311-macosx_11_0_arm64.whl
kannolo-0.18.1-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details for kannolo-0.18.1-cp311-cp311-macosx_10_12_x86_64.whl
kannolo-0.18.1-cp310-cp310-manylinux_2_39_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.39+ x86-64 Details for kannolo-0.18.1-cp310-cp310-manylinux_2_39_x86_64.whl
kannolo-0.18.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for kannolo-0.18.1-cp310-cp310-macosx_11_0_arm64.whl
kannolo-0.18.1-cp310-cp310-macosx_10_12_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.12+ x86-64 Details for kannolo-0.18.1-cp310-cp310-macosx_10_12_x86_64.whl

Total release size: 51.9 MB

Release files / kannolo-0.18.1.tar.gz

Download URL kannolo-0.18.1.tar.gz
Size 810.6 kB
Tags Source
SHA-256 checksum
How to use checksums
547445e71b51ed81824860ad98664a158a305aca449d8d2381c5d82fa6e42f09
BLAKE2b-256 checksum
How to use checksums
18407f78bc413cf9821742e37104d8a918379a3967616ed5764713254c6acb60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp313-cp313-manylinux_2_39_x86_64.whl

Download URL kannolo-0.18.1-cp313-cp313-manylinux_2_39_x86_64.whl
Size 4.8 MB
Tags CPython 3.13 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
78dd7b51d3ba121f25e5f68dd195fb78055f09122d999522b91106650a5d07e1
BLAKE2b-256 checksum
How to use checksums
3bc44e4d89462e302bfa279e716cf5002cff54329e1c129e13be59974aba0698
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL kannolo-0.18.1-cp313-cp313-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
66f10e75496c8195d53e1fe1a0d524c34835f187b9989b824ca4a91a8cf0e48f
BLAKE2b-256 checksum
How to use checksums
c924b6bae95a908f488df1958a56e9213be3dfae5d5a4175da912efe97aa7cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp313-cp313-macosx_10_12_x86_64.whl

Download URL kannolo-0.18.1-cp313-cp313-macosx_10_12_x86_64.whl
Size 4.4 MB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
61208717312de707c6077d8160e71e17ec5f5b8061377a6f7eb6c801b0a2dc2d
BLAKE2b-256 checksum
How to use checksums
06733458cc8d04b871920c197af44924872702ded0f5d5d9800413e88472a8a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL kannolo-0.18.1-cp312-cp312-manylinux_2_39_x86_64.whl
Size 4.8 MB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
cd86d0d904b08096546c98eb02c9fde6a712823fd1110fd02a171a4e222102aa
BLAKE2b-256 checksum
How to use checksums
65a8c882d124778ce8dea826af212a8860cf73e5cf6da9a128e41232e05109c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL kannolo-0.18.1-cp312-cp312-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e34b8d84e697461c35713bd8dcfe4c34260e5f738ce0aa70bbd90a7daf489e88
BLAKE2b-256 checksum
How to use checksums
66652376160714af91dbbdf7179e283f20ec528764c01e79af7fe52e85d8b373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl

Download URL kannolo-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl
Size 4.4 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6c5f61e93268f2aeab5417955e2c134ef692384ac56170325b1a51d171235328
BLAKE2b-256 checksum
How to use checksums
fb674555f782d4d44dbcf873d65fd93b0750c61543b2dc01e894daf961c8948d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp311-cp311-manylinux_2_39_x86_64.whl

Download URL kannolo-0.18.1-cp311-cp311-manylinux_2_39_x86_64.whl
Size 4.8 MB
Tags CPython 3.11 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
3574a29175c60a16de00f00ed20b834b05e826f76fd9ac92d3ddd893697b301b
BLAKE2b-256 checksum
How to use checksums
44dcaaf6e86ea8e87057f02cdcf1ab691ee2ba9f37d294ecfe1e309042d63ffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL kannolo-0.18.1-cp311-cp311-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
395e286822c1ac219b9906df2a038363f06dd4fbb8b60b9666eec087d65d2e76
BLAKE2b-256 checksum
How to use checksums
0415fc76826746e3830c17d7cdbd15ff2c9ed3147b1f1a086ff38f71881be14a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp311-cp311-macosx_10_12_x86_64.whl

Download URL kannolo-0.18.1-cp311-cp311-macosx_10_12_x86_64.whl
Size 4.4 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a96fa0d51561af6b42c03ec0273c8b0aaedbac17d457a2e682caa7140e0c7ed5
BLAKE2b-256 checksum
How to use checksums
812a5f578849bfa1a2990d6f16aea5a1be4083aec4f3ba112ffb2490ea10d69e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp310-cp310-manylinux_2_39_x86_64.whl

Download URL kannolo-0.18.1-cp310-cp310-manylinux_2_39_x86_64.whl
Size 4.8 MB
Tags CPython 3.10 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
8041211b8e1828bd4163f6f25d66ad4bc909aac10b31868343fe11be4c72d95f
BLAKE2b-256 checksum
How to use checksums
02af5b16c8922a5b9a9dc664da083fecd55895d232b9a9c630a1375eb8be41aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL kannolo-0.18.1-cp310-cp310-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d510501917689691e6f86076dba2a5d05ecd5139cb1de47868cad887ea849ae0
BLAKE2b-256 checksum
How to use checksums
855e803a1c74bd73f51ca0ab4bdbefce678e1aa0751740fe623fea252f1e2f81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kannolo-0.18.1-cp310-cp310-macosx_10_12_x86_64.whl

Download URL kannolo-0.18.1-cp310-cp310-macosx_10_12_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
15fd8731fe432873aca1cb713bb3798ff707a5eab9dff87159510c5a496b7f10
BLAKE2b-256 checksum
How to use checksums
6d35493dbb4cf7bbf8c8e6aa0b05e70ce6fc7027922988e3afde043645fccdad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for kannolo 0.18.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.18.1 This release

13 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page