-
Couldn't load subscription status.
- Fork 25.6k
Support semantic reranking using contextual snippets instead of entire field text #129369
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
Merged
Changes from 62 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
d2c22a6
Do highlighting in RankFeatureShardPhase
kderusso 3f52ac7
Propagate to
kderusso 0ffaf94
Only rerank the first snippet
kderusso f99c33e
Notes
kderusso 0196a7c
Support reranking based on max score of multiple snippets per document
kderusso d796953
Update from main
kderusso 1dc80a1
Fix compilation error
kderusso 7537c21
Merge from main
kderusso f68b720
Fix merge compile errors
kderusso b053fa3
Merge update from main
kderusso bbee29f
Merge main into branch
kderusso c4bcb43
Fix compilation error after upstream merge
kderusso ce8364b
Combine featureData and snippets
kderusso d8dbaab
Remove docIndices from RankFeatureDoc
kderusso b909ab9
Update API - remove max size, default num snippets, rename
kderusso 243e169
Merge branch 'main' into kderusso/rerank-snippet-poc
kderusso 1684fba
Merge main into kderusso/rerank-snippet-poc
kderusso e6208ec
Add hardcoded max token length
kderusso e3259d9
Fix error in docId calculation
kderusso 16dbca0
Fix snippet calculation
kderusso fee2b0d
Fix test compilation errors
kderusso 9119d26
Merge branch 'main' into kderusso/rerank-snippet-poc
kderusso b418f87
Fix more test compilation failures
kderusso c30da72
Cleanup
kderusso cf2c8b3
Minor variable cleanup
kderusso 4675586
Add some tests
kderusso 129efac
Refactor method signatures to provide only a single custom input, fix…
kderusso 4519d61
Refactor/rename
kderusso 17ec3a8
Minor cleanup
kderusso 9ae38c9
[CI] Auto commit changes from spotless
ffbcddd
Rewrite highlight match query
kderusso 8a82b13
[CI] Auto commit changes from spotless
d5411db
Fix wonky syntax
kderusso 3dfba46
Stash changes
kderusso ee69e3e
Move rewrite to RankBuilder
kderusso c24db3b
Cleanup
kderusso 7c6848d
[CI] Auto commit changes from spotless
35d27a9
Fix rewrite getting semantic query and cleanup tests
kderusso b6aaf8f
[CI] Auto commit changes from spotless
251bd49
Cleanup
kderusso 09c8b48
Update docs/changelog/129369.yaml
kderusso e9ebe8d
Merge main into kderusso/rerank-snippet-poc
kderusso 584e7ea
Fix integration test compilation errors
kderusso aaa3948
Fix some test compilation errors introduced by refactor
kderusso 15bdcef
Merge main into kderusso/rerank-snippet-poc
kderusso 75568a9
Fix tests
kderusso 143ed4a
Addressed PR feedback moving snippet generation down into text simila…
kderusso 2418e41
[CI] Auto commit changes from spotless
ed08549
Minor cleanup
kderusso ab8916b
Merge main into kderusso/rerank-snippet-poc
kderusso b641438
Fix CI test compilation failures
kderusso a835902
Fix tests
kderusso 1a79987
Minor cleanup
kderusso d330d5e
Merge branch 'main' into kderusso/rerank-snippet-poc
kderusso 9e53b17
Merge main into kderusso/rerank-snippet-poc
kderusso f88d678
Increase highlighter fragment size for snippets
kderusso 3b08e12
Add feature flag for snippet reranking
kderusso 55277a0
Merge main into kderusso/rerank-snippet-poc
kderusso d2e4611
Set noMatchSize on highlighting request
kderusso 44c2c71
Remove leftover throws
kderusso 6e8521a
Merge branch 'main' into kderusso/rerank-snippet-poc
kderusso d56726c
Consolidate snippet rank input
kderusso 40c447d
Update x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/…
kderusso 1ad29a7
Update x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/…
kderusso cc07332
Refactor move/rename SnippetConfig
kderusso 5a870a6
Merge branch 'main' into kderusso/rerank-snippet-poc
kderusso 32f59b3
Consolidate default endpoints
kderusso b7e0a45
Merge main into kderusso/rerank-snippet-poc
kderusso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 129369 | ||
| summary: Support semantic reranking using contextual snippets instead of entire field | ||
| text | ||
| area: Relevance | ||
| type: enhancement | ||
| issues: [] |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
90 changes: 90 additions & 0 deletions
90
server/src/main/java/org/elasticsearch/search/rank/feature/RerankSnippetInput.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.search.rank.feature; | ||
|
|
||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.index.query.QueryBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| public class RerankSnippetInput implements Writeable { | ||
|
|
||
| public final Integer numSnippets; | ||
| private final String inferenceText; | ||
| private final Integer tokenSizeLimit; | ||
| public final QueryBuilder snippetQueryBuilder; | ||
|
|
||
| public static final int DEFAULT_NUM_SNIPPETS = 1; | ||
|
|
||
| public RerankSnippetInput(StreamInput in) throws IOException { | ||
| this.numSnippets = in.readOptionalVInt(); | ||
| this.inferenceText = in.readString(); | ||
| this.tokenSizeLimit = in.readOptionalVInt(); | ||
| this.snippetQueryBuilder = in.readOptionalNamedWriteable(QueryBuilder.class); | ||
| } | ||
|
|
||
| public RerankSnippetInput(Integer numSnippets) { | ||
| this(numSnippets, null, null); | ||
| } | ||
|
|
||
| public RerankSnippetInput(Integer numSnippets, String inferenceText, Integer tokenSizeLimit) { | ||
| this(numSnippets, inferenceText, tokenSizeLimit, null); | ||
| } | ||
|
|
||
| public RerankSnippetInput(Integer numSnippets, String inferenceText, Integer tokenSizeLimit, QueryBuilder snippetQueryBuilder) { | ||
| this.numSnippets = numSnippets; | ||
| this.inferenceText = inferenceText; | ||
| this.tokenSizeLimit = tokenSizeLimit; | ||
| this.snippetQueryBuilder = snippetQueryBuilder; | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeOptionalVInt(numSnippets); | ||
| out.writeString(inferenceText); | ||
| out.writeOptionalVInt(tokenSizeLimit); | ||
| out.writeOptionalNamedWriteable(snippetQueryBuilder); | ||
| } | ||
|
|
||
| public Integer numSnippets() { | ||
| return numSnippets; | ||
| } | ||
|
|
||
| public String inferenceText() { | ||
| return inferenceText; | ||
| } | ||
|
|
||
| public Integer tokenSizeLimit() { | ||
| return tokenSizeLimit; | ||
| } | ||
|
|
||
| public QueryBuilder snippetQueryBuilder() { | ||
| return snippetQueryBuilder; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| RerankSnippetInput that = (RerankSnippetInput) o; | ||
| return Objects.equals(numSnippets, that.numSnippets) | ||
| && Objects.equals(inferenceText, that.inferenceText) | ||
| && Objects.equals(tokenSizeLimit, that.tokenSizeLimit) | ||
| && Objects.equals(snippetQueryBuilder, that.snippetQueryBuilder); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(numSnippets, inferenceText, tokenSizeLimit, snippetQueryBuilder); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.