lsh-rs (Locality Sensitive Hashing)
Locality sensitive hashing can help retrieving Approximate Nearest Neighbors in sub-linear time.
For more information on the subject see:
- Introduction on LSH
- Section 2. describes the hash families used in this crate
- LSH and neural networks
Implementations
- Base LSH
- Signed Random Projections (Cosine similarity)
- L2 distance
- MIPS (Dot products/ Maximum Inner Product Search)
- MinHash (Jaccard Similarity)
- Multi Probe LSH
- Step wise probing
- SRP (only bit shifts)
- Query directed probing
- L2
- MIPS
- Step wise probing
- Generic numeric types
Getting started
use LshMem;
// 2 rows w/ dimension 3.
let p = &;
// Do one time expensive preprocessing.
let n_projections = 9;
let n_hash_tables = 30;
let dim = 10;
let dim = 3;
let mut lsh = new
.srp
.unwrap;
lsh.store_vecs;
// Query in sublinear time.
let query = &;
lsh.query_bucket;
Documentation
- Read the Rust docs.
- Read the Python docs for the Python bindings.
Python
At the moment, the Python bindings are only compiled for Linux x86_64 systems.
$ pip install floky
= 10000
= 100
= 10
# Generate some random data points
=
# Do a one time (expensive) fit.
=
# Query approximated nearest neigbors in sub-linear time
=
=