-
Notifications
You must be signed in to change notification settings - Fork 525
Query: Adds support for weighted RRF in hybrid search #5064
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
Merged
microsoft-github-policy-service
merged 1 commit into
master
from
users/ndeshpan/weightedRRF
Mar 19, 2025
Merged
Query: Adds support for weighted RRF in hybrid search #5064
microsoft-github-policy-service
merged 1 commit into
master
from
users/ndeshpan/weightedRRF
Mar 19, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sboshra
reviewed
Mar 13, 2025
...ry/Core/Pipeline/CrossPartition/HybridSearch/HybridSearchCrossPartitionQueryPipelineStage.cs
Outdated
Show resolved
Hide resolved
sboshra
previously approved these changes
Mar 13, 2025
Contributor
sboshra
left a comment
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.
![]()
Fix a couple of bugs for weighted RRF and add unit test infra for weighted RRF Add more test coverage for weighted RRF incorporate code review feedback
be400d8 to
08ec8ec
Compare
sboshra
approved these changes
Mar 19, 2025
Contributor
sboshra
left a comment
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.
![]()
adityasa
approved these changes
Mar 19, 2025
Contributor
adityasa
left a comment
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.
![]()
Merged
3 tasks
amanrao23
added a commit
to Azure/azure-sdk-for-js
that referenced
this pull request
May 9, 2025
…34222) ### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR #34221 ### Describe the problem that is addressed by this PR 1. ***Add support for weighted RRF in hybrid search.*** We allow weights to be negative but the negative sign is used to signal that we should sort scores in ascending order for the corresponding component. The final WRRF score is then computed using the absolute value of the weight. In this approach, the sign of the weight indicates the interpretation of the ranking itself rather than directly affecting the calculated score: WRRF(d) = ∑ |w_i| × 1/(k + r_i'(d)) 2. ***Adds support for the optimized query plan*** Adds a QueryFeature that returns optimized query plan, effectively removing the need for rewriting orderByExpressions in the SDK. A flag `disableHybridSearchQueryPlanOptimization` is added to disable returning optimized query plan. This is done to ensure the query works as expected for older gateways. ### Are there test cases added in this PR? _(If not, why?)_ Yes ### Provide a list of related PRs _(if any)_ * Azure/azure-cosmos-dotnet-v3#5064 * Azure/azure-cosmos-dotnet-v3#5120 * Azure/azure-cosmos-dotnet-v3#5121 ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Weighted RRF support
This change adds support for weighted RRF in hybrid search.
We allow weights to be negative but the negative sign is used to signal that we should sort scores in ascending order for the corresponding component. The final WRRF score is then computed using the absolute value of the weight.
In this approach, the sign of the weight indicates the interpretation of the ranking itself rather than directly affecting the calculated score:
WRRF(d) = ∑ |w_i| × 1/(k + r_i'(d))Where:
|w_i| is the absolute value of the weight for the i-th component
r_i'(d) is the rank of document d in the i-th component, with a crucial difference:
k = 60
Intuition Behind This Modification
This modification addresses a key scenario in information retrieval and ranking fusion: sometimes "lower is better" rather than "higher is better."
Type of change