Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use for vanilla K,L LSH with precomputed hashes #1

Closed
paul-sud opened this issue Apr 28, 2020 · 6 comments
Closed

How to use for vanilla K,L LSH with precomputed hashes #1

paul-sud opened this issue Apr 28, 2020 · 6 comments

Comments

@paul-sud
Copy link

Hello,

I'm curious to see if I can get this to work with plain K, L parametrized LSH. The setup is that I already have L Vecs each with K (u32) hashes of the input sample, which I'd like to be able to feed directly into the LSH. The LSH hasher in this case then only queries for exact matches in each of the L hash tables and returns the union of all matches across all tables.

Is such a setup possible using the current API?

Thanks,

Paul

@ritchie46
Copy link
Owner

Hmm.. The LSH struct does need to know about your hashing function to be able to query. If you have a hashing function, you can implement the VecHash trait for that hashing function. The .hash_vec_query and .hash_vec_put functions are probably the same hashing function (they only differ for asymptotic LSH). Then you can instantiate a new LSH struct with your CustomHasher:

let mut lsh: LSH<MemoryTable, CustomHasher> = LshMem::new(n_projections, n_hash_tables, dim)

Does that help your case?

@paul-sud
Copy link
Author

Thanks, that's definitely a good starting point, although my inputs are &[u32], not &[f32] per the trait. I guess I can just cast though.

@ritchie46
Copy link
Owner

Yeah.. for now, I don't feel the extra complexity of generic inputs weighs up against an easy cast. :)

@paul-sud
Copy link
Author

I wholeheartedly concur, I tried futzing with the source to make the trait generic and it got complicated very quickly. Thanks again for the help.

@ritchie46
Copy link
Owner

In case you are still interested. After some sweat, the crate is now generic for most numeric types. #3

@paul-sud
Copy link
Author

paul-sud commented May 2, 2020

In case you are still interested. After some sweat, the crate is now generic for most numeric types. #3

That's great news! I actually realized at some point that the particular hashing method I was using is incompatible with the LSH data structure in this crate, since the hashers can't execute independently. I do have other ideas where the generics would help though, thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants