Fast approximate nearest neighbor searching in Rust, based on HNSW index
Go to file
dependabot[bot] 9ea727cdb8 Update pyo3 requirement from 0.13.2 to 0.14.1
Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.13.2...v0.14.1)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-05 15:22:58 +02:00
.cargo Initial version of Python bindings 2021-03-18 12:59:39 +01:00
.github Upgrade to GitHub-native Dependabot 2021-04-30 09:54:12 +02:00
.vscode First cut of python bindings update 2021-05-21 17:34:33 +02:00
instant-distance Add basic example and update README (#10) 2021-05-25 22:00:51 +02:00
instant-distance-py Update pyo3 requirement from 0.13.2 to 0.14.1 2021-07-05 15:22:58 +02:00
.gitignore Ignore .DS_Store cruft 2021-05-17 13:37:11 +02:00
Cargo.toml Initial version of Python bindings 2021-03-18 12:59:39 +01:00
Makefile Add Makefile to help with testing 2021-03-18 12:59:39 +01:00
README.md Fix crate name in README.md 2021-06-12 07:13:53 +02:00
cover.svg Add files via upload 2021-04-20 11:07:03 -07:00
deny.toml

README.md

Cover logo

Instant Distance: fast HNSW indexing

Build status License: MIT License: Apache 2.0

Instance Distance is a fast pure-Rust implementation of the Hierarchical Navigable Small Worlds paper by Malkov and Yashunin for finding approximate nearest neighbors. This implementation powers the InstantDomainSearch.com backend services used for word vector indexing.

What it does

Instant Distance is an implementation of a fast approximate nearest neighbor search algorithm. The algorithm is used to find the closest point(s) to a given point in a set.

Using the library

Rust

[dependencies]
instant-distance = "0.5.0"

Example

use instant_distance::{Builder, Search};

fn main() {
    let points = vec![Point(255, 0, 0), Point(255, 0, 0), Point(255, 0, 0)];
    let values = vec!["red", "green", "blue"];

    let map = Builder::default().build(points, values);
    let mut search = Search::default();

    let cambridge_blue = Point(163, 193, 173);

    let closest_point = map.search(&cambridge_blue, &mut search).next().unwrap();

    println!("{:?}", closest_point.value);
}

#[derive(Clone, Copy, Debug)]
struct Point(isize, isize, isize);

impl instant_distance::Point for Point {
    fn distance(&self, other: &Self) -> f32 {
        // Euclidean distance metric
        (((self.0 - other.0).pow(2) + (self.1 - other.1).pow(2) + (self.2 - other.2).pow(2)) as f32)
            .sqrt()
    }
}

Testing

Rust:

cargo t -p instant-distance --all-features

Python:

make test-python