Skip to main content

Fast minimal implementation of HNSW maps for approximate nearest neighbors searches

Project description

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. 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

instant_distance-0.3.5-cp311-none-win_amd64.whl (262.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

instant_distance-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.5-cp311-cp311-macosx_10_7_x86_64.whl (327.2 kB view details)

Uploaded CPython 3.11 macOS 10.7+ x86-64

instant_distance-0.3.5-cp310-none-win_amd64.whl (262.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

instant_distance-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.5-cp310-cp310-macosx_10_7_x86_64.whl (327.2 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

instant_distance-0.3.5-cp39-none-win_amd64.whl (262.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

instant_distance-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.5-cp39-cp39-macosx_11_0_arm64.whl (311.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

instant_distance-0.3.5-cp39-cp39-macosx_10_7_x86_64.whl (327.5 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

instant_distance-0.3.5-cp38-none-win_amd64.whl (262.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

instant_distance-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.5-cp38-cp38-macosx_10_7_x86_64.whl (327.3 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

File details

Details for the file instant_distance-0.3.5-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 e18c7e7d7c337b82f6f413a61b5f40f509fafb8d390180939eacc146c683547e
MD5 5591b59c5ec5632ee38299f127001ca8
BLAKE2b-256 505389ca8e6a30a1825a8963bfa33cb6c4b9b3872bc182965a30aa4e11fab112

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b40c08bc27b02a1de2acf3c3f5995d64fdd9f20ab57674d392dc639fbe9b9aa
MD5 838006c54a263e90b0c6515a45364ccd
BLAKE2b-256 0766f0a14f50d71d59b08bb966f0d9fd9c30bbf57cdc7a9f6e02f2a7d59a09df

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5ac72d074219ece8291a89c46005180c4cee740812b21f27706c5c667a0e8c53
MD5 96d504b86943e6d39258e702660fa3fa
BLAKE2b-256 5cb8eefe7ebe44090aa3da54ab69d1a288f2410f698f46af685f37f98d0c8f7d

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 8d4870c1a7199a04c8d2b7ebb882c6a572e7a5f6cf0ec85fb35c61eca4d4c683
MD5 0a5dd680cee5f53cecb3356021bda654
BLAKE2b-256 b401898787807ba2f94f0ecd945e96763611b90a12c73a411ab4317ff165e44e

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fb1ac805cc9a3a4d12ec4ea5c47bbe7be17ddb0df2f7a5f48ae8e992ac8046e
MD5 fffaf500f939f3459ef5f6412c5e36e2
BLAKE2b-256 1abe98b8dbe0f80aea4621bac0b57999a3abd8f3f9df13c05d35014cfcf574f6

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 197d908c460569720e8b100cc43f0e59410dcc490399ba6233cac76780cfc088
MD5 301c9285a0ebd6a0ff8289bf804d1dc9
BLAKE2b-256 6313bd9d184e7e0de5251e18c01e897dbaa5b90d99435069153efc07d3b90917

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 81167fbe400ed0f1d6c23d99669d12bfe62faf84452129ae6c5710b5d50873a4
MD5 852dc059580f9c12869b059acc22fa11
BLAKE2b-256 b52cf8e53a0f975e4c80b2944d70b2ed16498310b6025e781ce15430c8b5a25e

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0aac98965e83df0da0164853e8f5ff2f71176b0440a3393a0ada48c76da98cb0
MD5 4bb691f1ee330c51eb99c8e01e40ce78
BLAKE2b-256 0449f6e3e6fc0cf29296183eaf9655c81c03a379f693deef706e50778e234615

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d086578c86303abdb709f4882dac5d83d70a34354eb2c4ccbcb31720eaa602a2
MD5 8e52e136332b179953de0352d3dd2abb
BLAKE2b-256 a79a4d14be5288cdf8d68b10ccecf2028692c7c2daacbae296505a1f6654ed35

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e7797db2103d13803443e84b7d649586cbfacc93202dfa75de7e17c3600e8d8d
MD5 4e4500b02f1af0b73a7cff4ef78e97ba
BLAKE2b-256 9322693907bb6fe8356f217f139a3d472fc83b122b21400b95efb0bcd82f8d3c

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 f0606c12eeacae03799ddf09370d3647b867f5a4db2de8d65f198ec9799503c5
MD5 e072686dee3634114d9f6e0ee346ef1c
BLAKE2b-256 a3571605c7e5898d8032260f7b0842b6b579d4a18a0ed7ec929abb02be4e2fe0

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 050281dddf4f363c2177d0655b175c7786b38065a43aa4faf6fa5a4034970d97
MD5 66773f662c9df7053066c62b45143f90
BLAKE2b-256 a15cbc3467aadde6b843d343aaeb260d69809a8f428983dccb1e945e0a560057

See more details on using hashes here.

Provenance

File details

Details for the file instant_distance-0.3.5-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.5-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2c998c668762d524236a4e17c64d28dcad3248c5964cb21cfa8f279a778f9a67
MD5 21c2885f36002c11833bb07fe44f179e
BLAKE2b-256 18c559685ad14f15e27453b09828073b5194476fc9974924264ee74f2de12b79

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page