redis / redis-vl-python

Redis Vector Library (RedisVL) interfaces with Redis' vector database for realtime semantic search, RAG, and recommendation systems.
https://www.redisvl.com/
MIT License
176 stars 25 forks source link

Initial reranker integration in RedisVL #139

Closed tylerhutcherson closed 2 months ago

tylerhutcherson commented 2 months ago

This PR introduces another utility class into RedisVL to improve the querying experience, and result quality, through integration with 3rd party rerankers. We have started with Cohere's reranking API and will also add additional options later on.

TODO (with Cohere):

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 92.50000% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 88.60%. Comparing base (727d6dc) to head (c6a9a96).

Files Patch % Lines
redisvl/utils/rerank/cohere.py 90.56% 5 Missing :warning:
redisvl/utils/rerank/base.py 84.61% 4 Missing :warning:
redisvl/utils/vectorize/text/azureopenai.py 84.61% 2 Missing :warning:
redisvl/utils/vectorize/base.py 91.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #139 +/- ## ========================================== + Coverage 88.43% 88.60% +0.16% ========================================== Files 26 29 +3 Lines 1565 1667 +102 ========================================== + Hits 1384 1477 +93 - Misses 181 190 +9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tylerhutcherson commented 2 months ago

left some suggestions on what the documents need to look like to pass to the rerank call. TLDR:

  • If we want, we are free to send rerank json docs (ie, list of dicts) but we just need to make sure to pass rerank a list of rank_fields that are the keys in the json docs
  • If we want to instead handle the slicing of json fields on the client side, we can do so and then pass rerank a list of strings and then omit passing rank_fields
  • We should default to rerank-english-v3.0

Apologies if I'm missing some of the requirements we discussed a few months ago regarding the integration of the new reranker in redis.

Great feedback. I definitely missed the API spec update for v3. My concern with moving to rank_fields was backwards compatibility and the right way to do that. But I think I can updated rank_by to be a list of strings. That way it can be flexible across different reranking implementations. I will work on an update here shortly, and tag you again :) thanks!