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
from kannolo import DenseRerankHNSW

data = np.random.randn(100_000, 768).astype(np.float32)
index = DenseRerankHNSW.build_from_array(
    data.flatten(), dim=768, metric="dotproduct",
    m=32, ef_construction=200,
    encoder="rabitq",            # or "pq", "rabitq-ext"
)

query = data[42]
dists, ids = index.search(query, k=10, k_candidates=100, ef_search=100)
index.save("dense.idx")

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.

from kannolo import SparseRerankHNSW

index = SparseRerankHNSW.build_from_file(
    "documents.bin",             # Seismic binary format
    prune_percentage=60.0, residual_rerank=True,
    m=32, ef_construction=500,
)
dists, ids = index.search(query_components, query_values, k=10, k_candidates=100, ef_search=100)

Single-stage indexes (DensePlainHNSW, DensePQHNSW, SparsePlainHNSW, …), flat indexes, batch search, graph compression and early termination are 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 reranking (SparseMultivecRerankIndex, SparseMultivecTwoLevelsPQRerankIndex); with cli, also hnsw_rerank_search No
python PyO3 bindings, enabled automatically by maturin 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, two-stage and sparse + multi-vector reranking. If no wheel matches your platform, pip compiles from source.

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

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.17.0

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.17.0
File Size Uploaded Provenance Actions
kannolo-0.17.0.tar.gz 774.4 kB Without provenance Details for kannolo-0.17.0.tar.gz

Built distributions (wheels)

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

Total release size: 21.3 MB

Release files / kannolo-0.17.0.tar.gz

Download URL kannolo-0.17.0.tar.gz
Size 774.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e5ecbd2b2c28e69a0a5951b8cc47da05bd4095c70f59ae84e52df6e05cf886a0
BLAKE2b-256 checksum
How to use checksums
f1ce19ba059409fc6952625cc93e4717ed9d73ff830212b6aedb81b7aec8f909
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.17.0-cp313-cp313-manylinux_2_39_x86_64.whl

Download URL kannolo-0.17.0-cp313-cp313-manylinux_2_39_x86_64.whl
Size 1.9 MB
Tags CPython 3.13 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
6671b7017d94c02f06061dc0c7d287efff6d3521d6cc20749fa2cbb4f121f8c4
BLAKE2b-256 checksum
How to use checksums
b0c1d0e74469be52534609538f3b7a2f62a5d77708986e9adf464efc38ca8102
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.17.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL kannolo-0.17.0-cp313-cp313-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3d9dd9fecd0b603b49d75737d5dad50ef7169a726357b101c324f217897bd24a
BLAKE2b-256 checksum
How to use checksums
5163cdaddbdfab33dde67e21e7b255d8e3e359266fb3a2aa274df1f96d8507a4
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.17.0-cp313-cp313-macosx_10_12_x86_64.whl

Download URL kannolo-0.17.0-cp313-cp313-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4a18826ffa51b5a1a6854fd34e5cd312a7304a4d99d350a2817a9845679788f2
BLAKE2b-256 checksum
How to use checksums
7847c57457303ce88c4fc9d03dcf9fbcc155d8776f8dba5fb1563cdd9773c17b
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.17.0-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL kannolo-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
58c4205831b2683d2ebc94da9e74695e913d48ad9b1a807f54ad4abdd9c051d2
BLAKE2b-256 checksum
How to use checksums
dbc1750e24c24d6d3c81616b9bbab7a7a4a2d317318554f10ceb7ad79b1f3d75
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.17.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL kannolo-0.17.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1bd705e58a8921ba3adf23f3292347664462ed6684ea8aa19db0a9d892cde1e2
BLAKE2b-256 checksum
How to use checksums
b34d70351e6580d00f633a97be264e8c93d87df0dc412357df6b679950aa9e66
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.17.0-cp312-cp312-macosx_10_12_x86_64.whl

Download URL kannolo-0.17.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
67cb070248586ca3b96d9f657e428b429faed32c7507f09a9b8be6de120a13fd
BLAKE2b-256 checksum
How to use checksums
d5ae3ab7fdae22ed3ff2d503f6d4cee1d607f4d8b4400451aa87ce92c40d9dcf
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.17.0-cp311-cp311-manylinux_2_39_x86_64.whl

Download URL kannolo-0.17.0-cp311-cp311-manylinux_2_39_x86_64.whl
Size 1.9 MB
Tags CPython 3.11 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
3653a030592fc4e90c285137babdaead778a37d196253e5edd438f818f1e2b51
BLAKE2b-256 checksum
How to use checksums
2ff34a4b6d9a350b4737ec2c577a2acf67386a841b3a0cbc740eb304634286c6
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.17.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL kannolo-0.17.0-cp311-cp311-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
84eb1c7a8220d5e3643b8553d5aa2c941862bd3d5b9a27db51cff78a101829d5
BLAKE2b-256 checksum
How to use checksums
97ab0ef7f6969bda0b50cb85ef0cfc5665e68e98b65a50bb831aaa105c8ec981
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.17.0-cp311-cp311-macosx_10_12_x86_64.whl

Download URL kannolo-0.17.0-cp311-cp311-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8b6db2c838c091bafc8415028a5fca3732986381ea121f57837ae8aeba7ca4a4
BLAKE2b-256 checksum
How to use checksums
c5c80c82731e5bf957c74fb9feefce4c240c13707f57df6b65f5c98e9da65940
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.17.0-cp310-cp310-manylinux_2_39_x86_64.whl

Download URL kannolo-0.17.0-cp310-cp310-manylinux_2_39_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
6989329e743193adbccd38943276b7b41a3df4fd90802b85842861ee1928aa56
BLAKE2b-256 checksum
How to use checksums
30a8938c8622303b361e22b34f4a0a19cec3f40773da27fb3ea38e0516ce159c
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.17.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL kannolo-0.17.0-cp310-cp310-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f95b240efb957bb43c81dcf7028c32e3ceb14c9b519f3faad3ec153bff5feb5d
BLAKE2b-256 checksum
How to use checksums
8c2e27dee57afa310b7f963c090efbbae114a211d0e511522b90d60af2cf7ff0
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.17.0-cp310-cp310-macosx_10_12_x86_64.whl

Download URL kannolo-0.17.0-cp310-cp310-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bb3fb73dedd7d309c37251d96d47b4ae70ef18d0eb868414ef4a8e71f2550c43
BLAKE2b-256 checksum
How to use checksums
80343dadf7785234526790acf4d348121e58ac8d88cd8e70ac0eb931e8b0ed28
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.17.0

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.17.0 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