Announcing Hora 0.1.0, an approximate nearest neighbor search algorithm library in rust

I'm glad to announce we have released Hora0.1.0, an approximate nearest neighbor algorithm library, which is written in rust. and focus on the approximate nearest neighbor search field, we have already implemented HNSW(Hierarchical Navigable Small World Graph Index) index, SSG(Satellite System Graph)index, PQIVF(Product Quantization Inverted File) index, BruteForceIndex, and other indexes are coming. and we use SIMD to accelerate the performance, make it blazingly fast.

our slogan is " hora search everywhere ", which means hora can be deployed in any OS platform, Including already supported PC OS, (Linux, Mac OS, Windows), will support portable device OS(IOS and android), and even will support embedded systems(no_std). and we would support many language bindings, including Python, Javascript, Java, Ruby, Swift, and R. thanks to the LLVM great portable feature, we can make it happen.

github: GitHub - hora-search/hora: 🚀 efficient approximate nearest neighbor search algorithm collections library written in Rust 🦀 .

homepage: https://horasearch.com/

you can find some demos on our homepage

we think rust is very suitable for computing applications, due to its "zero cost abstraction" and LLVM backend, and nowadays, rust community also improve its SIMD support these days, make our library can be as fast as faiss, even we don't use something like "BLAS".

ANN-benchmark is a famous ann benchmark framework, here is our benchmark result. you can see we are as fast as Faiss, and we don't use any other dependency like "BLAS" or "OpenMP" (we use rayon instead :D)

aws t2.medium (CPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz)

and hora has these features:

Performant : 1. SIMD-Accelerated (packed_simd), 2. Stable algorithm implementation, 3. Multiple threads design

Reliable and Productive : 1. Rust compiler secures all code, 2. Memory managed by Rust for all language libs such as horapy, 3. Broad testing coverage, 4. Well documented, 5. Elegant and simple API, easy to learn

Portable : 1. Support Windows, Linux, and OS X, 2. No heavy dependency, such as BLAS

Multiple Languages Support : 1. Rust, 2. Python, 3. Javascript

Multiple Distances Support : 1. Dot Product Distance, 2. Euclidean Distance, 3. Manhattan Distance, 4. Cosine Similarity

we are pretty glad to have you participate, any contributions are welcome, including the documentation and tests. We use GitHub issues for tracking suggestions and bugs, you can do the Pull Requests, Issue on the github, and we will review it as soon as possible.

rust code demo:
in Cargo.toml:

[dependencies]
hora = "0.1.0"

demo:

use hora::core::ann_index::ANNIndex;
use rand::{thread_rng, Rng};
use rand_distr::{Distribution, Normal};

pub fn demo() {
    let n = 1000;
    let dimension = 64;

    // make sample points
    let mut samples = Vec::with_capacity(n);
    let normal = Normal::new(0.0, 10.0).unwrap();
    for _i in 0..n {
        let mut sample = Vec::with_capacity(dimension);
        for _j in 0..dimension {
            sample.push(normal.sample(&mut rand::thread_rng()));
        }
        samples.push(sample);
    }

    // init index
    let mut index = hora::index::hnsw_idx::HNSWIndex::<f32, usize>::new(
        dimension,
        &hora::index::hnsw_params::HNSWParams::<f32>::default(),
    );
    for (i, sample) in samples.iter().enumerate().take(n) {
        // add point
        index.add(sample, i).unwrap();
    }
    index.build(hora::core::metrics::Metric::Euclidean).unwrap();

    let mut rng = thread_rng();
    let target: usize = rng.gen_range(0..n);
    // 523 has neighbors: [523, 762, 364, 268, 561, 231, 380, 817, 331, 246]
    println!(
        "{:?} has neighbors: {:?}",
        target,
        index.search(&samples[target], 10) // search for k nearest neighbors
    );
}
2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.