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

If a compatible wheel exists for your platform, pip will download and install it directly without compilation. If no compatible wheel exists, pip will automatically compile from source.

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:

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

This installs the package in your system/virtual environment site-packages.

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:
RUSTFLAGS="-C target-cpu=native" maturin develop --release

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 two feature flags:

Feature What it enables
python PyO3 bindings — activated automatically by maturin when building the Python wheel
cli CLI binaries in src/bin/ (hnsw_build, hnsw_search, hnsw_rerank_search)

Neither feature is active by default, so a plain cargo build --release compiles only the library crate. To build the CLI binaries, enable the cli feature:

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

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.4.9.tar.gz (652.3 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.4.9-cp313-cp313-manylinux_2_34_x86_64.whl (948.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kannolo-0.4.9-cp313-cp313-macosx_11_0_arm64.whl (785.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kannolo-0.4.9-cp313-cp313-macosx_10_12_x86_64.whl (878.9 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kannolo-0.4.9-cp312-cp312-manylinux_2_34_x86_64.whl (948.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kannolo-0.4.9-cp312-cp312-macosx_11_0_arm64.whl (785.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kannolo-0.4.9-cp312-cp312-macosx_10_12_x86_64.whl (879.0 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kannolo-0.4.9-cp311-cp311-manylinux_2_34_x86_64.whl (951.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kannolo-0.4.9-cp311-cp311-macosx_11_0_arm64.whl (787.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kannolo-0.4.9-cp311-cp311-macosx_10_12_x86_64.whl (886.1 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kannolo-0.4.9-cp310-cp310-manylinux_2_34_x86_64.whl (951.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kannolo-0.4.9-cp310-cp310-macosx_11_0_arm64.whl (787.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kannolo-0.4.9-cp310-cp310-macosx_10_12_x86_64.whl (886.0 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for kannolo-0.4.9.tar.gz
Algorithm Hash digest
SHA256 fb0096e8c4ae667d556fff780d548270801b5dd65a917e98e7c7785692236cb0
MD5 05c0aca05d90acff2480bc1fcbf869bc
BLAKE2b-256 253bd38df31a3e9b3f80c46a28897bf3cb4f26f32dac7199633ead6bfa23d8fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6974d0e7cf78b2d643ef68c1d915472ca22c93d22a4d6c2a9d52006569a9cd4a
MD5 e5e836fd5538b6186b14842a7e01133d
BLAKE2b-256 1e4a0d3fff0449a8f10f88d945b307fd93a79aa440bf6d45fa1fcf37bc46597d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5091be025d3a83e7566a9be5279af37010267ab96a431529cf55a4952821a1b1
MD5 1399072485a969034cae845c96966332
BLAKE2b-256 b32b8fe0c29d9b76fb6f58607768a526303a4b351d3615050f120fa85b3fcca9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3271e223612a348a482c19e3450e7e7caf1e2e2118b53eaec8a79b0fe4e89e66
MD5 9183e4331a64e5a0d1224440909e5d72
BLAKE2b-256 734ef78da470e2d4ed2fccd373102ed79b57e3080ae12a4653b7d30ac2afe2a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c1e437f589d695329ee8d08443fb551898b87207bef65f8e0b15de5764fd0f6b
MD5 cc121aff2274e42f35665b703269247f
BLAKE2b-256 c44979f01b12e8a152467527aee20ed463678bda28a6f923e6d25ab1e2b9a03a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 119fdd117f30bed7bca182185f549581e8bd4ebf3902dca8439ca493c17bf369
MD5 9909c6c1eef696b5cf71990af745ade8
BLAKE2b-256 c20413b3ab7691b0f4506e1c3137091c2bf4d9cdaf66d249285cfeda71b8a111

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 065064294df679bece371013f0aaa7e25a7987e8e03a836bb01ebb198608018b
MD5 07a37e5fecc772be044dce5d942a7423
BLAKE2b-256 6da3d656ea3068823078db4853ced07db7422923a4b740c6d411f08bbda193b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b45860ae94ddd6a75879c892dca21606f52c2696622da0dda8d1397a977c6f31
MD5 2ba458603e22e185d73db33a2733535c
BLAKE2b-256 35461710dd89f90bf50ea055929b361b6a3151b5268496057b0d4131a29e8f79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14e436b93ab1c63b31ca0ebe66731eb19c54f51d370019b922dd710eeb75a0b9
MD5 a7cc27e1c8976457b8caeb790a1a1b7f
BLAKE2b-256 8461370347f9757f5bb963d4af9e0811d916feaa95ed0e5bdc268e8da36f1646

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eea37c449897eb883fd8802781e4a96a81f20da3fe1e5583170d81bc90107555
MD5 bbb11c8c79c5c72f4398215ce07b6994
BLAKE2b-256 70cdc5861a57769535b64f365bc3a9e01534ef21e6fe60efe145bb7ab2f978cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7e0f277bd2f5ce186811918a00ce47ee1b5b125a2493601aa721e87a469c29e6
MD5 c21ab51577f1c50f6ea6e6266d6102cd
BLAKE2b-256 d6a59d0048b57529348b68cde33bd0af0175684f3e5b95ed6575305e17fb6c93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0436d0b7eb431ddbc563851b3e8c24f59283a55ff3e2991f4bb10f7c34e4ace
MD5 bc43d9a264b768a384bf4df2a17b6f3c
BLAKE2b-256 de68835587d072d678969f7ee9fecc956db7933430b0742afdcff824e5cbacc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.9-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 473161ed90b66b50048d3c3f840d5e6d05d427cb645c5c2ae094e69f6a4b0944
MD5 325d5f80f6ad2224e4e58cb34ee98bce
BLAKE2b-256 9d1ca1a4aa06e96b854656f4fe5ed8999890224e0c548fde97f2b282b991b84a

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