Skip to content

Commit 7b5ac90

Browse files
committed
Fix naming, use oversample parameter instead of num_candidates_factor
1 parent 3c60c01 commit 7b5ac90

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

docs/reference/mapping/types/dense-vector.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ The three following quantization strategies are supported:
121121
* `bbq` - experimental:[] Better binary quantization which reduces each dimension to a single bit precision. This reduces the memory footprint by 96% (or 32x) at a larger cost of accuracy. Generally, oversampling during query time and reranking can help mitigate the accuracy loss.
122122

123123

124-
When using a quantized format, you may want to oversample and rescore the results to improve accuracy. See <<dense-vector-knn-search-reranking, oversampling and rescoring>> for more information.
124+
When using a quantized format, you may want to oversample and rescore the results to improve accuracy. See <<dense-vector-knn-search-rescoring, oversampling and rescoring>> for more information.
125125

126126
To use a quantized index, you can set your index type to `int8_hnsw`, `int4_hnsw`, or `bbq_hnsw`. When indexing `float` vectors, the current default
127127
index type is `int8_hnsw`.
128128

129-
Quantized vectors can use <<dense-vector-knn-search-reranking,oversampling and rescoring>> to improve accuracy on approximate kNN search results.
129+
Quantized vectors can use <<dense-vector-knn-search-rescoring,oversampling and rescoring>> to improve accuracy on approximate kNN search results.
130130

131131
NOTE: Quantization will continue to keep the raw float vector values on disk for reranking, reindexing, and quantization improvements over the lifetime of the data.
132132
This means disk usage will increase by ~25% for `int8`, ~12.5% for `int4`, and ~3.1% for `bbq` due to the overhead of storing the quantized and raw vectors.

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,12 +1367,16 @@ tag::knn-rescore-vector[]
13671367
NOTE: Rescoring only makes sense for quantized vectors; when <<dense-vector-quantization,quantization>> is not used, the original vectors are used for scoring.
13681368
Rescore option will be ignored for non-quantized `dense_vector` fields.
13691369

1370-
`num_candidates_factor`::
1370+
`oversample`::
13711371
(Required, float)
13721372
+
1373-
Applies the specified oversample factor to the number of candidates on the approximate kNN search.
1374-
The approximate kNN search will retrieve `num_candidates * num_candidates_factor` candidates per shard, and then use the original vectors for rescoring them.
1373+
Applies the specified oversample factor to `k` on the approximate kNN search.
1374+
The approximate kNN search will:
13751375

1376-
See <<dense-vector-knn-search-reranking,oversampling and rescoring quantized vectors>> for details.
1376+
* Retrieve `num_candidates` candidates per shard.
1377+
* From these candidates, the top `k * oversample` candidates per shard will be rescored using the original vectors.
1378+
* The top `k` rescored candidates will be returned.
1379+
1380+
See <<dense-vector-knn-search-rescoring,oversampling and rescoring quantized vectors>> for details.
13771381
--
13781382
end::knn-rescore-vector[]

docs/reference/search/search-your-data/knn-search.asciidoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ the global top `k` matches across shards. You cannot set the
10701070

10711071

10721072
[discrete]
1073-
[[dense-vector-knn-search-reranking]]
1073+
[[dense-vector-knn-search-rescoring]]
10741074
==== Oversampling and rescoring for quantized vectors
10751075

10761076
When using <<dense-vector-quantization,quantized vectors>> for kNN search, you can optionally rescore results to balance performance and accuracy, by doing:
@@ -1091,10 +1091,13 @@ Generally, we have found that:
10911091
* `bbq` requires rescoring except on exceptionally large indices or models specifically designed for quantization. We have found that between 3x-5x oversampling is generally sufficient. But for fewer dimensions or vectors that do not quantize well, higher oversampling may be required.
10921092

10931093
You can use the `rescore_vector` preview:[] option to automatically perform reranking.
1094-
When a rescore `num_candidates_factor` parameter is specified, the approximate kNN search will retrieve the top `num_candidates * oversample` candidates per shard.
1095-
It will then use the original vectors to rescore them, and return the top `k` results.
1094+
When a rescore `oversample` parameter is specified, the approximate kNN search will:
10961095

1097-
Here is an example of using the `rescore_vector` option with the `num_candidates_factor` parameter:
1096+
* Retrieve `num_candidates` candidates per shard.
1097+
* From these candidates, the top `k * oversample` candidates per shard will be rescored using the original vectors.
1098+
* The top `k` rescored candidates will be returned.
1099+
1100+
Here is an example of using the `rescore_vector` option with the `oversample` parameter:
10981101

10991102
[source,console]
11001103
----
@@ -1106,7 +1109,7 @@ POST image-index/_search
11061109
"k": 10,
11071110
"num_candidates": 100,
11081111
"rescore_vector": {
1109-
"num_candidates_factor": 2.0
1112+
"oversample": 2.0
11101113
}
11111114
},
11121115
"fields": [ "title", "file-type" ]
@@ -1118,18 +1121,19 @@ POST image-index/_search
11181121

11191122
This example will:
11201123

1121-
* Search using approximate kNN with `num_candidates` set to 200 (`num_candidates` * `num_candidates_factor`).
1122-
* Rescore the top 200 candidates per shard using the original, non quantized vectors.
1124+
* Search using approximate kNN for the top 100 candidates.
1125+
* Rescore the top 20 candidates (`oversample * k`) per shard using the original, non quantized vectors.
1126+
* Return the top 10 (`k`) rescored candidates.
11231127
* Merge the rescored canddidates from all shards, and return the top 10 (`k`) results.
11241128

11251129
[discrete]
1126-
[[dense-vector-knn-search-reranking-rescore-additional]]
1130+
[[dense-vector-knn-search-rescoring-rescore-additional]]
11271131
===== Additional rescoring techniques
11281132

11291133
The following sections provide additional ways of rescoring:
11301134

11311135
[discrete]
1132-
[[dense-vector-knn-search-reranking-rescore-section]]
1136+
[[dense-vector-knn-search-rescoring-rescore-section]]
11331137
====== Use the `rescore` section for top-level kNN search
11341138

11351139
You can use this option when you don't want to rescore on each shard, but on the top results from all shards.
@@ -1185,7 +1189,7 @@ gathering 20 nearest neighbors according to quantized scoring and rescoring with
11851189

11861190

11871191
[discrete]
1188-
[[dense-vector-knn-search-reranking-script-score]]
1192+
[[dense-vector-knn-search-rescoring-script-score]]
11891193
====== Use a `script_score` query to rescore per shard
11901194

11911195
You can use this option when you want to rescore on each shard and want more fine-grained control on the rescoring

0 commit comments

Comments
 (0)