-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Aws bedrock reranker #3652
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
base: main
Are you sure you want to change the base?
Aws bedrock reranker #3652
Conversation
# Conflicts: # docs/components/rerankers/config.mdx # docs/components/rerankers/overview.mdx # mem0/configs/rerankers/base.py # mem0/utils/factory.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the failing tests and incorporate the requested changes, there's lot of duplicate code over here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this examples file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please match the writing style similar to here:
| print(results) | ||
| ``` | ||
|
|
||
| ## Prerequisites |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the section for the aws account setup, it's too textual and these steps shouldn't be documented here.
| "api_key": "your-openai-key" | ||
| } | ||
| }, | ||
| "reranker": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change reranker to rerank to make it align with the code base?
| #### 4. IAM Roles (for EC2/Lambda) | ||
| ```python | ||
| config = { | ||
| "reranker": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the reranker here as well.
| ) | ||
|
|
||
| # Initialize reranker if configured | ||
| self.reranker = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code here as well.
| if threshold is None or mem.score >= threshold: | ||
| original_memories.append(memory_item_dict) | ||
|
|
||
| # Apply reranking if configured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this code we have it's implementation in the search this becomes redundant.
| if threshold is None or mem.score >= threshold: | ||
| original_memories.append(memory_item_dict) | ||
|
|
||
| # Apply reranking if configured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing applies here.
| except (ImportError, AttributeError) as e: | ||
| raise ImportError(f"Could not import reranker for provider '{provider_name}': {e}") | ||
|
|
||
| # For AWS Bedrock, tests expect the factory to pass a plain dict to the reranker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit picking here, for the tests to pass we should update the tests and not code here, why are we explicitly handling aws bedrock config here?
| @@ -0,0 +1 @@ | |||
| """Tests for reranker implementations.""" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this as well.
Description
Added AWS Bedrock as a reranker provider in the docs:
Added code changes to support AWS Bedrock reranker.
Fixes #3501
Type of change
Please delete options that are not relevant.
New feature (non-breaking change which adds functionality)
Documentation update
How Has This Been Tested?
make buildensures code builds properly.Checklist:
Maintainer Checklist