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.5.5.tar.gz (654.6 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.5.5-cp313-cp313-manylinux_2_34_x86_64.whl (907.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kannolo-0.5.5-cp313-cp313-macosx_11_0_arm64.whl (745.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kannolo-0.5.5-cp313-cp313-macosx_10_12_x86_64.whl (838.5 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kannolo-0.5.5-cp312-cp312-manylinux_2_34_x86_64.whl (907.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kannolo-0.5.5-cp312-cp312-macosx_11_0_arm64.whl (745.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kannolo-0.5.5-cp312-cp312-macosx_10_12_x86_64.whl (838.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kannolo-0.5.5-cp311-cp311-manylinux_2_34_x86_64.whl (908.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kannolo-0.5.5-cp311-cp311-macosx_11_0_arm64.whl (750.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kannolo-0.5.5-cp311-cp311-macosx_10_12_x86_64.whl (839.5 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kannolo-0.5.5-cp310-cp310-manylinux_2_34_x86_64.whl (908.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kannolo-0.5.5-cp310-cp310-macosx_11_0_arm64.whl (750.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kannolo-0.5.5-cp310-cp310-macosx_10_12_x86_64.whl (840.0 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for kannolo-0.5.5.tar.gz
Algorithm Hash digest
SHA256 45ed71c52d4d36023ac1639e3a5dc6df2e44ce624990f707e6446e2f7d1b6bea
MD5 3e5089215402579b8f5fb7bf4612f277
BLAKE2b-256 09e564ad96422f99d039815bb7c2a012969291308c2fd635f29b772128596ed5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4b18717b949857ae01bd7e700a14d04c6822172818100ab7fc530722d59351d3
MD5 769dc5a7e251dd2bda6851debf173761
BLAKE2b-256 9e82da600095b9cfa914d62533dd6969bdc3340e4314e6cc55f13160542913e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58b9c0e0e3dae99f84303fb2b6bf20f9fa111e85ae6e0ade5a04b09a6b80064b
MD5 e7d23df3f0f2ee22e2b1d92df5a732d9
BLAKE2b-256 3f11e325c1c74fb121ef909c8c30d326cecde38fc1d3997131eb415515ba4d18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4bf013daaa297686dec166d6d4b7ee4c7c9625aa9ce8aa32bc35a19e63ce020a
MD5 9aabfa0b7a93ec48ec04a6cb28dcfb6c
BLAKE2b-256 babb5f1e81b772de83a0f536e17218735307e9b73c94c01e8571c03b9ae1777d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 45a55358608dd4e8e3902c1c54a6018b852eb938da82ac8175de5c2bb847c0a5
MD5 c8cdb6613730a3ed62b75a5cd1096669
BLAKE2b-256 33fe772986de4665facd6742d96c8afcd25b70d20b86cefe1bf9d02c39937083

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1a6de83b3e133f33e8482c862158333c53e37a19b8f49adb8a6d0fe449a9d69
MD5 60b8525d4b06c9a9ee537b9d3a43000d
BLAKE2b-256 061a1edb6b23da51043089b5e45adb877416980a72902095f68fd46a2a1da1b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6335ab4afd765e7683402aade381941c94931e594392abda6069b7085228bd36
MD5 987b85d67af83018082f439bdac35581
BLAKE2b-256 030969c0e6fef38e27e59fb224e58cc513daa098518ee53c08a4d70f3e3a6c47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3c36560afd216b6eac114b25f5dcf7050cfcba2e3ee825462d7af2c87e9f38b0
MD5 1b341f7d354dcb1144865d60f02fa8bb
BLAKE2b-256 c3fdc200c879769655df5004a175a61402a2f1497cf2fb630a162af8b761e28e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d12bb033307421935e60b78a2aa3ef25351d7ec959424186b1ae482ab1247d4
MD5 703851002a7c2931a9f33a105c5833c1
BLAKE2b-256 68931c6229eb4268fd5dd0a5349f61153584fc6d9c2e9b73cad23fd3fe79bea2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 82e02325dd660b8fa6cc04790da7e6953a2efb66f369c899a3d81f9fc6357077
MD5 18b6dba0be303f4a8c2b3901fc6845b9
BLAKE2b-256 f0cd36065f35e37ac03b4cfbe507ec4a45a534114cf89090b8b1880a309ba299

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 39cad5e7f158dd8be04f9562fd897fa652f55fdc8d4eab06933e18dcd2fc552a
MD5 1fdb8734df5dd7167296cf3d0a675207
BLAKE2b-256 e1f35df4974c14332669bc23a961153f3b608599b9d11425f1a74181d327a9bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b75aa6d361b4df440b0446c4104547af2402f83eec2f260ff8b115b519eed8f
MD5 2308884debd4a7d398cb92522ac5bd38
BLAKE2b-256 918295c81199efb26b563b0ec89a0eec527f978fda4c23ec0a782286d9204f53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kannolo-0.5.5-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 002867cdb08abe3d226810173e33ac96eb5c005d59f13fbfe9373a1d41134f59
MD5 7412f5c123ce0ab79354ffe302aa070f
BLAKE2b-256 6c619b0d1e89141dc6e6205addc642748d27fa9a0882b5dffaca82cc975f8457

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