-
Notifications
You must be signed in to change notification settings - Fork 126
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
Adds rescore parameter to KNNQuery #1969
Adds rescore parameter to KNNQuery #1969
Conversation
Adds rescore parameter to knn query. With this commit, the rescore is a no-op. The functionality and validation will be added in a later commit. Signed-off-by: John Mazanec <[email protected]>
c34cde1
to
dc8e049
Compare
src/main/java/org/opensearch/knn/index/query/parser/RescoreParser.java
Outdated
Show resolved
Hide resolved
public final class RescoreContext { | ||
|
||
public static final float DEFAULT_OVERSAMPLE_FACTOR = 1.0f; | ||
public static final float MAX_OVERSAMPLE_FACTOR = 5.0f; |
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.
@jmazanec15 will 5 be good enough may be 100? I know nothing is good enough. but I was thinking with 100 as max and a cap of 10K on the k*oversampling factor should cover most of the cases.
Thoughts?
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.
Sure I can increase. Let me update
src/main/java/org/opensearch/knn/index/query/rescore/RescoreContext.java
Outdated
Show resolved
Hide resolved
@@ -110,6 +124,10 @@ public static KNNQueryBuilder.Builder streamInput(StreamInput in, Function<Strin | |||
builder.methodParameters(MethodParametersParser.streamInput(in, IndexUtil::isClusterOnOrAfterMinRequiredVersion)); | |||
} | |||
|
|||
if (minClusterVersionCheck.apply(RESCORE_PARAMETER)) { |
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.
I think this will affect neural, just a heads up
@@ -48,6 +48,8 @@ public class IndexUtil { | |||
private static final Version MINIMAL_SUPPORTED_VERSION_FOR_RADIAL_SEARCH = Version.V_2_14_0; | |||
private static final Version MINIMAL_SUPPORTED_VERSION_FOR_METHOD_PARAMETERS = Version.V_2_16_0; | |||
private static final Version MINIMAL_SUPPORTED_VERSION_FOR_MODEL_VECTOR_DATA_TYPE = Version.V_2_16_0; | |||
// TODO: Will update once 2.17 backport change is merged | |||
private static final Version MINIMAL_RESCORE_FEATURE = Version.V_3_0_0; |
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: Look around if there is a need to have this in neural plugin
@@ -776,19 +777,23 @@ public void testDoToQuery_InvalidZeroByteVector() { | |||
|
|||
public void testSerialization() throws Exception { |
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: Does KNNQueryBuilderValidParamsTests and KNNQueryBuilderInvalidParamsTests need an update?
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.
Ill add some basic ones, but do most of testing in the Rescore validation tests
src/main/java/org/opensearch/knn/index/query/rescore/RescoreContext.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/query/rescore/RescoreContext.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/query/rescore/RescoreContext.java
Outdated
Show resolved
Hide resolved
Signed-off-by: John Mazanec <[email protected]>
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.
LGTM
import static org.opensearch.knn.index.query.parser.RescoreParser.RESCORE_OVERSAMPLE_PARAMETER; | ||
import static org.opensearch.knn.index.query.parser.RescoreParser.RESCORE_PARAMETER; | ||
|
||
public class QueryParseIT extends KNNRestTestCase { |
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.
Seems like a duplicate in a way, maybe added a todo on one of them to merge for later
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.
Yes, that probably makes sense. Let me make a note on this and come back with it in another PR, with some other test cleanup.
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.
LGTM !!
Adds rescore parameter to knn query. With this commit, the rescore is a no-op. The functionality and validation will be added in a later commit. Signed-off-by: John Mazanec <[email protected]> (cherry picked from commit 9db7058)
* Adds rescore parameter to KNNQuery (#1969) Adds rescore parameter to knn query. With this commit, the rescore is a no-op. The functionality and validation will be added in a later commit. Signed-off-by: John Mazanec <[email protected]> (cherry picked from commit 9db7058) * fix version Signed-off-by: John Mazanec <[email protected]> --------- Signed-off-by: John Mazanec <[email protected]> Co-authored-by: John Mazanec <[email protected]>
Adds rescore parameter to knn query. With this commit, the rescore is a no-op. The functionality and validation will be added in a later commit. Signed-off-by: John Mazanec <[email protected]> Signed-off-by: Akash Shankaran <[email protected]>
Description
Adds rescore parameter to knn query. With this commit, the rescore is a no-op. The functionality and validation will be added in a later commit.
The valid options look like:
Will update changelog once feature is completed
Related Issues
Related to #1779
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.