#nearest-neighbor #min-heap #kannolo

nightly bin+lib kannolo

kANNolo is designed for easy prototyping of ANN Search algorithms while ensuring high effectiveness and efficiency over both dense and sparse vectors

5 releases

new 0.1.4 Apr 18, 2025
0.1.3 Apr 7, 2025
0.1.2 Apr 6, 2025
0.1.1 Apr 6, 2025
0.1.0 Apr 5, 2025

#600 in Algorithms

Download history 287/week @ 2025-04-02 33/week @ 2025-04-09

320 downloads per month

MIT license

530KB
9K SLoC

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 - Maximum performance

If you want to compile the package optimized for your CPU, you need to install the package from the Source Distribution. In order to do that you need to have the Rust toolchain installed. Use the following commands:

Prerequisites

Install Rust (via rustup):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Installation

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

This will compile the Rust code tailored for your machine, providing maximum performance.

Python - Easy installation

If you are not interested in obtaining the maximum performance, you can install the package from a prebuilt Wheel. If a compatible wheel exists for your platform, pip will download and install it directly, avoiding the compilation phase. If no compatible wheel exists, pip will download the source distribution and attempt to compile it using the Rust compiler (rustc).

pip install kannolo

Prebuilt wheels are available for Linux platforms (x86_64, i686, aarch64) with different Python implementation (CPython, PyPy) for linux distros using glibc 2.17 or later. Wheels are also available x86_64 platforms with linux distros using musl 1.2 or later.

Rust

This command allows you to compile all the Rust binaries contained in src/bin

RUSTFLAGS="-C target-cpu=native" cargo build --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 more detailed guide on use to use kANNolo directly in Rust, replicate the results of our paper, or use kANNolo with your custom collection.

Disclaimer: The results in the paper are obtained with a direct-access table shared among threads to keep track of visited nodes. In the current version, this is substituted with a hash set, with the double goal of simplifying the code for users and to make it independent of the size of the dataset, a feature that one would like to enable when dealing with large datasets. This may affect performance.

📚 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. To Appear.

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.

arXiv

@article{delfino2025kannolo,
  title={kANNolo: Sweet and Smooth Approximate k-Nearest Neighbors Search},
  author={Delfino, Leonardo and Erriquez, Domenico and Martinico, Silvio and Nardini, Franco Maria and Rulli, Cosimo and Venturini, Rossano},
  journal={arXiv preprint arXiv:2501.06121},
  year={2025}
}

Dependencies

~86MB
~1M SLoC