External Build
In addition to using the methods in Partitioning Tuning to achieve shorter build time and lower memory consumption at the cost of QPS and recall, you can also choose to run the partitioning phase offline on other machines or on GPUs. This feature is not supported by vchordg, since it does not have a partitioning phase.
Assume the table is t and the column to be indexed is val.
Specifically, you need to sample the column for which the index will be built.
Based on these samples, you can partition the vector space into Voronoi cells. After that, you will create a table and insert your partitions.
The index can be created using the following syntax.
Format
The table that stores the partition information must strictly follow the following schema:
- The first column must be
id. Its type isinteger. It must not be null. It must be unique. - The second column must be
parent. Its type isinteger. It could not be null. - The third column must be
vector. Its type isvector. It must not be null.halfvecor other types are not supported yet.
Logically, this forms a tree. The distance from the root to each leaf must be the same.
If any of the above properties are not satisfied, an error will be reported.
Partitioning
To get started, here is a minimal code example for performing partitioning using faiss.
This computes the generators of all Voronoi cells across different levels. The parent-child relationships in the tree are determined by computing the shortest distances, but the details are omitted here. Any algorithm capable of generating multi-level Voronoi cells can be used, such as spherical K-means, balanced K-means or GPU K-means.