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

Missing cosine? #51

Closed
jcoc611 opened this issue Mar 5, 2023 · 5 comments
Closed

Missing cosine? #51

jcoc611 opened this issue Mar 5, 2023 · 5 comments
Assignees

Comments

@jcoc611
Copy link

jcoc611 commented Mar 5, 2023

Hi there! This is great.

Seems that cosine metric is missing. Based on the python bindings it should be as easy as saving a normalize flag somewhere in HierarchicalNSW of addon.cc and using IP + normalizing all the vectors if true.

@yoshoku yoshoku self-assigned this Mar 6, 2023
@yoshoku
Copy link
Owner

yoshoku commented Mar 6, 2023

@jcoc611 Thank you for having interest in this npm. hnsw-node currently does not support cosine metric. Python bindings normalize vector when before calling the addPoint member function if the normalize flag is true. It is not difficult to do the same in the hnsw-node. I would like to to try to implement the cosine metric option.

@nfcampos
Copy link

nfcampos commented Mar 9, 2023

This would be a great addition. We're using this library in https://github.com/hwchase17/langchainjs (thank you!) and would love to offer cosine metric

@yoshoku
Copy link
Owner

yoshoku commented Mar 10, 2023

@nfcampos Thank you for using this npm for your great product 👍 The cosine metric option has been implemented and tested, I will release that shortly.

@yoshoku
Copy link
Owner

yoshoku commented Mar 10, 2023

@jcoc611 @nfcampos I have released v1.4.2 which includes the cosine metric option. I enjoyed implementing it. Thank you for your suggestion.

@nfcampos
Copy link

@yoshoku Great, thanks!

@yoshoku yoshoku closed this as completed Mar 13, 2023
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

3 participants