Skip to main content

Python interface for the kANNolo library

Project description

kANNolo

kANNolo is a research-oriented library for Approximate Nearest Neighbors (ANN) search written in Rust 🦀. It is explicitly designed to combine usability with performance effectively. Designed with modularity and researchers in mind, kANNolo makes prototyping new ANN search algorithms and data structures easy. kANNolo supports both dense and sparse embeddings seamlessly. It implements the HNSW graph index and Product Quantization.

Python Installation

Quick start (prebuilt wheels)

For most users, this is the easiest option:

pip install kannolo

The prebuilt wheel includes dense and sparse HNSW indexes. If a compatible wheel exists for your platform, pip downloads and installs it directly. If not, pip compiles from source.

To use multivector reranking (SparseMultivecRerankIndex, SparseMultivecTwoLevelsPQRerankIndex), build from source with the multivec feature enabled (see Building from source below).

Building from source (maximum performance)

For maximum performance optimized to your CPU, build from source. Choose one of the two approaches below:

Shared Prerequisites

Both building approaches require Rust and nightly:

  1. Install Rust (via rustup):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Activate nightly:
rustup install nightly
rustup default nightly

Approach 1: Build from PyPI source

Compile and install directly from PyPI with CPU optimization (dense and sparse indexes only):

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

This installs the package in your system/virtual environment site-packages. For multivector reranking support, use Approach 2 instead.

Approach 2: Build from GitHub (development mode)

Clone the repository and build for development/modification:

  1. Clone and prepare:
git clone https://github.com/TusKANNy/kannolo.git
cd kannolo
  1. Create a virtual environment (recommended):
python3 -m venv ./venv
source ./venv/bin/activate  # On Windows: venv\Scripts\activate

Alternatively, use conda:

conda create -n kannolo python=3.11
conda activate kannolo
  1. Install maturin:
pip install maturin
  1. Build and install in editable mode:

    Dense and sparse indexes only (default, lighter build):

    RUSTFLAGS="-C target-cpu=native" maturin develop --release
    

    With multivector reranking support (SparseMultivecRerankIndex, SparseMultivecTwoLevelsPQRerankIndex):

    RUSTFLAGS="-C target-cpu=native" maturin develop --release --features multivec
    

Why use editable mode? Changes to Python code take effect immediately without reinstalling. Perfect for development and prototyping.

  1. Verify installation:
python -c "import kannolo; print('Successfully installed kannolo!')"

Rust

The crate exposes three feature flags:

Feature What it enables Default
multivec Multivector reranking indexes (SparseMultivecRerankIndex, SparseMultivecTwoLevelsPQRerankIndex) and the hnsw_rerank_search CLI binary No
python PyO3 bindings — activated automatically by maturin when building the Python wheel No
cli CLI binaries: hnsw_build, hnsw_search (combine with multivec to also get hnsw_rerank_search) No

If you want to compile the library only (dense and sparse indexes, no multivec, no binaries):

RUSTFLAGS="-C target-cpu=native" cargo build --release

If you want the CLI binaries hnsw_build and hnsw_search (dense and sparse):

RUSTFLAGS="-C target-cpu=native" cargo build --release --features cli

If you want multivector reranking in the library (adds SparseMultivecRerankIndex and SparseMultivecTwoLevelsPQRerankIndex):

RUSTFLAGS="-C target-cpu=native" cargo build --release --features multivec

If you want all CLI binaries including hnsw_rerank_search:

RUSTFLAGS="-C target-cpu=native" cargo build --release --features "cli,multivec"

The resulting binaries are placed in target/release/.

Details on how to use kANNolo's core engine in Rust 🦀 can be found in docs/RustUsage.md.

Details on how to use kANNolo's Python interface can be found in docs/PythonUsage.md.

Resources

Check out our docs folder for a more detailed guide on how to use kANNolo directly in Rust, replicate the results of our paper, or use kANNolo with your custom collection.

📚 Bibliography

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 License

The source code in this repository is subject to the following citation license:

By downloading and using this software, you agree to cite the under-noted paper in any kind of material you produce where it was used to conduct a search or experimentation, whether be it a research paper, dissertation, article, poster, presentation, or documentation. By using this software, you have agreed to the citation license.

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"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kannolo-0.6.0.tar.gz (656.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kannolo-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl (973.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kannolo-0.6.0-cp313-cp313-macosx_11_0_arm64.whl (762.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kannolo-0.6.0-cp313-cp313-macosx_10_12_x86_64.whl (898.2 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kannolo-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl (973.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kannolo-0.6.0-cp312-cp312-macosx_11_0_arm64.whl (762.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kannolo-0.6.0-cp312-cp312-macosx_10_12_x86_64.whl (898.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kannolo-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl (973.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kannolo-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (767.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kannolo-0.6.0-cp311-cp311-macosx_10_12_x86_64.whl (904.9 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kannolo-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl (974.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kannolo-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (767.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kannolo-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl (903.7 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file kannolo-0.6.0.tar.gz.

