#[repr(C)]pub struct cuvsIvfPqIndexParams {Show 13 fields
pub metric: cuvsDistanceType,
pub metric_arg: f32,
pub add_data_on_build: bool,
pub n_lists: u32,
pub kmeans_n_iters: u32,
pub kmeans_trainset_fraction: f64,
pub pq_bits: u32,
pub pq_dim: u32,
pub codebook_kind: cuvsIvfPqCodebookGen,
pub force_random_rotation: bool,
pub conservative_memory_allocation: bool,
pub max_train_points_per_pq_code: u32,
pub codes_layout: cuvsIvfPqListLayout,
}Expand description
@brief Supplemental parameters to build IVF-PQ Index
Fields§
§metric: cuvsDistanceTypeDistance type.
metric_arg: f32The argument used by some distance metrics.
add_data_on_build: boolWhether to add the dataset content to the index, i.e.:
truemeans the index is filled with the dataset vectors and ready to search after callingbuild.falsemeansbuildonly trains the underlying model (e.g. quantizer or clustering), but the index is left empty; you’d need to callextendon the index afterwards to populate it.
n_lists: u32The number of inverted lists (clusters)
Hint: the number of vectors per cluster (n_rows/n_lists) should be approximately 1,000 to
10,000.
kmeans_n_iters: u32The number of iterations searching for kmeans centers (index building).
kmeans_trainset_fraction: f64The fraction of data to use during iterative kmeans building.
pq_bits: u32The bit length of the vector element after compression by PQ.
Possible values: [4, 5, 6, 7, 8].
Hint: the smaller the ‘pq_bits’, the smaller the index size and the better the search performance, but the lower the recall.
pq_dim: u32The dimensionality of the vector after compression by PQ. When zero, an optimal value is selected using a heuristic.
NB: pq_dim * pq_bits must be a multiple of 8.
Hint: a smaller ‘pq_dim’ results in a smaller index size and better search performance, but lower recall. If ‘pq_bits’ is 8, ‘pq_dim’ can be set to any number, but multiple of 8 are desirable for good performance. If ‘pq_bits’ is not 8, ‘pq_dim’ should be a multiple of 8. For good performance, it is desirable that ‘pq_dim’ is a multiple of 32. Ideally, ‘pq_dim’ should be also a divisor of the dataset dim.
codebook_kind: cuvsIvfPqCodebookGenHow PQ codebooks are created.
force_random_rotation: boolApply a random rotation matrix on the input data and queries even if dim % pq_dim == 0.
Note: if dim is not multiple of pq_dim, a random rotation is always applied to the input
data and queries to transform the working space from dim to rot_dim, which may be slightly
larger than the original space and and is a multiple of pq_dim (rot_dim % pq_dim == 0).
However, this transform is not necessary when dim is multiple of pq_dim
(dim == rot_dim, hence no need in adding “extra” data columns / features).
By default, if dim == rot_dim, the rotation transform is initialized with the identity
matrix. When force_random_rotation == true, a random orthogonal transform matrix is generated
regardless of the values of dim and pq_dim.
conservative_memory_allocation: boolBy default, the algorithm allocates more space than necessary for individual clusters
(list_data). This allows to amortize the cost of memory allocation and reduce the number of
data copies during repeated calls to extend (extending the database).
The alternative is the conservative allocation behavior; when enabled, the algorithm always
allocates the minimum amount of memory required to store the given number of records. Set this
flag to true if you prefer to use as little GPU memory for the database as possible.
max_train_points_per_pq_code: u32The max number of data points to use per PQ code during PQ codebook training. Using more data
points per PQ code may increase the quality of PQ codebook but may also increase the build
time. The parameter is applied to both PQ codebook generation methods, i.e., PER_SUBSPACE and
PER_CLUSTER. In both cases, we will use pq_book_size * max_train_points_per_pq_code training
points to train each codebook.
codes_layout: cuvsIvfPqListLayoutMemory layout of the IVF-PQ list data.
- CUVS_IVF_PQ_LIST_LAYOUT_FLAT: Codes are stored contiguously, one vector’s codes after another.
- CUVS_IVF_PQ_LIST_LAYOUT_INTERLEAVED: Codes are interleaved for optimized search performance. This is the default and recommended for search workloads.
Trait Implementations§
Source§impl Clone for cuvsIvfPqIndexParams
impl Clone for cuvsIvfPqIndexParams
Source§fn clone(&self) -> cuvsIvfPqIndexParams
fn clone(&self) -> cuvsIvfPqIndexParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more