Vector index
Overview of vector indexes
Vector retrieval represents items such as products or content as vectors and builds a vector index library from them. You can query the index library with one or more user or product vectors to retrieve the top K products or content items based on vector distance.
Vector index configuration
Vector configuration without categories
{
"table_name": "test_vector",
"summarys": {
"summary_fields": [
"id",
"vector_field"
]
},
"indexs": [
{
"index_name": "pk",
"index_type": "PRIMARYKEY64",
"index_fields": "id",
"has_primary_key_attribute": true,
"is_primary_key_sorted": false
},
{
"index_name": "embedding",
"index_type": "CUSTOMIZED",
"index_fields": [
{
"boost": 1,
"field_name": "id"
},
{
"boost": 1,
"field_name": "vector_field"
}
],
"indexer": "aitheta2_indexer",
"parameters": {
"enable_rt_build": "false",
"min_scan_doc_cnt": "20000",
"vector_index_type": "Qc",
"major_order": "col",
"builder_name": "QcBuilder",
"distance_type": "SquaredEuclidean",
"embedding_delimiter": ",",
"enable_recall_report": "false",
"is_embedding_saved": "false",
"linear_build_threshold": "5000",
"dimension": "128",
"search_index_params": "{\"proxima.qc.searcher.scan_ratio\":0.01}",
"searcher_name": "QcSearcher",
"build_index_params": "{\"proxima.qc.builder.quantizer_class\":\"Int8QuantizerConverter\",\"proxima.qc.builder.quantize_by_centroid\":true,\"proxima.qc.builder.optimizer_class\":\"BruteForceBuilder\",\"proxima.qc.builder.thread_count\":10,\"proxima.qc.builder.optimizer_params\":{\"proxima.linear.builder.column_major_order\":true},\"proxima.qc.builder.store_original_features\":false,\"proxima.qc.builder.train_sample_count\":3000000,\"proxima.qc.builder.train_sample_ratio\":0.5}"
}
}
],
"attributes": [
"id",
"vector_field"
],
"fields": [
{
"field_name": "id",
"field_type": "INTEGER"
},
{
"user_defined_param": {
"multi_value_sep": ","
},
"field_name": "vector_field",
"field_type": "FLOAT",
"multi_value": true
}
]
}Vector configuration with categories
{
"table_name": "test_vector",
"summarys": {
"summary_fields": [
"id",
"vector_field",
"category_id"
]
},
"indexs": [
{
"index_name": "pk",
"index_type": "PRIMARYKEY64",
"index_fields": "id",
"has_primary_key_attribute": true,
"is_primary_key_sorted": false
},
{
"index_name": "embedding",
"index_type": "CUSTOMIZED",
"index_fields": [
{
"boost": 1,
"field_name": "id"
},
{
"field_name": "category_id",
"boost": 1
},
{
"boost": 1,
"field_name": "vector_field"
}
],
"indexer": "aitheta2_indexer",
"parameters": {
"enable_rt_build": "false",
"min_scan_doc_cnt": "20000",
"vector_index_type": "Qc",
"major_order": "col",
"builder_name": "QcBuilder",
"distance_type": "SquaredEuclidean",
"embedding_delimiter": ",",
"enable_recall_report": "false",
"is_embedding_saved": "false",
"linear_build_threshold": "5000",
"dimension": "128",
"search_index_params": "{\"proxima.qc.searcher.scan_ratio\":0.01}",
"searcher_name": "QcSearcher",
"build_index_params": "{\"proxima.qc.builder.quantizer_class\":\"Int8QuantizerConverter\",\"proxima.qc.builder.quantize_by_centroid\":true,\"proxima.qc.builder.optimizer_class\":\"BruteForceBuilder\",\"proxima.qc.builder.thread_count\":10,\"proxima.qc.builder.optimizer_params\":{\"proxima.linear.builder.column_major_order\":true},\"proxima.qc.builder.store_original_features\":false,\"proxima.qc.builder.train_sample_count\":3000000,\"proxima.qc.builder.train_sample_ratio\":0.5}"
}
}
],
"attributes": [
"id",
"vector_field",
"category_id"
],
"fields": [
{
"field_name": "id",
"field_type": "INTEGER"
},
{
"user_defined_param": {
"multi_value_sep": ","
},
"field_name": "vector_field",
"field_type": "FLOAT",
"multi_value": true
},
{
"field_name": "category_id",
"field_type": "INTEGER"
}
]
}Categories are introduced to support vector retrieval by category. For example, images can belong to different categories. If you build a vector index without specifying categories and only filter the retrieved vectors, the query may return no results.
When you configure a vector index in administrator mode, remove the escape characters from the values of build_index_params and search_index_params.
Field descriptions
field_name: the fields used to build the vector index. The fields must be of the RAW type. At least two fields are required: one is the primary key (or the hash value of the primary key), whose values must be integers, and the other is the field that contains the vectors. If you want to build the index for vectors by category, you can add a category field of the RAW type whose values are integers. The order of these fields in the index must be the same as the order configured in fields, and the fields must follow this order: primary key, category (if any), and vector.
index_name: the name of the vector index.
index_type: the index type. The value must be CUSTOMIZED.
indexer: the plug-in used to build the vector index. Only aitheta2_indexer is supported.
parameters: the build parameters and query parameters of the vector index.
dimension: the number of dimensions.
embedding_delimiter: the vector delimiter. Default value: ",".
distance_type: the distance type. Only the following two types are supported:
InnerProduct (inner product)
SquaredEuclidean (squared Euclidean distance). Configure SquaredEuclidean for normalized data.
major_order: the data storage method. The following two methods are supported:
col (column-based storage; the dimension must be a power of 2; provides better performance)
row (row-based storage; used by default)
builder_name: the index build type. We recommend that you configure one of the following two types. (For more parameters, contact us.)
QcBuilder
LinearBuilder (linear build; recommended when the number of documents is less than 10,000)
searcher_name: the index retrieval type, which corresponds to builder_name. If you have GPU requirements, contact us.
QcSearcher (CPU-based retrieval; corresponds to QcBuilder)
LinearSearcher (CPU-based brute-force retrieval; corresponds to LinearBuilder)
build_index_params: the index build parameters, which correspond to builder_name. For more information, see the Quantized Clustering configuration configuration.
search_index_params: the index retrieval parameters, which correspond to searcher_name. For more information, see the search_index_params configuration.
linear_build_threshold: the threshold for linear build. If the number of documents is lower than this threshold, LinearBuilder is used for building and LinearSearcher is used for retrieval. Default value: 10000. Linear build saves memory and produces lossless retrieval results, but its performance is extremely poor when the data volume is large.
min_scan_doc_cnt: the minimum number of documents in the retrieval candidate set. Default value: 10000. This parameter is similar in concept to proxima.qc.searcher.scan_ratio. If both parameters are configured, the larger of the two values is used.
Larger values of scan_ratio&min_scan_doc_cnt are not always better. Excessively large values significantly degrade performance&latency.
In general, if you retrieve the top K vectors, we recommend that you set min_scan_doc_cnt to max(10000, 100*topk) and scan_ratio to max(10000, 100*topk)/total_doc_cnt. The actual values must be determined based on factors such as the data volume, recall rate, and performance.
Two similar parameters exist mainly to meet the requirements of real-time and multi-category scenarios. In most cases, you only need to configure scan_ratio.
enable_recall_report: specifies whether to enable reporting of the recall rate metric. This feature is disabled by default.
is_embedding_saved: specifies whether to save the original vectors. This feature is disabled by default. If INT8/FP16 quantization and real-time retrieval are enabled, you must enable this option. Otherwise, batch incremental builds fail.
enable_rt_build: specifies whether to support real-time indexes. This feature is enabled by default.
ignore_invalid_doc: specifies whether to ignore invalid vector data. This feature is enabled by default.
rt_index_params: the real-time index parameters, which can be configured when enable_rt_build is set to true. Example:
{ "proxima.oswg.streamer.segment_size": 2048 }