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 Instant Domain Search 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(0, 255, 0), Point(0, 0, 255)];
    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.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (418.6 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (419.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp312-none-win_amd64.whl (248.8 kB view details)

Uploaded CPython 3.12 Windows x86-64

instant_distance-0.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (416.9 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp312-cp312-macosx_11_0_arm64.whl (359.2 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

instant_distance-0.3.6-cp312-cp312-macosx_10_12_x86_64.whl (365.3 kB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

instant_distance-0.3.6-cp311-none-win_amd64.whl (250.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

instant_distance-0.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (417.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp311-cp311-macosx_11_0_arm64.whl (359.2 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

instant_distance-0.3.6-cp311-cp311-macosx_10_12_x86_64.whl (365.7 kB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

instant_distance-0.3.6-cp310-none-win_amd64.whl (250.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

instant_distance-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (417.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp310-cp310-macosx_11_0_arm64.whl (359.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

instant_distance-0.3.6-cp310-cp310-macosx_10_12_x86_64.whl (365.6 kB view details)

Uploaded CPython 3.10 macOS 10.12+ x86-64

instant_distance-0.3.6-cp39-none-win_amd64.whl (251.2 kB view details)

Uploaded CPython 3.9 Windows x86-64

instant_distance-0.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (416.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp39-cp39-macosx_11_0_arm64.whl (359.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

instant_distance-0.3.6-cp39-cp39-macosx_10_12_x86_64.whl (365.7 kB view details)

Uploaded CPython 3.9 macOS 10.12+ x86-64

instant_distance-0.3.6-cp38-none-win_amd64.whl (250.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

instant_distance-0.3.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (416.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

instant_distance-0.3.6-cp37-none-win_amd64.whl (250.5 kB view details)

Uploaded CPython 3.7 Windows x86-64

instant_distance-0.3.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (417.2 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

Details for the file instant_distance-0.3.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a038d183ea429f9a5bc4c3808a491bbb8f50d8fcbf9313f8909dce5b9e4aef7
MD5 de221c7b133c8e7e5a46bb2f3c8e9166
BLAKE2b-256 4aa497f2ec9c4618b12eb782a4ff23d4073d5cafbb66ef28abd171ce3e1a2f29

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8fb96cfc53caf82e06d7a9636718f2bb40f4edb22ff8b82f0feaac248414a081
MD5 45954625f149907274bb7978a3e83f3e
BLAKE2b-256 4c69329204fed1d626f7006f2a0ee6b62c8a15f4f5bec7b9aaed3fe23786d13a

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 760fd27838b09eb2a9621591bba278c8dc2502adb87bc99a8c2d013576bb925d
MD5 41b011aea2d5941ac40391a96decfb81
BLAKE2b-256 ff179c1cf28eb313c025a8922b05aedd9464fcf8fe1f48f84a8bba6c1068c649

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6196b928c6f0cb4c9a9e4cb7b7246271316c75b087a73d8c371fd6838eec5226
MD5 b075efcfb0596bd8c5373dcc2ae0e93c
BLAKE2b-256 bd9a33387e6edcc6155245708dd74f3af809f5d632544428f10c28e6f159c129

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 73f855f3c69d33d86ad72527b21d436d7b144b7017050324a277991fe2638326
MD5 ecb3041641e44eebd53b6cbf3b77a128
BLAKE2b-256 6a3af68750749a17aab53d2326abcf835d272121c1834cb7eca950d54775c8c2

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 177caac109c6758512068857d516357df0809919e08b6e545fdc804473586373
MD5 9f9061484e0a85d41be9e3c3289ad41e
BLAKE2b-256 9064d1d694f3fdc9942f4aa4d8b72478183d83bdc4d02731de72408de3d8cf94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 e15dd2458c7d7da2201a80501e84aa12f3b1adb7920f6fd9d053645a9e689f1c
MD5 41a0656c8dfa92822047c0735bd6da3f
BLAKE2b-256 b24c574920e7ab729290715682ad4f31f0d64c657f4459350ba5f88f55484cda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64b3522937886a5e7c66fc57ab3867049d7d14bb3ae0aa3af07900cb4e8d6567
MD5 0cfb34114b0584e6152a2d0815c5dd39
BLAKE2b-256 cb91f3c976de65026091d2e2cc691c1bf8049385659ef6a7734327998c992405

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0aae0938bd5b5b4c11d54d2d56091649ec24444825595f270a96753fc5408d9d
MD5 b94afe0004c9466c9273d560c6251f3f
BLAKE2b-256 6d5dd1cab12af1005372319db9090850c536f2b644eb6ed3acb6fc26e2948b50

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9c517479f5361f7b49875736ab605f596a47285a03309e672f6ebf5a1d8203a9
MD5 fcca0e2ad2e8fff592e78f4611649f88
BLAKE2b-256 6f6f8a38f37a0f0480477c3665d88772fd2e104adc47c3f8ca81287c38100dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 9cfc25c27dec5c3f39a579bbc31782a856ffde4c1644cbd12ee806d9f29d36fd
MD5 5c6e945c5edba8b43b630df0e1b5dca9
BLAKE2b-256 d0ba0b312578bf9835e61fa5ee3b31f6113240490efd0ef8121b87e8f1452581

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a71e472549a45ef01bae1537c5f80da3ec1ac33f6374fd582c26925d58e14d8
MD5 6d960486a55bfb542a533963784744f9
BLAKE2b-256 c042f150368ad32ad22a7ac683e30a17d5ff37102d70761450b61fbc2abce342

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0df0fde56e9a8e3ae1df6af8fded2e5135c7f5ca55fad04f18716ca02a9c7e4d
MD5 f698ddec2022594b3b18457d27d50006
BLAKE2b-256 a4a3a00b278ced01e1b4a282d446659aa042821faf5b39d6fcd841bb77e52bf9

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 09b96f4d3e50ebe4ece0e2e54bedf155a132a2a3d2781fa979434cbe0764a29b
MD5 8ec19606d7e4b8abab56dbc5b74cd28e
BLAKE2b-256 153c810638ec2f53022a93b0fb949cd3a6d9108547c1cd2adcbe924cd588c8ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 1df9cb8f8c2d64be2d2e90533d9523affbe2644466635641162660ae1c519fed
MD5 c7a24a856910fb27734f607a08c8b506
BLAKE2b-256 f4934a1b3ad44b3e718efbac1ee4b3081f67183edb6f8b624acb521f11f6941b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54f2bf3f738c41e3ead47f0d8a89197ac09901ce7fb1b417362a34a2afe31e35
MD5 823e816c47800a37469eb238ca8869fc
BLAKE2b-256 be6f6961cc8418436f50ebbea32733dc0db4b4f3e21f8ba7f1a761e1a01b6c0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d051d6ba384c6437ed121ddceb7249e6d540c0e046f53ea9340cc201c93d3a06
MD5 4cfd86c5358eccb54cbf67ad6e343408
BLAKE2b-256 ffadc9222cfcfbe9f47c8bc78eb480b8a722f0ab7852e56610576e536e1cdc70

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 39bbc268960f1d803773eb08ddda859c8092e25399fbff7ff9dbedfb0039f8d9
MD5 4b8e0eef81e3f2a12cafacb49078e987
BLAKE2b-256 7cbcdc8a44f46cc057df164c060f952ba211fc37bcb700707f545d7a2e2cf772

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 2b08a70abd2bb367525bde0729f54f9e1671ff4a531341db6340c886dd269027
MD5 9d6e9f151720b07a13697008727abfe7
BLAKE2b-256 d36d263728a18fc4e384ecbdb74644e83e667df85bd3c59d4098ea44b7014be6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2294d31d7b3bb43fe7fc7fd0967ca2124337951af141bbb23ec9b8c8ee05dda
MD5 f371c46f716c0e87009a8d1963389483
BLAKE2b-256 780f544abb01480178965d72d0b7a749e120103f9f0af7964a5a3b1419dbb525

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 dc6b2bc4cf7fc7bafa6d1a2e628426887d0ea0032c4b9557f68d9dde14fc34d3
MD5 482001ff16dd3db84518bb0cc8e8d39d
BLAKE2b-256 717d46bf0ed09989be00e9f4ef776a358896cd5a59d27914ec2c4e326f265152

See more details on using hashes here.

File details

Details for the file instant_distance-0.3.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for instant_distance-0.3.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80eba42b2bbe63ebbe4155ca9d236d2b4400a24a7b6df5c8bc41990438b82f75
MD5 6cf106996b4b2b34b7790453e9c1cfe6
BLAKE2b-256 d934545b1c685e1eff829c8e8bdc6e334bb883410f59490900be9d8fbd612e5a

See more details on using hashes here.

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