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.8.tar.gz (652.4 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.8-cp313-cp313-manylinux_2_34_x86_64.whl (948.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kannolo-0.4.8-cp313-cp313-macosx_11_0_arm64.whl (785.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kannolo-0.4.8-cp313-cp313-macosx_10_12_x86_64.whl (879.3 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kannolo-0.4.8-cp312-cp312-manylinux_2_34_x86_64.whl (949.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kannolo-0.4.8-cp312-cp312-macosx_11_0_arm64.whl (785.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kannolo-0.4.8-cp312-cp312-macosx_10_12_x86_64.whl (879.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kannolo-0.4.8-cp311-cp311-manylinux_2_34_x86_64.whl (951.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kannolo-0.4.8-cp311-cp311-macosx_11_0_arm64.whl (787.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kannolo-0.4.8-cp311-cp311-macosx_10_12_x86_64.whl (886.4 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kannolo-0.4.8-cp310-cp310-manylinux_2_34_x86_64.whl (951.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kannolo-0.4.8-cp310-cp310-macosx_11_0_arm64.whl (787.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kannolo-0.4.8-cp310-cp310-macosx_10_12_x86_64.whl (886.2 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kannolo-0.4.8.tar.gz
  • Upload date:
  • Size: 652.4 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.8.tar.gz
Algorithm Hash digest
SHA256 670c3965177105a0ebdff1a812720fdab935519095ae21017c3a2bcec88588d3
MD5 60e1335a8c113683d7ba50265c52d93f
BLAKE2b-256 3298ad915448fd28627e159524a8934f238282da919e2124196fb155a16ab1ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d1167c6427422b56995f2b722e01178ca82fb5da653fc4da15c23f4503e4fbf0
MD5 27f6717291490a4174e9876c5abab622
BLAKE2b-256 4e7de3ab8af45002d5c95da249ee69e6a6c0bd07f5facc9e71571091a575de06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81277adfff0e8dfcbaf19f703cbfe0a28d7c47b0d3d59d55bc465eaf214402a1
MD5 ee918d730d435aecd0f4a7c9e73df56c
BLAKE2b-256 3ac21e22595b0b31170247e4dcbe7ad14584367db2800b5ffc132f90532f03f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3e4dc9f9ce3bec3cce06a3b8a850f68ff1e68af2630af3ed3ebbd69ad515f8ab
MD5 6d121dbc06ddf526bfcdc6767848318f
BLAKE2b-256 ab99c9092a171066a0a8277031e43a6fe25ae334677e5208befc966e0a7523ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4aa0657900462a76ca5fc1b99d5da5873141548e6542fcdaffbb5af3bd5dfd2d
MD5 20e1b025565ab8d279f54747a716b7ce
BLAKE2b-256 259e70b926f0a0d8bf3fbc50310bd97d869d9852edf8076457477b75287ad55d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f19b71b1bfead5eeb80d97205711e4a5ac4d2ada6370914ccbdd0e61228b74e0
MD5 1e7061dbc6bff26cbad0f63f6a7651ee
BLAKE2b-256 918eeb145ffa7a99ec4fb166b0da2303ae4b27be0a7e81afe7c88812de9288d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 90201f99842b19a681677477f4c289bc0f65f83d47ebd18c6d5d170642b6dc1b
MD5 7079a2710d90cfb866ac9b52335051ff
BLAKE2b-256 aeefd8ad75056dbf1c5ccf05cb9f0330c4eb6310311bfb86b6a7baac6fb4ca88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2d0d28b2b2b7afd6f618817171e5fb451718feef2246a8601978037f31c13463
MD5 afa6baa1072ee4ffc80d7c7452738ef6
BLAKE2b-256 e2def1ad08200ab64c4188149e8b519a187f185a63598d69f5936dd5f99e0444

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fc59f392b504f720dd94532f4b0ce94f360be5c4f809d57354f72198adf813f
MD5 bab297a5c3260679910a4c3ad0ac55f5
BLAKE2b-256 aa0cb421d00083c208295271647e3f0fb17e2f7f8b9a2cac4b976f87b154c907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 539a958a4bcfa06481f35d0e2e65cbe1e3f324eb22afce278e705c0236102845
MD5 5f3ee5d024f65d769edb89424669cea3
BLAKE2b-256 c2f207dd2a0ccc8676c26a9fd4a46988a57159b04c213ac7ae0167623ce9a10b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 83d8defc8688bab7215668db1d4b4b4ea93d0459fecaa63d447a9c81e7f58896
MD5 678829203915e81a2d7d9113244a7958
BLAKE2b-256 b726a0b90fe311513128702b54f88f08b6d46740fa9d90f161f972a78a3c27e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0cd655177ce89d2f5570d06fee188ddc7bc3f905dda8eeae1a0a4be189564c0
MD5 7aaf539c06a5da9dceab4d7bba98f4b4
BLAKE2b-256 925a4afa7340ac0948845a5d836c3a3d442362368cd9da5d059f1cf061406d55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.4.8-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e9abdd00786f93b9f7dc871445dba1e0196adf223cce0347908aabc189070909
MD5 5aefa271731fec520aa3fcdf457ec725
BLAKE2b-256 07be83e7b35bdbe3bbd23a0c8b5e1d599d1ecbe188ee954410b63b054ee62b39

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