You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/query-dsl/sparse-vector-query.asciidoc
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ This can be achieved with one of two strategies:
11
11
- Using an {nlp} model to convert query text into a list of token-weight pairs
12
12
- Sending in precalculated token-weight pairs as query vectors
13
13
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>>
15
15
or a <<semantic-text, semantic_text>> field with a compatible sparse inference model.
16
16
At query time, query vectors are calculated using the same inference model that was used to create the tokens.
17
17
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.
83
83
84
84
`prune` ::
85
85
(Optional, boolean)
86
-
preview:[]
87
86
Whether to perform pruning, omitting the non-significant tokens from the query to improve query performance.
88
87
If `prune` is true but the `pruning_config` is not specified, pruning will occur but default values will be used.
89
88
Default: false.
90
89
91
90
`pruning_config` ::
92
91
(Optional, object)
93
-
preview:[]
94
92
Optional pruning configuration.
95
93
If enabled, this will omit non-significant tokens from the query in order to improve query performance.
96
94
This is only used if `prune` is set to `true`.
@@ -101,26 +99,36 @@ Parameters for `pruning_config` are:
101
99
102
100
`tokens_freq_ratio_threshold`::
103
101
(Optional, integer)
104
-
preview:[]
105
102
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.
106
103
This value must between 1 and 100.
107
104
Default: `5`.
108
105
109
106
`tokens_weight_threshold`::
110
107
(Optional, float)
111
-
preview:[]
112
108
Tokens whose weight is less than `tokens_weight_threshold` are considered insignificant and pruned.
113
109
This value must be between 0 and 1.
114
110
Default: `0.4`.
115
111
116
112
`only_score_pruned_tokens`::
117
113
(Optional, boolean)
118
-
preview:[]
119
114
If `true` we only input pruned tokens into scoring, and discard non-pruned tokens.
120
115
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.
121
116
Default: `false`.
122
117
123
118
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.
0 commit comments