Multi-vector-based query for a single document

更新时间:
复制 MD 格式

Overview

You can store multiple vectors in a single vector field of a document for retrieval. For example, with a vector dimension of 128, you can store a combined vector whose total dimension is a multiple of 128, such as 256 for two vectors or 384 for three vectors. When you perform a query, the document is retrieved if any vector in the field matches your query.

Use cases

Split a long text into segments, vectorize each segment, and store the resulting vectors in a single vector field for retrieval.

Usage

In this example, 128-dimensional vectors are used.

This example uses a table named test, configured with a primary key field named aaa (STRING type) and a vector field named vector (FLOAT type). In the advanced settings for the vector index, the distance metric is set to SquaredEuclidean, and the indexing algorithm is set to Qc.

The vector field is named vector. The Vector Dimension parameter of the vector index is 128. To retrieve a document by retrieving one or more vectors in the document, you need to push 128-dimensional vectors to the vector field and separate the vectors with the delimiter that is used to separate the elements in a vector in the vector field. The following figure shows the format of three vectors to be stored in a vector field if the delimiter is a comma (,).

image.png

When you perform a query, specify 128-dimensional vectors as the vectors to be queried. If one of the vectors in a document is retrieved, the document is retrieved.

During the sorting and scoring phase, if a query matches multiple vectors in a single document, the document's vector similarity score is the best score among the matches. For Euclidean distance, a lower score indicates higher relevance. For inner product, a higher score indicates higher relevance.