Fast minimal implementation of HNSW maps for approximate nearest neighbors searches
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for instant_distance-0.3.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 066458ab91ec91d19f8e47053e8dc8c7239e13cffbcec391f538554777aedcdd |
|
MD5 | 60da3c1382a60fdfca3b1ece2bd75c8e |
|
BLAKE2b-256 | 04faaec250ecb076a15f4404a689c8c0e16b2423bf3799271c9ab8769c0fc413 |
Close
Hashes for instant_distance-0.3.1-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef05d0c0c03e9aa44f5e9e8ef020d28883baa767eb3e89bc5861f524dc5b67bc |
|
MD5 | 24f4d5c500679aaf70a61387e48d63f6 |
|
BLAKE2b-256 | 25317f1579ce2ec92d34aec3011e1c8357f88d0966f4a17bb724199a2c4c4df7 |
Close
Hashes for instant_distance-0.3.1-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47bdf57ea0b03b28b7838c79859cdf214cae69bc1d59a0559d12098092fdd037 |
|
MD5 | 19a056c66225aace0ce84cd2ce0f4710 |
|
BLAKE2b-256 | 798a63147ccef5e851e33ec82b9bad8ad323bfa93e6786ae7c989e297ce6cf52 |
Close
Hashes for instant_distance-0.3.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4bacb57f0893ba5cad68c63f084aa94ec1dc139945109c82b455bb1972c631b |
|
MD5 | cc206f927e905d736b00343bc445d7a5 |
|
BLAKE2b-256 | 71973a2576ca052de6e97b038324eb1a8da497c0e12ac4798b9f12939ca5179e |
Close
Hashes for instant_distance-0.3.1-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c211e6e42a038d66238a2d051ab9fa0f50bcf5dcf9b741c810324c49fab9b33 |
|
MD5 | f01f6e50778002a2c82037f6d32d6089 |
|
BLAKE2b-256 | 113ffc11ef2ecb0c138fb41054f407d4090b6f069a5c585bc38bfe45bb57763c |
Close
Hashes for instant_distance-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d32e5ae88f4a45126de2f761dd124eb908307d471c46ee79e318417ebf9bb31 |
|
MD5 | 692c20b6cf5cd52362d1f41cb64a8732 |
|
BLAKE2b-256 | 04d1d71c6bd2674cbe8e6bc9c15e8621ddf6c09db2608fb8efc09d8a21792894 |
Close
Hashes for instant_distance-0.3.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 961f37e1c33e2a75363125671813cbbf0b262c5a25e4ea87fba491aebea53d54 |
|
MD5 | ffe5fd904599b2535b8e9afcd5486a3b |
|
BLAKE2b-256 | 36660c3c777200d57c5964d0653e3fafcfb981f66f08559129485df6f80e0f20 |
Close
Hashes for instant_distance-0.3.1-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88fba0454fd44fa3b6bcdab82bf39737267176490ba68ad9076a44d9af5ebeac |
|
MD5 | 4f90eea0709199ace7d229cdd0fd7e34 |
|
BLAKE2b-256 | 288640a188d4f87d6c34c4da728b6e89a78da77741f66ebe2445a50abbab0228 |
Close
Hashes for instant_distance-0.3.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c36492120573b53f2852ed8ce4f4b7a75480f7861ac3953c7ec8299d2da10df7 |
|
MD5 | 7fe24a85ddb62370742013bd7aef7b1d |
|
BLAKE2b-256 | 6671faffc21760cbdbfb8c45e8fc88d55c77ce8510a38d7f51706646e209229e |
Close
Hashes for instant_distance-0.3.1-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e9064a73982157425d4831f5ed3006b4c2f44e81e5fb22e909c5c61a13a8101 |
|
MD5 | 6fce66b53d07dfabd37389f261ca3fe7 |
|
BLAKE2b-256 | 7758e4392d21a8418ca04cef36503669317e5dd44dc0cb84a167bdc2bf82a87c |