redis-om-node icon indicating copy to clipboard operation
redis-om-node copied to clipboard

Vector Similarity Index

Open CaptainCodeman opened this issue 3 years ago • 12 comments

The field type / index building part of supporting Vector Similarity

Part of #85

This is just the index-building and support for saving / loading objects with binary Buffers. The search part is still remaining to be done although it is possible to use with the redis client directly in case anyone wants to experiment with it.

Also adds support for storing binary data, even if it isn't a vector indexed (e,.g. a profile object with an avatar image, product with photo etc...)

CaptainCodeman avatar Jul 01 '22 03:07 CaptainCodeman

This is probably at the point where it is ready for review.

I've successfully used it to store and index both image and text vectors so it's already usable if you're willing to do the search part via the redis client (until we add VSS querying support to this package).

I don't know why the node 14 build started playing up part way through - all the exact same dependencies worked on other branches AFAICT, but I needed to install esbuild directly.

CaptainCodeman avatar Jul 06 '22 16:07 CaptainCodeman

Here's some examples of the image matching, the top left image in each set is the source that was searched for and the rest are the matches (out of about 1,500 images - a mix of paintings, photos and digital art). Perfect for a "you might also like ..." product page:

1 Screen Shot 2022-07-06 at 10 42 38 AM

2 Screen Shot 2022-07-06 at 10 42 47 AM

3 Screen Shot 2022-07-06 at 10 42 01 AM

4 Screen Shot 2022-07-06 at 10 42 56 AM

5 Screen Shot 2022-07-06 at 10 43 49 AM

6 Screen Shot 2022-07-06 at 10 43 41 AM

7 Screen Shot 2022-07-06 at 10 42 47 AM

8 Screen Shot 2022-07-06 at 10 43 01 AM

9 Screen Shot 2022-07-06 at 10 43 28 AM

10 Screen Shot 2022-07-06 at 10 43 15 AM

11 Screen Shot 2022-07-06 at 10 43 53 AM

CaptainCodeman avatar Jul 06 '22 16:07 CaptainCodeman

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@3c3d8e6). Click here to learn what that means. Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage        ?   98.65%           
=======================================
  Files           ?       35           
  Lines           ?     3047           
  Branches        ?      600           
=======================================
  Hits            ?     3006           
  Misses          ?       41           
  Partials        ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Dec 13 '22 18:12 codecov-commenter

Finally working to index both HASH and JSON data structures with vector similarity.

The tests can use some refactoring to re-use the common code, but it's usable to build the index and store the data correctly.

CaptainCodeman avatar Dec 13 '22 23:12 CaptainCodeman

+1 for merging this (I'm not a committer/reviewer, just would like to see it added)

simon-two avatar Dec 20 '22 21:12 simon-two

No worries. It will be merged. Probably early next year. Like February. Just a matter or timing.

guyroyse avatar Dec 21 '22 15:12 guyroyse

I notice vector fields now support FLOAT64 as well as FLOAT32 for the type parameter so that should probably be accounted for.

Ideally it would determine that from the model, whether it had a Float32Array or Float64Array property (instead of Buffer) but that would need reflect-metadata and be more suited to a TypeScript decorator mapping approach which I might have a play around with.

CaptainCodeman avatar Dec 21 '22 17:12 CaptainCodeman

+1 for merging, although I do think support for FLOAT64 is important.

Shaun-Regenbaum avatar Jan 03 '23 18:01 Shaun-Regenbaum

+1 for merging

anaibol avatar Feb 19 '23 15:02 anaibol

Another vote for merging (actually I've voted twice...)

simon-two avatar Apr 04 '23 17:04 simon-two

Has this been abandoned? This is a very useful feature for redis-om with the popularity of LLM and Embedding documents.

mauriciocirelli avatar Apr 16 '24 23:04 mauriciocirelli

Has this been abandoned? This is a very useful feature for redis-om with the popularity of LLM and Embedding documents.

Kinda. It would need some effort to rebase onto the latest version and adapt to wherever the lib has diverged since this was submitted, but I don't personally have time to devote to doing that right now.

I've mostly just been using the node redis client directly or else my own decorator-based mapper / index builder that I've been experimenting with.

CaptainCodeman avatar Apr 18 '24 17:04 CaptainCodeman