Adding linear retriever to support weighted sums of sub-retrievers#120222
Merged
pmpailis merged 78 commits intoelastic:mainfrom Jan 28, 2025
Merged
Adding linear retriever to support weighted sums of sub-retrievers#120222pmpailis merged 78 commits intoelastic:mainfrom
pmpailis merged 78 commits intoelastic:mainfrom
Conversation
Contributor
|
Documentation preview: |
Collaborator
|
Hi @pmpailis, I've created a changelog YAML for you. |
benwtrent
reviewed
Jan 27, 2025
Member
benwtrent
left a comment
There was a problem hiding this comment.
Looking much better. I have a concern around testing:
Do we have a test that specifically exercises the path when the different retrievers return different doc IDs? (e.g. they match non-overlapping doc sets).
...lugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/linear/LinearRetrieverBuilder.java
Outdated
Show resolved
Hide resolved
Contributor
Author
Added a test to account for this in ea1787f |
pmpailis
commented
Jan 27, 2025
...gin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/linear/LinearRetrieverComponent.java
Show resolved
Hide resolved
pmpailis
commented
Jan 27, 2025
...plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/linear/MinMaxScoreNormalizer.java
Outdated
Show resolved
Hide resolved
Collaborator
💔 Backport failed
You can use sqren/backport to manually backport by running |
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
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.
This PR adds a new
linearretriever to facilitate hybrid search, that would be able to linearly combine the results of other sub-retrievers and compute the final score of a document based on the weighted sum of each sub-components.Each sub-component can specify the following elements:
retriever-> specifies how we will compute the top documentsnormalizer-> specifies how we want to normalize the top documents for this retriever (so that we can ensure that all scores fall within the same range)weight-> theweightfor the normalized score if the final weighted sum computationPagination is similar to that of
rrf's retriever, i.e. we compute the globalrank_window_sizedocs and pagination is only available within these bounds.So, working through an example, let's say that we perform a hybrid search query where:
standardretriever, and normalize the scores to a[0, 1]rangeknnretriever, without normalizing the documents as wellscore = 1.5 * standard + 2.5 * knnSample syntax: