Skip to content

Commit 8bd84c1

Browse files
Docs: vector search concept (#17102)
Co-authored-by: anton-bobkov <anton-bobkov@ydb.tech>
1 parent 19c4e7f commit 8bd84c1

File tree

27 files changed

+427
-431
lines changed

27 files changed

+427
-431
lines changed

ydb/docs/en/core/concepts/_includes/secondary_indexes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Currently, a unique index cannot be added to an existing table.
3333

3434
## Vector Index
3535

36-
[Vector Index](vector_indexes.md) is a special type of secondary index.
36+
[Vector Index](../../dev/vector-indexes.md) is a special type of secondary index.
3737

38-
Unlike secondary indexes, which optimize equality or range searches, vector indexes allow similarity searches based on distance or similarity functions.
38+
Unlike secondary indexes, which optimize equality or range searches, vector indexes allow [vector search](../vector_search.md) based on distance or similarity functions.
3939

4040
### Creating a Secondary Index Online {#index-add}
4141

ydb/docs/en/core/concepts/_includes/vector_indexes.md

Lines changed: 0 additions & 118 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Approximate methods do not perform a complete enumeration of the initial data. This allows significantly speeding up the search process, although it might lead to some reduction in the quality of the results.
2+
3+
[Scalar Quantization](../../yql/reference/udf/list/knn.md#approximate-vector-search-scalar-quantization) is a method of reducing vector dimensionality, where a set of coordinates is mapped into a space of smaller dimensions.
4+
5+
{{ ydb-short-name }} supports vector searching for vector types `Float`, `Int8`, `Uint8`, and `Bit`. Consequently, it is possible to apply scalar quantization to transform data from `Float` to any of these types.
6+
7+
Scalar quantization reduces the time required for reading and writing data by decreasing the number of bytes. For example, when quantizing from `Float` to `Bit`, each vector is reduced by 32 times.
8+
9+
[Approximate vector search without an index](../../yql/reference/udf/list/knn.md#approximate-vector-search-examples) uses a very simple additional data structure - a set of vectors with other quantization. This allows the use of a simple search algorithm: first, a rough preliminary search is performed on the compressed vectors, followed by refining the results on the original vectors.
10+
11+
Main advantages:
12+
13+
* Full support for [transactions](../../concepts/glossary.md#transactions), including in strict consistency mode.
14+
* Instant application of data modification operations: insertion, update, deletion.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The foundation of the exact method is the calculation of the distance from the query vector to all the vectors in the dataset. This algorithm, also known as the naive approach or brute force method, has a runtime of `O(dn)`, where `n` is the number of vectors in the dataset, and `d` is their dimensionality.
2+
3+
[Exact vector search](../../yql/reference/udf/list/knn.md#exact-vector-search-examples) is best utilized if the complete enumeration of the vectors occurs within acceptable time limits. This includes cases where they can be pre-filtered based on some condition, such as a user identifier. In such instances, the exact method may perform faster than the current implementation of [vector indexes](../../dev/vector-indexes.md).
4+
5+
Main advantages:
6+
7+
* No need for additional data structures, such as specialized [vector indexes](../../concepts/glossary.md#vector-index).
8+
* Full support for [transactions](../../concepts/glossary.md#transactions), including in strict consistency mode.
9+
* Instant execution of data modification operations: insertion, update, deletion.

ydb/docs/en/core/concepts/glossary.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Technically, tablets are [actors](#actor) with a persistent state reliably saved
100100

101101
Together, these mechanisms allow {{ ydb-short-name }} to provide [strict consistency](https://en.wikipedia.org/wiki/Consistency_model#Strict_consistency).
102102

103-
The implementation of distributed transactions is covered in a separate article [{#T}](../contributor/datashard-distributed-txs.md), while below there's a list of several [related terms](#distributed-transaction-implementation).
103+
The implementation of distributed transactions is covered in a separate article [{#T}](../contributor/datashard-distributed-txs.md), while below there's a list of several [related terms](#deterministic-transactions).
104104

105105
### Interactive transactions {#interactive-transaction}
106106

@@ -162,9 +162,10 @@ A special type of **secondary index** is singled out separately - [vector index]
162162

163163
#### Vector Index {#vector-index}
164164

165-
A **vector index** is an additional data structure used to speed up the [nearest neighbor search](https://en.wikipedia.org/wiki/Nearest_neighbor_search), typically when the data is too large for the [index-less approach](../yql/reference/udf/list/knn.md) to handle the load. Unlike the primary index, vector indexes are managed independently of the underlying table data. Thus, a table can have multiple vector indexes for different scenarios. For more information about using vector indexes in {{ ydb-short-name }}, see [{#T}](vector_indexes.md).
165+
**Vector index** is an additional data structure used to speed up the [vector search](vector_search.md) when there is a large amount of data, and the [exact vector search without an index](../yql/reference/udf/list/knn.md) does not perform satisfactorily. The capabilities of {{ ydb-short-name }} regarding vector indexes are described in a separate article [{#T}](../dev/vector-indexes.md).
166+
167+
**Vector index** is distinct from a [secondary index](#secondary-index) as it solves other tasks.
166168

167-
A **vector index** is allocated separately from the [secondary index] (#secondary-index), as it solves other tasks.
168169

169170
#### Column family {#column-family}
170171

ydb/docs/en/core/concepts/toc_i.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ items:
1414
href: transactions.md
1515
- name: Secondary indexes
1616
href: secondary_indexes.md
17-
- name: Vector indexes
18-
href: vector_indexes.md
17+
- name: Vector search
18+
href: vector_search.md
1919
- name: Change Data Capture (CDC)
2020
href: cdc.md
2121
when: feature_changefeed

ydb/docs/en/core/concepts/vector_indexes.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Vector search
2+
3+
## Concept of vector search
4+
5+
**Vector search**, also known as [nearest neighbor search](https://en.wikipedia.org/wiki/Nearest_neighbor_search) (NN), is an optimization problem where the goal is to find the nearest vector (or a set of vectors) in a given dataset relative to a specified query vector. The proximity between vectors is determined using distance or similarity metrics.
6+
7+
Vector search is actively used in the following areas:
8+
9+
* recommendation systems
10+
* semantic search
11+
* search for similar images
12+
* anomaly detection
13+
* classification systems
14+
15+
In addition, **vector search** in {{ ydb-short-name }} is widely applied in machine learning (ML) and artificial intelligence (AI) tasks. It is particularly useful in Retrieval-Augmented Generation (RAG) approaches, which utilize vector search to retrieve relevant information from large volumes of data, significantly enhancing the quality of generative models.
16+
17+
Methods for solving vector search tasks can be divided into three major categories:
18+
19+
* [exact methods](#vector-search-exact)
20+
* [approximate methods without index](#vector-search-approximate)
21+
* [approximate methods with index](#vector-search-index)
22+
23+
The choice of a method depends on the number of vectors and the nature of the workload. Exact methods search slowly but update quickly, whereas indexes do the opposite.
24+
25+
## Exact vector search {#vector-search-exact}
26+
27+
{% include [vector_search_exact.md](_includes/vector_search_exact.md) %}
28+
29+
Learn more about [exact vector search](../yql/reference/udf/list/knn.md#exact-vector-search-examples).
30+
31+
## Approximate vector search without index {#vector-search-approximate}
32+
33+
{% include [vector_search_approximate.md](_includes/vector_search_approximate.md) %}
34+
35+
Learn more about [approximate vector search without index](../yql/reference/udf/list/knn.md#approximate-vector-search-examples).
36+
37+
## Approximate vector search with index {#vector-search-index}
38+
39+
When the data volume significantly increases, non-index approaches cease to work within acceptable time limits. In such cases, additional data structures are necessary such as [vector indexes](../dev/vector-indexes.md), which accelerate the search process.
40+
41+
Main advantage:
42+
43+
* ability to work with a large number of vectors
44+
45+
Disadvantages:
46+
47+
* index construction may take considerable time
48+
* in the current version, data modification operations such as insertion, update, and deletion are not supported

0 commit comments

Comments
 (0)