Skip to content

Commit e9fe19b

Browse files
committed
Adds links to relocated content
1 parent 03d5d26 commit e9fe19b

File tree

1 file changed

+2
-156
lines changed

1 file changed

+2
-156
lines changed

solutions/search/vector/dense-vector.md

Lines changed: 2 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -29,160 +29,6 @@ Dense vector search requires both index configuration and a strategy for generat
2929

3030
## Better Binary Quantization (BBQ) [bbq]
3131

32-
Better Binary Quantization (BBQ) is an advanced vector quantization method, designed for large-scale similarity search. BBQ is a form of lossy compression for [`dense_vector` fields](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dense-vector) that enables efficient storage and retrieval of large numbers of vectors, while keeping results close to those from the original uncompressed vectors.
33-
34-
BBQ offers significant improvements over scalar quantization by relying on optimized `bit` level computations to reduce memory usage and computational costs while maintaining high search relevance using pre-computed corrective factors. BBQ is designed to work in combination with [oversampling](#bbq-oversampling) and reranking, and is compatible with various [vector search algorithms](#bbq-vector-search-algorithms), such as [HNSW](#bbq-hnsw) and [brute force (flat)](#bbq-flat).
35-
36-
### How BBQ works [bbq-how-it-works]
37-
38-
BBQ retains the original vector’s dimensionality but transforms the datatype of the dimensions from the original `float32` to `bit` effectively compressing each vector by 32x plus an additional 14 bytes of corrective data per vector. BBQ uses these pre-computed corrective factors as partial distance calculations to help realize impressively robust approximations of the original vector.
39-
40-
Measuring vector similarity with BBQ vectors requires much less computing effort, allowing more candidates to be considered when using the HNSW algorithm. This often results in better ranking quality and improved relevance compared to the original `float32` vectors.
41-
42-
### Supported vector search algorithms [bbq-vector-search-algorithms]
43-
44-
BBQ currently supports two vector search algorithms, each suited to different scenarios. You can configure them by setting the dense vector field’s `index_type`.
45-
46-
#### `bbq_hnsw` [bbq-hnsw]
47-
48-
When you set a dense vector field’s `index_options` parameter to `type: bbq_hnsw`, {{es}} uses the HNSW algorithm for fast [kNN search](https://www.elastic.co/docs//solutions/search/vector/knn) on compressed vectors. With the default [oversampling](#bbq-oversampling) applied, it delivers better cost efficiency, lower latency, and improved relevance ranking, making it the best choice for large-scale similarity search.
49-
50-
:::{note}
51-
Starting in version 9.1, `bbq_hnsw` is the default indexing method for new `dense_vector` fields with greater than 384 dimensions, so you typically don’t need to specify it explicitly when creating an index.
52-
53-
Datasets with less than 384 dimensions may see less accuracy and incur a higher overhead cost related to the corrective factors, but we have observed some production datasets perform well even at fairly low dimensions including [tests on e5-small](https://www.elastic.co/search-labs/blog/better-binary-quantization-lucene-elasticsearch).
54-
:::
55-
56-
The following example creates an index with a `dense_vector` field configured to use the `bbq_hnsw` algorithm.
57-
58-
```console
59-
PUT bbq_hnsw-index
60-
{
61-
"mappings": {
62-
"properties": {
63-
"my_vector": {
64-
"type": "dense_vector",
65-
"dims": 64,
66-
"index": true,
67-
"index_options": {
68-
"type": "bbq_hnsw"
69-
}
70-
}
71-
}
72-
}
73-
}
74-
```
75-
76-
To change an existing index to use `bbq_hnsw`, update the field mapping:
77-
78-
```console
79-
PUT bbq_hnsw-index/_mapping
80-
{
81-
"properties": {
82-
"my_vector": {
83-
"type": "dense_vector",
84-
"dims": 64,
85-
"index": true,
86-
"index_options": {
87-
"type": "bbq_hnsw"
88-
}
89-
}
90-
}
91-
}
92-
```
93-
94-
After this change, all newly created segments will use the `bbq_hnsw` algorithm. As you add or update documents, the index will gradually convert to `bbq_hnsw`.
95-
96-
To apply `bbq_hnsw` to all vectors at once, reindex them into a new index where the `index_options` parameter's `type` is set to `bbq_hnsw`:
97-
98-
:::::{stepper}
99-
::::{step} Create a destination index
100-
```console
101-
PUT my-index-bbq
102-
{
103-
"mappings": {
104-
"properties": {
105-
"my_vector": {
106-
"type": "dense_vector",
107-
"dims": 64,
108-
"index": true,
109-
"index_options": {
110-
"type": "bbq_hnsw"
111-
}
112-
}
113-
}
114-
}
115-
}
116-
```
117-
::::
118-
119-
::::{step} Reindex the data
120-
```console
121-
POST _reindex
122-
{
123-
"source": { "index": "my-index" }, <1>
124-
"dest": { "index": "my-index-bbq" }
125-
}
126-
```
127-
1. The existing index to be reindexed into the newly created index with the `bbq_hnsw` algorithm.
128-
::::
129-
130-
:::::
131-
132-
#### `bbq_flat` [bbq-flat]
133-
134-
When you set a dense vector field’s `index_options` parameter to `type: bbq_flat`, {{es}} uses the BBQ algorithm without HNSW. This option generally requires fewer computing resources and works best when the number of vectors being searched is relatively low.
135-
136-
The following example creates an index with a `dense_vector` field configured to use the `bbq_flat` algorithm.
137-
138-
```console
139-
PUT bbq_flat-index
140-
{
141-
"mappings": {
142-
"properties": {
143-
"my_vector": {
144-
"type": "dense_vector",
145-
"dims": 64,
146-
"index": true,
147-
"index_options": {
148-
"type": "bbq_flat"
149-
}
150-
}
151-
}
152-
}
153-
}
154-
```
155-
156-
### Oversampling [bbq-oversampling]
157-
158-
Oversampling is a technique used with BBQ searches to reduce the accuracy loss from compression. Compression lowers the memory footprint by over 95% and improves query latency, at the cost of decreased result accuracy. This decrease can be mitigated by oversampling during query time and reranking the top results using the full vector.
159-
160-
When you run a kNN search on a BBQ-indexed field, {{es}} automatically retrieves more candidate vectors than the number of results you request. This oversampling improves accuracy by giving the system more vectors to re-rank using their full-precision values before returning the top results.
161-
162-
```console
163-
GET bbq-index/_search
164-
{
165-
"knn": {
166-
"field": "my_vector",
167-
"query_vector": [0.12, -0.45, ...],
168-
"k": 10,
169-
"num_candidates": 100
170-
}
171-
}
172-
```
173-
174-
By default, oversampling is set to 3×, meaning if you request k:10, {{es}} retrieves 30 candidates for re-ranking. You don’t need to configure this behavior; it’s applied automatically for BBQ searches.
175-
176-
:::{note}
177-
You can change oversampling from the default 3× to another value. Refer to [Oversampling and rescoring for quantized vectors](https://www.elastic.co/docs/solutions/search/vector/knn#dense-vector-knn-search-rescoring) for details.
178-
:::
179-
180-
### Learn more [bbq-learn-more]
181-
182-
- [Better Binary Quantization (BBQ) in Lucene and {{es}}](https://www.elastic.co/search-labs/blog/better-binary-quantization-lucene-elasticsearch) - Learn how BBQ works, its benefits, and how it reduces memory usage while preserving search accuracy.
183-
- [Dense vector field type](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dense-vector) - Find code examples for using `bbq_hnsw` `index_type`.
184-
- [kNN search](https://www.elastic.co/docs/solutions/search/vector/knn) - Learn about the search algorithm that BBQ works with.
185-
186-
187-
32+
Better Binary Quantization (BBQ) is a vector quantization method for `dense_vector` fields that compresses vectors for faster and more memory-efficient similarity search. BBQ can improve relevance and cost efficiency, especially when used with HNSW.
18833

34+
For details on how BBQ works, supported algorithms, and configuration examples, refer to [Better Binary Quantization (BBQ)](https://www.elastic.co/docs/reference/elasticsearch/index-settings/bbq)

0 commit comments

Comments
 (0)