1 #ifndef IVF_HNSW_LIB_INDEXIVF_HNSW_GROUPING_H
2 #define IVF_HNSW_LIB_INDEXIVF_HNSW_GROUPING_H
4 #include "IndexIVF_HNSW.h"
21 size_t nbits_per_idx,
size_t nsubcentroids);
30 void add_group(
size_t group_idx,
size_t group_size,
const float *x,
const idx_t *
ids);
32 void search(
size_t k,
const float *x,
float *distances,
long *labels);
34 void write(
const char *path_index);
35 void read(
const char *path_index);
37 void train_pq(
size_t n,
const float *x);
50 void compute_residuals(
size_t n,
const float *x,
float *residuals,
51 const float *subcentroids,
const idx_t *keys);
53 void reconstruct(
size_t n,
float *x,
const float *decoded_residuals,
54 const float *subcentroids,
const idx_t *keys);
56 void compute_subcentroid_idxs(
idx_t *subcentroid_idxs,
const float *subcentroids,
57 const float *points,
size_t group_size);
59 float compute_alpha(
const float *centroid_vectors,
const float *points,
60 const float *centroid,
const float *centroid_vector_norms_L2sqr,
size_t group_size);
63 #endif //IVF_HNSW_LIB_INDEXIVF_HNSW_GROUPING_H
bool do_pruning
Turn on/off pruning.
Definition: IndexIVF_HNSW_Grouping.h:13
std::vector< std::vector< idx_t > > ids
Inverted lists for indexes.
Definition: IndexIVF_HNSW.h:60
std::vector< std::vector< idx_t > > nn_centroid_idxs
Indices of the <nsubc> nearest centroids for each centroid.
Definition: IndexIVF_HNSW_Grouping.h:15
void add_group(size_t group_idx, size_t group_size, const float *x, const idx_t *ids)
Definition: IndexIVF_HNSW_Grouping.cpp:21
std::vector< std::vector< idx_t > > subgroup_sizes
Sizes of sub-groups for each group.
Definition: IndexIVF_HNSW_Grouping.h:16
void search(size_t k, const float *x, float *distances, long *labels)
Definition: IndexIVF_HNSW_Grouping.cpp:159
std::vector< float > alphas
Coefficients that determine the location of sub-centroids.
Definition: IndexIVF_HNSW_Grouping.h:17
Definition: IndexIVF_HNSW.h:42
std::vector< std::vector< float > > inter_centroid_dists
Distances between coarse centroids and their sub-centroids.
Definition: IndexIVF_HNSW_Grouping.h:47
size_t nsubc
Number of sub-centroids per group.
Definition: IndexIVF_HNSW_Grouping.h:12
void train_pq(size_t n, const float *x)
Definition: IndexIVF_HNSW_Grouping.cpp:368
void write(const char *path_index)
Write index to the path.
Definition: IndexIVF_HNSW_Grouping.cpp:285
std::vector< float > query_centroid_dists
Distances to the coarse centroids. Used for distance computation between a query and base points...
Definition: IndexIVF_HNSW_Grouping.h:44
Definition: IndexIVF_HNSW_Grouping.h:10
void compute_inter_centroid_dists()
Compute distances between the group centroid and its <subc> nearest neighbors in the HNSW graph...
Definition: IndexIVF_HNSW_Grouping.cpp:502
void read(const char *path_index)
Read index from the path.
Definition: IndexIVF_HNSW_Grouping.cpp:326
uint32_t idx_t
all indices are this type
Definition: IndexIVF_HNSW.h:44