Skip to content

thaiMao/small_knn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

small_knn

CircleCI

This library is an approximate K-nearest neighbor search based on Hierarchical Navigable Small World (https://arxiv.org/pdf/1603.09320.pdf).

Usage

  • Set customizable parameters.
let mut knn = HNSW::<DIMENSIONS, f32>::default()
    .set_distance(Distance::Euclidean)
    .build();
  • Insert data.
knn.insert(0, [1.0, 1.0]);
knn.insert(1, [2.0, 2.0]);
knn.insert(2, [10.0, 5.0]);
knn.insert(4, [11.0, 15.0]);
  • Search for neighbors.
let neighbors = knn.search_neighbors::<K>([2.1, 2.1]);

// Returns the index of the nearest neighbours
assert_eq!(neighbors.unwrap(), [1, 0]);

Design goals

The goal is to carry out a similarity search for a fixed number (K) of nearest neighbors for a given query without incurring additional allocations during search.

Documentation

TODO

License

This project is licensed under the MIT License.

About

An approximate K-NN written in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages