- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Allow zero for rescore_vector.oversample to indicate by-passing oversample and rescoring #125599
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
Allow zero for rescore_vector.oversample to indicate by-passing oversample and rescoring #125599
Conversation
…ample and rescoring
| Pinging @elastic/es-search-relevance (Team:Search Relevance) | 
| Hi @benwtrent, I've created a changelog YAML for you. | 
…tor-zero-oversample
| if (oversampleValue == 0 && indexVersion.before(RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS)) { | ||
| throw new IllegalArgumentException("oversample must be greater than 1"); | ||
| } | ||
| if (oversampleValue < 1) { | 
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 feel that I'm missing something obvious here, but 0 is now a valid value for oversampleValue in new index versions, right?
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.
yeah, let me verify I am capturing this accurately in tests. I might have removed an else if accidentally.
| ); | ||
|  | ||
| Query query = fieldType.createKnnQuery(VectorData.fromFloats(new float[] { 1, 4, 10 }), 10, 100, 0f, null, null, null); | ||
| assertTrue(query instanceof ESKnnFloatVectorQuery); | 
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 we need to check that the query parameters do not include rescoring when 0 is used in the query. Also, we should probably check that we can't set 0 for previous index versions
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 will add a test
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 - Some comments on testing for your consideration
        
          
                ...spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/41_knn_search_bbq_hnsw.yml
          
            Show resolved
            Hide resolved
        
              
          
                ...mlRestTest/resources/rest-api-spec/test/search.vectors/41_knn_search_half_byte_quantized.yml
          
            Show resolved
            Hide resolved
        
              
          
                server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldTypeTests.java
          
            Show resolved
            Hide resolved
        
      …ample and rescoring (elastic#125599) This allows a `rescore_vector: {oversample: 0}` to indicate bypassing oversampling and rescoring. This is useful for: - Updating a quantized mapping to turn off automatic rescoring - Bypassing oversampling at query time in an ad-hoc manner if its on by default in the mapping closes: elastic#125157
| 💚 All backports created successfully
 Questions ?Please refer to the Backport tool documentation | 
blocks: elastic#127662 This adds bwc versions for elastic#125599
…g oversample and rescoring (#125599) (#127662) * Allow zero for rescore_vector.oversample to indicate by-passing oversample and rescoring (#125599) This allows a `rescore_vector: {oversample: 0}` to indicate bypassing oversampling and rescoring. This is useful for: - Updating a quantized mapping to turn off automatic rescoring - Bypassing oversampling at query time in an ad-hoc manner if its on by default in the mapping closes: #125157 (cherry picked from commit 009a86a) * Adding versions for bwc for #125599 (#127663) blocks: #127662 This adds bwc versions for #125599 * fixing versioning for merge
blocks: elastic#127662 This adds bwc versions for elastic#125599
blocks: elastic#127662 This adds bwc versions for elastic#125599
This allows a
rescore_vector: {oversample: 0}to indicate bypassing oversampling and rescoring.This is useful for:
closes: #125157