diff --git a/pecos/core/ann/hnsw.hpp b/pecos/core/ann/hnsw.hpp index 283a0273..bebeffa6 100644 --- a/pecos/core/ann/hnsw.hpp +++ b/pecos/core/ann/hnsw.hpp @@ -248,8 +248,13 @@ namespace ann { ProductQuantizer4Bits quantizer; index_type num_node; + // code_dimension is number of 4 bits code used to encode a data point in GraphPQ4Bits + // code_dimension can be different from parameter num_local_codebooks in quantizer + // as we might adjust code_dimension to make it divisble by 4. More details can be + // found in pad_parameters function of ann/quantizer_impl/x86.hpp size_t code_dimension; - size_t code_offset; + // code_offset helps to locate memory position containing neighboring codes + size_t code_offset; size_t node_mem_size; index_type max_degree; std::vector mem_start_of_node; @@ -1025,8 +1030,8 @@ namespace ann { index_type efC; // size of priority queue for construction time index_type max_level; index_type init_node; - index_type subspace_dimension; - index_type sub_sample_points; + index_type subspace_dimension; // dimension of each subspace in Product Quantization + index_type sub_sample_points; // number of sub-sampled points used to build quantizer subspace centors. GraphL0 feature_vec; // feature vectors only GraphL1 graph_l1; // neighborhood graphs from level 1 and above diff --git a/pecos/core/ann/quantizer_impl/common.hpp b/pecos/core/ann/quantizer_impl/common.hpp index 279f9a30..c319bd33 100644 --- a/pecos/core/ann/quantizer_impl/common.hpp +++ b/pecos/core/ann/quantizer_impl/common.hpp @@ -22,8 +22,14 @@ namespace ann { struct ProductQuantizer4BitsBase { + // num_of_local_centroids denotes number of cluster centers used in quantization + // In 4 Bit case, it's a fixed to be 16 const size_t num_of_local_centroids = 16; + // num_local_codebooks denotes number of local codebooks we have or in other words, + // number of subspace we have in Product Quantization. + // Supposedly, num_local_codebooks * local_dimension equals dimension of original data vector index_type num_local_codebooks; + // local dimension denotes the dimensionality of subspace in Product Quantization int local_dimension; std::vector global_centroid; std::vector local_codebooks;