- Notifications
You must be signed in to change notification settings - Fork 25.5k
New vector_rescore
parameter as a quantized index type option #124581
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
New vector_rescore
parameter as a quantized index type option #124581
Conversation
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
Hi @benwtrent, I've created a changelog YAML for you. |
…wtrent/elasticsearch into feature/add-rescore-to-index-options
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. 🎉 Left some small doc comments
Float oversample = indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions | ||
? quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null | ||
: null; | ||
if (queryOversample != null) { | ||
oversample = queryOversample; | ||
} |
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 - I find hard to follow multiple ternary operators
Float oversample = indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions | |
? quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null | |
: null; | |
if (queryOversample != null) { | |
oversample = queryOversample; | |
} | |
Float oversample = null; | |
if (queryOversample != null) { | |
oversample = queryOversample; | |
} else if (queryOversample indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions) { | |
oversample = quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null | |
} |
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 refactor
Co-authored-by: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com>
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 👍
? quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null | ||
: null; | ||
Float oversample = null; | ||
if (indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions && quantizedIndexOptions.rescoreVector != null) { |
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 - Why go through this if branch if queryOversample is not null? It will be overriden in the next if.
@carlosdelest I am restricting by index version. It came to mind that its possible to rolling upgrade, have a mixed cluster, then update a value to use the rescore parameter, but on an old index version. This would be bad as that index would no longer be readable on the old data nodes. |
Good call. Will keep in mind for future mapping options changes ✍️ |
…wtrent/elasticsearch into feature/add-rescore-to-index-options
…tic#124581) This adds a new parameter to the quantized index mapping that allows default oversampling and rescoring to occur. This doesn't adjust any of the defaults. It allows it to be configured. When the user provides `rescore_vector: {oversample: <number>}` in the query it will overwrite it. For example, here is how to use it with bbq: ``` PUT rescored_bbq { "mappings": { "properties": { "vector": { "type": "dense_vector", "index_options": { "type": "bbq_hnsw", "rescore_vector": {"oversample": 3.0} } } } } } ``` Then, when querying, it will auto oversample the `k` by `3x` and rerank with the raw vectors. ``` POST _search { "knn": { "query_vector": [...], "field": "vector" } } ```
This PR is a partial backport of elastic#127285 that fixes the validation of the inference id when mappings are restored or dynamically updated. This change doesn't include defaulting semantic text dense vector to BBQ since it requires elastic#124581 to be backported first.
This PR is a partial backport of elastic#127285 that fixes the validation of the inference id when mappings are restored or dynamically updated. This change doesn't include defaulting semantic text dense vector to BBQ since it requires elastic#124581 to be backported first.
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
#124581) (#127644) * New `vector_rescore` parameter as a quantized index type option (#124581) This adds a new parameter to the quantized index mapping that allows default oversampling and rescoring to occur. This doesn't adjust any of the defaults. It allows it to be configured. When the user provides `rescore_vector: {oversample: <number>}` in the query it will overwrite it. For example, here is how to use it with bbq: ``` PUT rescored_bbq { "mappings": { "properties": { "vector": { "type": "dense_vector", "index_options": { "type": "bbq_hnsw", "rescore_vector": {"oversample": 3.0} } } } } } ``` Then, when querying, it will auto oversample the `k` by `3x` and rerank with the raw vectors. ``` POST _search { "knn": { "query_vector": [...], "field": "vector" } } ``` (cherry picked from commit b2c1c4e) * Adds new BWC version for 8.19 backport of (#124581) (#127647) * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
This adds a new parameter to the quantized index mapping that allows default oversampling and rescoring to occur.
This doesn't adjust any of the defaults. It allows it to be configured. When the user provides
rescore_vector: {oversample: <number>}
in the query it will overwrite it.For example, here is how to use it with bbq:
Then, when querying, it will auto oversample the
k
by3x
and rerank with the raw vectors.