File metadata

  • Download URL: kannolo-0.6.0.tar.gz
  • Upload date:
  • Size: 656.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kannolo-0.6.0.tar.gz
Algorithm Hash digest
SHA256 674aa9317c869619a9d27b774d5f74eeb4f797d1e377f6cb4efb953fcbaa9cb6
MD5 13b674c81a87aba09d63710c40162814
BLAKE2b-256 cb2ac8ecb5466068c0b6a23179ce1b010066fc22780e9946000d74ef441ebb6c

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4de3e48bd26be1eade41ff7a9f25aeafc1e049837b1f175257c74af08f44b92a
MD5 33394a68696e43117abc521273fd1ad6
BLAKE2b-256 02881841cc5dc0f8ae01e7fa7ef09bcba9cfae79c96dcd1a4d10f01d74664624

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7d3a7250835b53dafa18b28c243cc9695e47ab2a5f5a6b44ae129f3942219b4
MD5 728bc26468f4c6d5e2aad0cc871e7fad
BLAKE2b-256 e8ebe558ef07ae479f0354c11d5280275d59051b9131cdeec96729c1b07e38c7

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 73eaa25fdaef06942c1f48f9c90741d56e93a5489881cc75c5a34eb9c8bd87a1
MD5 40afe84db4d298862f4802140e7fffe1
BLAKE2b-256 1b7239ccf021ad565ca1594d6c2bf58d02e6eb44f93818c3a8a667d4fd8fa22a

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8fa2bdfb3b9ff30cce213626c9c5b42a2a239566dc07425d5aaaf2bedb4443fe
MD5 276a00e7735aaaf3e4e460eba969f535
BLAKE2b-256 42a42b14ccc01412f6dcd7cec27bfe4ff8922c6ac9117421a73f07d23c00533a

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d8eb0aeb0ca9b1e3cbab4281a9c18a7c750ef7cb1ede07193287109e7d641a3
MD5 cff1ee1c7110e4fc8306f22bf798220a
BLAKE2b-256 72661d7864accd5898b9f443afcfc387722abd7fe5eb998a79cf8a855994cafb

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d4c75b4296985bcc8adcb508ba7933f5e880505f19c6ca6f30ca9306a11f3b91
MD5 6c3270b5d4248b2f439e721dd60184f0
BLAKE2b-256 e72c05252d2c308060b262418f78990c5791f246f88fd64453c79953b13c3065

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d17f96ec7dd0891cd7b33d69c7c02ad910c9a907ec16146dd82ced0ef3706a0c
MD5 161016cbe76e4bb96e81e9a9ea29d3d1
BLAKE2b-256 3346e68c1b7d763c7e28845ecdbcb1f80c749ba3db4aa0d8e3491b7ea9e0fff8

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59e1733a9dcdfc652b4395da3462e3e7a8703d01fa1f67c84aa09dc707f3e6d2
MD5 c36851b8bf7625a409162c0b22b38f8a
BLAKE2b-256 fb4848fde209b180b3e618d93aec3641ebfcde7fdf835783349f9dee372bd625

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 161ccd35f8d753091d5d6754cecb3a2f2c1f9159332ddfd23c3df2cdbd255a96
MD5 aa2441064aa452c4427e74c6cc4ca707
BLAKE2b-256 740ec00fa3ea6b155cb8f127c7b7f8e5717e75d5af3aed1ab71ffdca0020be34

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0d095a890bf489b00d37d8f12a528a47c1248e6cde313fa35486a8e3466b0d0b
MD5 3bd79930b615e30082a55b396c9b2efb
BLAKE2b-256 5b36e9d96aa1bcc26f0c1e0aede7e70f490f73bf8c329d85929ec4cdd7408c45

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26daa9dcedd81ec4520db810ba1a54563188b980b2cbaa9aaf1a9f3f40f0e8e7
MD5 9f91785f6608481b8c34c29eeea5ee93
BLAKE2b-256 5d4cca9de134ff71f889ba249d4fedcd6091a31c4f08eded96dbcdb194bf6204

See more details on using hashes here.

File details

Details for the file kannolo-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kannolo-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 30de8d230e2d479cbd503f2cfbcb9ebd947ee36354d92a918a96730e011f185d
MD5 cab2f618fe735891afe0d3311fb3cae6
BLAKE2b-256 7ae3d2a0ed328565d2922cae2bdd65d3ab23dd8147dd8c23a2f2843bb242982d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page