From 4f4a85ac99ff4b4650e94af966e9c383644452c9 Mon Sep 17 00:00:00 2001 From: "Mark J. Hoy" Date: Fri, 27 Jun 2025 09:46:33 -0400 Subject: [PATCH 1/4] mark token pruning GA for 8.19 --- docs/changelog/128854.yaml | 12 ++++++++++ .../query-dsl/sparse-vector-query.asciidoc | 22 +++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 docs/changelog/128854.yaml diff --git a/docs/changelog/128854.yaml b/docs/changelog/128854.yaml new file mode 100644 index 0000000000000..5e08ab4ed4aec --- /dev/null +++ b/docs/changelog/128854.yaml @@ -0,0 +1,12 @@ +pr: 128854 +summary: Mark token pruning for sparse vector as GA +area: Machine Learning +type: feature +issues: [] +highlight: + title: Mark Token Pruning for Sparse Vector as GA + body: |- + Token pruning for sparse_vector queries has been live since 8.13 as tech preview. + As of 8.19.0 and 9.1.0, this is now generally available. + notable: true + diff --git a/docs/reference/query-dsl/sparse-vector-query.asciidoc b/docs/reference/query-dsl/sparse-vector-query.asciidoc index 2df9bfd04e77f..12158f5b05336 100644 --- a/docs/reference/query-dsl/sparse-vector-query.asciidoc +++ b/docs/reference/query-dsl/sparse-vector-query.asciidoc @@ -11,7 +11,7 @@ This can be achieved with one of two strategies: - Using an {nlp} model to convert query text into a list of token-weight pairs - Sending in precalculated token-weight pairs as query vectors -These token-weight pairs are then used in a query against a <> +These token-weight pairs are then used in a query against a <> or a <> field with a compatible sparse inference model. At query time, query vectors are calculated using the same inference model that was used to create the tokens. When querying, these query vectors are ORed together with their respective weights, which means scoring is effectively a <> calculation between stored dimensions and query dimensions. @@ -83,14 +83,12 @@ Only one of `inference_id` and `query_vector` is allowed. `prune` :: (Optional, boolean) -preview:[] Whether to perform pruning, omitting the non-significant tokens from the query to improve query performance. If `prune` is true but the `pruning_config` is not specified, pruning will occur but default values will be used. Default: false. `pruning_config` :: (Optional, object) -preview:[] Optional pruning configuration. If enabled, this will omit non-significant tokens from the query in order to improve query performance. This is only used if `prune` is set to `true`. @@ -101,26 +99,36 @@ Parameters for `pruning_config` are: `tokens_freq_ratio_threshold`:: (Optional, integer) -preview:[] Tokens whose frequency is more than `tokens_freq_ratio_threshold` times the average frequency of all tokens in the specified field are considered outliers and pruned. This value must between 1 and 100. Default: `5`. `tokens_weight_threshold`:: (Optional, float) -preview:[] Tokens whose weight is less than `tokens_weight_threshold` are considered insignificant and pruned. This value must be between 0 and 1. Default: `0.4`. `only_score_pruned_tokens`:: (Optional, boolean) -preview:[] If `true` we only input pruned tokens into scoring, and discard non-pruned tokens. It is strongly recommended to set this to `false` for the main query, but this can be set to `true` for a rescore query to get more relevant results. Default: `false`. NOTE: The default values for `tokens_freq_ratio_threshold` and `tokens_weight_threshold` were chosen based on tests using ELSERv2 that provided the most optimal results. + +When token pruning is applied, non-significant tokens will be pruned from the query. +Non-significant tokens can be defined as tokens that meet both of the following criteria: + +* The token appears much more frequently than most tokens, indicating that it is a very common word and may not benefit the overall search results much. +* The weight/score is so low that the token is likely not very relevant to the original term + +Both the token frequency threshold and weight threshold must show the token is non-significant in order for the token to be pruned. +This ensures that: + +* The tokens that are kept are frequent enough and have significant scoring. +* Very infrequent tokens that may not have as high of a score are removed. + -- [discrete] @@ -248,7 +256,7 @@ GET my-index/_search [[sparse-vector-query-with-pruning-config-and-rescore-example]] ==== Example ELSER query with pruning configuration and rescore -The following is an extension to the above example that adds a preview:[] pruning configuration to the `sparse_vector` query. +The following is an extension to the above example that adds a pruning configuration to the `sparse_vector` query. The pruning configuration identifies non-significant tokens to prune from the query in order to improve query performance. Token pruning happens at the shard level. From 40752774985f0d9b6e87dd80cf9b3e3ff16db390 Mon Sep 17 00:00:00 2001 From: "Mark J. Hoy" Date: Fri, 27 Jun 2025 09:49:01 -0400 Subject: [PATCH 2/4] Update docs/changelog/130212.yaml --- docs/changelog/130212.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/changelog/130212.yaml diff --git a/docs/changelog/130212.yaml b/docs/changelog/130212.yaml new file mode 100644 index 0000000000000..64d59b6c99c7c --- /dev/null +++ b/docs/changelog/130212.yaml @@ -0,0 +1,14 @@ +pr: 130212 +summary: Mark token pruning GA for 8.19 +area: Relevance +type: docs +issues: [] +highlight: + title: Mark token pruning GA for 8.19 + body: |- + (backport of: https://github.com/elastic/elasticsearch/pull/128854) + + A docs change to remove the [preview] labels for the token pruning + configuration items for the Sparse Vector query as we get ready to put + these into GA. + notable: true From 9d522dca7d4628f8e67ee3fa989baf539612a673 Mon Sep 17 00:00:00 2001 From: "Mark J. Hoy" Date: Fri, 27 Jun 2025 09:53:58 -0400 Subject: [PATCH 3/4] update changelog --- docs/changelog/130212.yaml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/changelog/130212.yaml b/docs/changelog/130212.yaml index 64d59b6c99c7c..b9cf5347c3dcf 100644 --- a/docs/changelog/130212.yaml +++ b/docs/changelog/130212.yaml @@ -1,14 +1,12 @@ pr: 130212 -summary: Mark token pruning GA for 8.19 -area: Relevance -type: docs +summary: Mark token pruning for sparse vector as GA +area: Machine Learning +type: feature issues: [] highlight: - title: Mark token pruning GA for 8.19 + title: Mark Token Pruning for Sparse Vector as GA body: |- - (backport of: https://github.com/elastic/elasticsearch/pull/128854) - - A docs change to remove the [preview] labels for the token pruning - configuration items for the Sparse Vector query as we get ready to put - these into GA. + Token pruning for sparse_vector queries has been live since 8.13 as tech preview. + As of 8.19.0 and 9.1.0, this is now generally available. notable: true + From a82eadb55fe91293f094050dc63074d3b672e1d4 Mon Sep 17 00:00:00 2001 From: "Mark J. Hoy" Date: Fri, 27 Jun 2025 09:58:41 -0400 Subject: [PATCH 4/4] remove 9.1 changelog --- docs/changelog/128854.yaml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 docs/changelog/128854.yaml diff --git a/docs/changelog/128854.yaml b/docs/changelog/128854.yaml deleted file mode 100644 index 5e08ab4ed4aec..0000000000000 --- a/docs/changelog/128854.yaml +++ /dev/null @@ -1,12 +0,0 @@ -pr: 128854 -summary: Mark token pruning for sparse vector as GA -area: Machine Learning -type: feature -issues: [] -highlight: - title: Mark Token Pruning for Sparse Vector as GA - body: |- - Token pruning for sparse_vector queries has been live since 8.13 as tech preview. - As of 8.19.0 and 9.1.0, this is now generally available. - notable: true -