Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fast approximate nearest neighbor searching in Rust, based on HNSW index

License

NotificationsYou must be signed in to change notification settings

djc/instant-distance

Repository files navigation

Cover logo

Instant Distance: fast HNSW indexing

Build statusLicense: MITLicense: Apache 2.0

Instance Distance is a fast pure-Rust implementation of theHierarchicalNavigable Small Worlds paper by Malkov and Yashunin for findingapproximate nearest neighbors. This implementation powers theInstant Domain Search backend services used for word vector indexing.

What it does

Instant Distance is an implementation of a fast approximate nearest neighborsearch algorithm. The algorithm is used to find the closest point(s) to a givenpoint in a set. As one example, it can be used to makesimple translations.

Using the library

Rust

[dependencies]instant-distance ="0.5.0"

Example

use instant_distance::{Builder,Search};fnmain(){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);letmut 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)]structPoint(isize,isize,isize);impl instant_distance::PointforPoint{fndistance(&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))asf32).sqrt()}}

Testing

Rust:

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

Python:

make test-python

About

Fast approximate nearest neighbor searching in Rust, based on HNSW index

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp