Skip to content

Commit 197714e

Browse files
authored
[8.19] Mark Token Pruning for Sparse Vector as GA for 8.19 (#130212)
* mark token pruning GA for 8.19 * Update docs/changelog/130212.yaml * update changelog * remove 9.1 changelog
1 parent 23b6242 commit 197714e

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

docs/changelog/130212.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pr: 130212
2+
summary: Mark token pruning for sparse vector as GA
3+
area: Machine Learning
4+
type: feature
5+
issues: []
6+
highlight:
7+
title: Mark Token Pruning for Sparse Vector as GA
8+
body: |-
9+
Token pruning for sparse_vector queries has been live since 8.13 as tech preview.
10+
As of 8.19.0 and 9.1.0, this is now generally available.
11+
notable: true
12+

docs/reference/query-dsl/sparse-vector-query.asciidoc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This can be achieved with one of two strategies:
1111
- Using an {nlp} model to convert query text into a list of token-weight pairs
1212
- Sending in precalculated token-weight pairs as query vectors
1313

14-
These token-weight pairs are then used in a query against a <<sparse-vector,sparse vector>>
14+
These token-weight pairs are then used in a query against a <<sparse-vector,sparse vector>>
1515
or a <<semantic-text, semantic_text>> field with a compatible sparse inference model.
1616
At query time, query vectors are calculated using the same inference model that was used to create the tokens.
1717
When querying, these query vectors are ORed together with their respective weights, which means scoring is effectively a <<vector-functions-dot-product,dot product>> calculation between stored dimensions and query dimensions.
@@ -83,14 +83,12 @@ Only one of `inference_id` and `query_vector` is allowed.
8383

8484
`prune` ::
8585
(Optional, boolean)
86-
preview:[]
8786
Whether to perform pruning, omitting the non-significant tokens from the query to improve query performance.
8887
If `prune` is true but the `pruning_config` is not specified, pruning will occur but default values will be used.
8988
Default: false.
9089

9190
`pruning_config` ::
9291
(Optional, object)
93-
preview:[]
9492
Optional pruning configuration.
9593
If enabled, this will omit non-significant tokens from the query in order to improve query performance.
9694
This is only used if `prune` is set to `true`.
@@ -101,26 +99,36 @@ Parameters for `pruning_config` are:
10199

102100
`tokens_freq_ratio_threshold`::
103101
(Optional, integer)
104-
preview:[]
105102
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.
106103
This value must between 1 and 100.
107104
Default: `5`.
108105

109106
`tokens_weight_threshold`::
110107
(Optional, float)
111-
preview:[]
112108
Tokens whose weight is less than `tokens_weight_threshold` are considered insignificant and pruned.
113109
This value must be between 0 and 1.
114110
Default: `0.4`.
115111

116112
`only_score_pruned_tokens`::
117113
(Optional, boolean)
118-
preview:[]
119114
If `true` we only input pruned tokens into scoring, and discard non-pruned tokens.
120115
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.
121116
Default: `false`.
122117

123118
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.
119+
120+
When token pruning is applied, non-significant tokens will be pruned from the query.
121+
Non-significant tokens can be defined as tokens that meet both of the following criteria:
122+
123+
* 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.
124+
* The weight/score is so low that the token is likely not very relevant to the original term
125+
126+
Both the token frequency threshold and weight threshold must show the token is non-significant in order for the token to be pruned.
127+
This ensures that:
128+
129+
* The tokens that are kept are frequent enough and have significant scoring.
130+
* Very infrequent tokens that may not have as high of a score are removed.
131+
124132
--
125133

126134
[discrete]
@@ -248,7 +256,7 @@ GET my-index/_search
248256
[[sparse-vector-query-with-pruning-config-and-rescore-example]]
249257
==== Example ELSER query with pruning configuration and rescore
250258

251-
The following is an extension to the above example that adds a preview:[] pruning configuration to the `sparse_vector` query.
259+
The following is an extension to the above example that adds a pruning configuration to the `sparse_vector` query.
252260
The pruning configuration identifies non-significant tokens to prune from the query in order to improve query performance.
253261

254262
Token pruning happens at the shard level.

0 commit comments

Comments
 (0)