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

Update redis vector store #12386

Merged

Conversation

tylerhutcherson
Copy link
Contributor

@tylerhutcherson tylerhutcherson commented Mar 28, 2024

Description

This PR introduces a refactor of the RedisVectorStore interface and functionality. Highlights include:

  • Expanded support for different filter types including text fields, tags, and numeric ranges.
  • Improved performance of simple read/write operations.
  • Cleaner schema definition to outline fields that will be indexed in Redis along with settings/configurations
  • Reduced lines of code to maintain

@logan-markewich would love your eyes on this first before I take another step at implementing deeper unit tests and integration tests. Because of the size of the changes, I'd love to get alignment first.

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 28, 2024
Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Progress! I like the new setup quite a bit. Mostly just some questions for my own understanding

@dosubot dosubot bot removed the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 9, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Apr 9, 2024
@tylerhutcherson
Copy link
Contributor Author

@logan-markewich ok all ready for another review from you! thanks!

ids.append(node.node_id)
key = "_".join([self._prefix, str(node.node_id)])
self._redis_client.hset(key, mapping=mapping) # type: ignore
data.append({**record, **additional_metadata})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, all the metadata is added (nice). I saw some examples where the custom schema specifically defines metadata fields -- what's the advantage with doing that? How is that different from the default behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. Redis keeps the "data" and "index" as separate constructs. So what you write/include in the payload here doesn't have to be added to the schema. Sometimes it's more performant or cost effective to NOT index fields you don't need to.

There are two modes here of using Redis:

  1. Default schema: in this mode, only the bare minimum, required fields will be "indexed" in Redis and searchable/filterable. However you can still store all arbitrary metadata that you want -- but it won't be included in the search index (still available to be returned along side). You can get started with this out of the box. No schema definition required.
  2. Custom schema: in this mode, user can define a custom schema, which you have seen. This allows for customization of vector settings (algorithm, dims, etc) AND adding additional metadata like tags or text or numerics to the search index. Can also customize index name etc.

We could look at ways in between too if you think we need to support additional ways!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes a ton of sense -- thank you for clarifying !

Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks a ton for the hustle on this @tylerhutcherson

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 11, 2024
@logan-markewich logan-markewich merged commit 433804f into run-llama:main Apr 11, 2024
8 checks passed
chrisalexiuk-nvidia pushed a commit to chrisalexiuk-nvidia/llama_index that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants