52a6ca2dcd
Updates the requirements on [serde-big-array](https://github.com/est31/serde-big-array) to permit the latest version. - [Release notes](https://github.com/est31/serde-big-array/releases) - [Commits](https://github.com/est31/serde-big-array/compare/v0.4.1...v0.5.0) --- updated-dependencies: - dependency-name: serde-big-array dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.cargo | ||
.github | ||
.vscode | ||
instant-distance | ||
instant-distance-py | ||
.gitignore | ||
Cargo.toml | ||
LICENSE | ||
Makefile | ||
README.md | ||
cover.svg | ||
deny.toml |
README.md
Instant Distance: fast HNSW indexing
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. As one example, it can be used to make simple translations.
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