diff --git a/pecos/core/ann/hnsw.hpp b/pecos/core/ann/hnsw.hpp index f9954b0..051d02b 100644 --- a/pecos/core/ann/hnsw.hpp +++ b/pecos/core/ann/hnsw.hpp @@ -25,12 +25,11 @@ #include #include - - #include "ann/feat_vectors.hpp" #include "ann/quantizer.hpp" #include "third_party/nlohmann_json/json.hpp" #include "utils/file_util.hpp" +#include "utils/mmap_util.hpp" #include "utils/matrix.hpp" #include "utils/random.hpp" #include "utils/type_util.hpp" @@ -94,44 +93,27 @@ namespace ann { index_type feat_dim; index_type max_degree; index_type node_mem_size; - std::vector mem_start_of_node; - std::vector buffer; + mmap_util::MmapableVector mem_start_of_node; + mmap_util::MmapableVector buffer; size_t neighborhood_memory_size() const { return (1 + max_degree) * sizeof(index_type); } - void save(FILE *fp) const { - pecos::file_util::fput_multiple(&num_node, 1, fp); - pecos::file_util::fput_multiple(&feat_dim, 1, fp); - pecos::file_util::fput_multiple(&max_degree, 1, fp); - pecos::file_util::fput_multiple(&node_mem_size, 1, fp); - size_t sz = mem_start_of_node.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&mem_start_of_node[0], sz, fp); - } - sz = buffer.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&buffer[0], sz, fp); - } + void save(mmap_util::MmapStore& mmap_s) const { + mmap_s.fput_one(this->num_node); + mmap_s.fput_one(this->feat_dim); + mmap_s.fput_one(this->max_degree); + mmap_s.fput_one(this->node_mem_size); + this->mem_start_of_node.save_to_mmap_store(mmap_s); + this->buffer.save_to_mmap_store(mmap_s); } - void load(FILE *fp) { - pecos::file_util::fget_multiple(&num_node, 1, fp); - pecos::file_util::fget_multiple(&feat_dim, 1, fp); - pecos::file_util::fget_multiple(&max_degree, 1, fp); - pecos::file_util::fget_multiple(&node_mem_size, 1, fp); - size_t sz = 0; - pecos::file_util::fget_multiple(&sz, 1, fp); - mem_start_of_node.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&mem_start_of_node[0], sz, fp); - } - pecos::file_util::fget_multiple(&sz, 1, fp); - buffer.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&buffer[0], sz, fp); - } + void load(mmap_util::MmapStore& mmap_s) { + this->num_node = mmap_s.fget_one(); + this->feat_dim = mmap_s.fget_one(); + this->max_degree = mmap_s.fget_one(); + this->node_mem_size = mmap_s.fget_one(); + this->mem_start_of_node.load_from_mmap_store(mmap_s); + this->buffer.load_from_mmap_store(mmap_s); } template @@ -198,33 +180,24 @@ namespace ann { index_type max_degree; index_type node_mem_size; index_type level_mem_size; - std::vector buffer; - - void save(FILE *fp) const { - pecos::file_util::fput_multiple(&num_node, 1, fp); - pecos::file_util::fput_multiple(&max_level, 1, fp); - pecos::file_util::fput_multiple(&max_degree, 1, fp); - pecos::file_util::fput_multiple(&node_mem_size, 1, fp); - pecos::file_util::fput_multiple(&level_mem_size, 1, fp); - size_t sz = buffer.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&buffer[0], sz, fp); - } + mmap_util::MmapableVector buffer; + + void save(mmap_util::MmapStore& mmap_s) const { + mmap_s.fput_one(this->num_node); + mmap_s.fput_one(this->max_level); + mmap_s.fput_one(this->max_degree); + mmap_s.fput_one(this->node_mem_size); + mmap_s.fput_one(this->level_mem_size); + this->buffer.save_to_mmap_store(mmap_s); } - void load(FILE *fp) { - pecos::file_util::fget_multiple(&num_node, 1, fp); - pecos::file_util::fget_multiple(&max_level, 1, fp); - pecos::file_util::fget_multiple(&max_degree, 1, fp); - pecos::file_util::fget_multiple(&node_mem_size, 1, fp); - pecos::file_util::fget_multiple(&level_mem_size, 1, fp); - size_t sz = 0; - pecos::file_util::fget_multiple(&sz, 1, fp); - buffer.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&buffer[0], sz, fp); - } + void load(mmap_util::MmapStore& mmap_s) { + this->num_node = mmap_s.fget_one(); + this->max_level = mmap_s.fget_one(); + this->max_degree = mmap_s.fget_one(); + this->node_mem_size = mmap_s.fget_one(); + this->level_mem_size = mmap_s.fget_one(); + this->buffer.load_from_mmap_store(mmap_s); } template @@ -246,7 +219,6 @@ namespace ann { template struct GraphProductQuantizer4Bits : GraphBase { typedef FeatVec_T feat_vec_t; - 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 @@ -254,55 +226,34 @@ namespace ann { // found in pad_parameters function of ann/quantizer_impl/x86.hpp size_t code_dimension; // code_offset helps to locate memory position containing neighboring codes - size_t code_offset; + size_t code_offset; size_t node_mem_size; index_type max_degree; - std::vector mem_start_of_node; - std::vector buffer; - - void save(FILE *fp) const { - pecos::file_util::fput_multiple(&num_node, 1, fp); - pecos::file_util::fput_multiple(&code_dimension, 1, fp); - pecos::file_util::fput_multiple(&code_offset, 1, fp); - pecos::file_util::fput_multiple(&node_mem_size, 1, fp); - pecos::file_util::fput_multiple(&max_degree, 1, fp); - size_t sz = mem_start_of_node.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&mem_start_of_node[0], sz, fp); - } - sz = buffer.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&buffer[0], sz, fp); - } - quantizer.save(fp); - fclose(fp); - } - - void load(FILE *fp) { - pecos::file_util::fget_multiple(&num_node, 1, fp); - pecos::file_util::fget_multiple(&code_dimension, 1, fp); - pecos::file_util::fget_multiple(&code_offset, 1, fp); - pecos::file_util::fget_multiple(&node_mem_size, 1, fp); - pecos::file_util::fget_multiple(&max_degree, 1, fp); - size_t sz = 0; - pecos::file_util::fget_multiple(&sz, 1, fp); - mem_start_of_node.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&mem_start_of_node[0], sz, fp); - } - pecos::file_util::fget_multiple(&sz, 1, fp); - buffer.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&buffer[0], sz, fp); - } - - quantizer.load(fp); + mmap_util::MmapableVector mem_start_of_node; + mmap_util::MmapableVector buffer; + ProductQuantizer4Bits quantizer; - fclose(fp); + void save(mmap_util::MmapStore& mmap_s) const { + mmap_s.fput_one(this->num_node); + mmap_s.fput_one(this->code_dimension); + mmap_s.fput_one(this->code_offset); + mmap_s.fput_one(this->node_mem_size); + mmap_s.fput_one(this->max_degree); + this->mem_start_of_node.save_to_mmap_store(mmap_s); + this->buffer.save_to_mmap_store(mmap_s); + quantizer.save(mmap_s); } + void load(mmap_util::MmapStore& mmap_s) { + this->num_node = mmap_s.fget_one(); + this->code_dimension = mmap_s.fget_one(); + this->code_offset = mmap_s.fget_one(); + this->node_mem_size = mmap_s.fget_one(); + this->max_degree = mmap_s.fget_one(); + this->mem_start_of_node.load_from_mmap_store(mmap_s); + this->buffer.load_from_mmap_store(mmap_s); + quantizer.load(mmap_s); + } void build_quantizer(const pecos::drm_t& X_trn, index_type subspace_dimension, index_type sub_sample_points) { size_t code_dimension = X_trn.cols; @@ -384,7 +335,6 @@ namespace ann { } }; - template struct SetOfVistedNodes { T init_token, curr_token; @@ -508,6 +458,9 @@ namespace ann { GraphL0 graph_l0; // neighborhood graph along with feature vectors at level 0 GraphL1 graph_l1; // neighborhood graphs from level 1 and above + // for loading memory-mapped file + pecos::mmap_util::MmapStore mmap_store; + // destructor ~HNSW() {} @@ -534,7 +487,7 @@ namespace ann { void save_config(const std::string& filepath) const { nlohmann::json j_params = { {"hnsw_t", pecos::type_util::full_name()}, - {"version", "v1.0"}, + {"version", "v2.0"}, {"train_params", { {"num_node", this->num_node}, {"maxM", this->maxM}, @@ -561,37 +514,37 @@ namespace ann { } } save_config(model_dir + "/config.json"); - std::string index_path = model_dir + "/index.bin"; - FILE *fp = fopen(index_path.c_str(), "wb"); - pecos::file_util::fput_multiple(&num_node, 1, fp); - pecos::file_util::fput_multiple(&maxM, 1, fp); - pecos::file_util::fput_multiple(&maxM0, 1, fp); - pecos::file_util::fput_multiple(&efC, 1, fp); - pecos::file_util::fput_multiple(&max_level, 1, fp); - pecos::file_util::fput_multiple(&init_node, 1, fp); - graph_l0.save(fp); - graph_l1.save(fp); - fclose(fp); + std::string index_path = model_dir + "/index.mmap_store"; + mmap_util::MmapStore mmap_s = mmap_util::MmapStore(); + mmap_s.open(index_path.c_str(), "w"); + mmap_s.fput_one(this->num_node); + mmap_s.fput_one(this->maxM); + mmap_s.fput_one(this->maxM0); + mmap_s.fput_one(this->efC); + mmap_s.fput_one(this->max_level); + mmap_s.fput_one(this->init_node); + graph_l0.save(mmap_s); + graph_l1.save(mmap_s); + mmap_s.close(); } - void load(const std::string& model_dir) { + void load(const std::string& model_dir, bool lazy_load = false) { auto config = load_config(model_dir + "/config.json"); std::string version = config.find("version") != config.end() ? config["version"] : "not found"; - std::string index_path = model_dir + "/index.bin"; - FILE *fp = fopen(index_path.c_str(), "rb"); - if (version == "v1.0") { - pecos::file_util::fget_multiple(&num_node, 1, fp); - pecos::file_util::fget_multiple(&maxM, 1, fp); - pecos::file_util::fget_multiple(&maxM0, 1, fp); - pecos::file_util::fget_multiple(&efC, 1, fp); - pecos::file_util::fget_multiple(&max_level, 1, fp); - pecos::file_util::fget_multiple(&init_node, 1, fp); - graph_l0.load(fp); - graph_l1.load(fp); + if (version == "v2.0") { + std::string index_path = model_dir + "/index.mmap_store"; + mmap_store.open(index_path.c_str(), lazy_load ? "r_lazy" : "r"); + this->num_node = mmap_store.fget_one(); + this->maxM = mmap_store.fget_one(); + this->maxM0 = mmap_store.fget_one(); + this->efC = mmap_store.fget_one(); + this->max_level = mmap_store.fget_one(); + this->init_node = mmap_store.fget_one(); + graph_l0.load(mmap_store); + graph_l1.load(mmap_store); } else { - throw std::runtime_error("Unable to load this binary with version = " + version); + throw std::runtime_error("Unable to load memory-mapped file with version = " + version); } - fclose(fp); } // Algorithm 4 of HNSW paper @@ -1014,7 +967,7 @@ namespace ann { } }; - + // PECOS-HNSW-PQ4 Interface template struct HNSWProductQuantizer4Bits { typedef FeatVec_T feat_vec_t; @@ -1022,7 +975,6 @@ namespace ann { typedef heap_t> max_heap_t; typedef heap_t> min_heap_t; - // scalar variables index_type num_node; index_type maxM; // max number of out-degree for level l=1,...,L @@ -1031,18 +983,24 @@ namespace ann { index_type max_level; index_type init_node; 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. + 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 GraphProductQuantizer4Bits graph_l0_pq4; // Productquantized4Bits neighborhood graph built from graph_l0 + + // for loading memory-mapped file + mmap_util::MmapStore mmap_store; + HNSWProductQuantizer4Bits() { std::string space_type = pecos::type_util::full_name(); if (space_type != "pecos::ann::FeatVecDenseL2Simd") { throw std::runtime_error("Currently, we only support L2 distance with float type."); - } + } } + ~HNSWProductQuantizer4Bits() {} + struct Searcher : SetOfVistedNodes { typedef SetOfVistedNodes set_of_visited_nodes_t; typedef HNSWProductQuantizer4Bits hnswpq4_t; @@ -1108,7 +1066,6 @@ namespace ann { return Searcher(this); } - static nlohmann::json load_config(const std::string& filepath) { std::ifstream loadfile(filepath); std::string json_str; @@ -1131,7 +1088,7 @@ namespace ann { void save_config(const std::string& filepath) const { nlohmann::json j_params = { {"hnsw_t", pecos::type_util::full_name()}, - {"version", "v1.0"}, + {"version", "v2.0"}, {"train_params", { {"num_node", this->num_node}, {"subspace_dimension", this->subspace_dimension}, @@ -1160,43 +1117,43 @@ namespace ann { } } save_config(model_dir + "/config.json"); - std::string index_path = model_dir + "/index.bin"; - FILE *fp = fopen(index_path.c_str(), "wb"); - pecos::file_util::fput_multiple(&num_node, 1, fp); - pecos::file_util::fput_multiple(&maxM, 1, fp); - pecos::file_util::fput_multiple(&maxM0, 1, fp); - pecos::file_util::fput_multiple(&efC, 1, fp); - pecos::file_util::fput_multiple(&max_level, 1, fp); - pecos::file_util::fput_multiple(&init_node, 1, fp); - pecos::file_util::fput_multiple(&subspace_dimension, 1, fp); - pecos::file_util::fput_multiple(&sub_sample_points, 1, fp); - feature_vec.save(fp); - graph_l1.save(fp); - graph_l0_pq4.save(fp); - fclose(fp); + std::string index_path = model_dir + "/index.mmap_store"; + mmap_util::MmapStore mmap_s = mmap_util::MmapStore(); + mmap_s.open(index_path.c_str(), "w"); + mmap_s.fput_one(this->num_node); + mmap_s.fput_one(this->maxM); + mmap_s.fput_one(this->maxM0); + mmap_s.fput_one(this->efC); + mmap_s.fput_one(this->max_level); + mmap_s.fput_one(this->init_node); + mmap_s.fput_one(this->subspace_dimension); + mmap_s.fput_one(this->sub_sample_points); + feature_vec.save(mmap_s); + graph_l1.save(mmap_s); + graph_l0_pq4.save(mmap_s); + mmap_s.close(); } - void load(const std::string& model_dir) { + void load(const std::string& model_dir, bool lazy_load = false) { auto config = load_config(model_dir + "/config.json"); std::string version = config.find("version") != config.end() ? config["version"] : "not found"; - std::string index_path = model_dir + "/index.bin"; - FILE *fp = fopen(index_path.c_str(), "rb"); - if (version == "v1.0") { - pecos::file_util::fget_multiple(&num_node, 1, fp); - pecos::file_util::fget_multiple(&maxM, 1, fp); - pecos::file_util::fget_multiple(&maxM0, 1, fp); - pecos::file_util::fget_multiple(&efC, 1, fp); - pecos::file_util::fget_multiple(&max_level, 1, fp); - pecos::file_util::fget_multiple(&init_node, 1, fp); - pecos::file_util::fget_multiple(&subspace_dimension, 1, fp); - pecos::file_util::fget_multiple(&sub_sample_points, 1, fp); - feature_vec.load(fp); - graph_l1.load(fp); - graph_l0_pq4.load(fp); + if (version == "v2.0") { + std::string index_path = model_dir + "/index.mmap_store"; + mmap_store.open(index_path.c_str(), lazy_load ? "r_lazy" : "r"); + this->num_node = mmap_store.fget_one(); + this->maxM = mmap_store.fget_one(); + this->maxM0 = mmap_store.fget_one(); + this->efC = mmap_store.fget_one(); + this->max_level = mmap_store.fget_one(); + this->init_node = mmap_store.fget_one(); + this->subspace_dimension = mmap_store.fget_one(); + this->sub_sample_points = mmap_store.fget_one(); + feature_vec.load(mmap_store); + graph_l1.load(mmap_store); + graph_l0_pq4.load(mmap_store); } else { - throw std::runtime_error("Unable to load this binary with version = " + version); + throw std::runtime_error("Unable to load memory-mapped file with version = " + version); } - fclose(fp); } template @@ -1234,7 +1191,6 @@ namespace ann { feature_vec.init(X_trn, -1); } - max_heap_t& predict_single(const feat_vec_t& query, index_type efS, index_type topk, Searcher& searcher, index_type num_rerank) const { index_type curr_node = this->init_node; auto &G1 = graph_l1; @@ -1370,5 +1326,6 @@ namespace ann { return topk_queue; } }; + } // end of namespace ann } // end of namespace pecos diff --git a/pecos/core/ann/quantizer_impl/common.hpp b/pecos/core/ann/quantizer_impl/common.hpp index a20fe8f..28e3e7e 100644 --- a/pecos/core/ann/quantizer_impl/common.hpp +++ b/pecos/core/ann/quantizer_impl/common.hpp @@ -15,79 +15,54 @@ #include #include #include "utils/clustering.hpp" +#include "utils/mmap_util.hpp" namespace pecos { 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; + const index_type 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; - std::vector original_local_codebooks; - - inline void save(FILE* fp) const { - pecos::file_util::fput_multiple(&num_local_codebooks, 1, fp); - pecos::file_util::fput_multiple(&local_dimension, 1, fp); - size_t sz = global_centroid.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&global_centroid[0], sz, fp); - } - sz = original_local_codebooks.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&original_local_codebooks[0], sz, fp); - } - sz = local_codebooks.size(); - pecos::file_util::fput_multiple(&sz, 1, fp); - if (sz) { - pecos::file_util::fput_multiple(&local_codebooks[0], sz, fp); - } + mmap_util::MmapableVector global_centroid; + mmap_util::MmapableVector local_codebooks; + mmap_util::MmapableVector original_local_codebooks; + + inline void save(mmap_util::MmapStore& mmap_s) const { + mmap_s.fput_one(this->num_local_codebooks); + mmap_s.fput_one(this->local_dimension); + this->global_centroid.save_to_mmap_store(mmap_s); + this->local_codebooks.save_to_mmap_store(mmap_s); + this->original_local_codebooks.save_to_mmap_store(mmap_s); } - inline void load(FILE* fp) { - pecos::file_util::fget_multiple(&num_local_codebooks, 1, fp); - pecos::file_util::fget_multiple(&local_dimension, 1, fp); - size_t sz = 0; - pecos::file_util::fget_multiple(&sz, 1, fp); - global_centroid.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&global_centroid[0], sz, fp); - } - pecos::file_util::fget_multiple(&sz, 1, fp); - original_local_codebooks.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&original_local_codebooks[0], sz, fp); - } - pecos::file_util::fget_multiple(&sz, 1, fp); - local_codebooks.resize(sz); - if (sz) { - pecos::file_util::fget_multiple(&local_codebooks[0], sz, fp); - } + inline void load(mmap_util::MmapStore& mmap_s) { + this->num_local_codebooks = mmap_s.fget_one(); + this->local_dimension = mmap_s.fget_one(); + this->global_centroid.load_from_mmap_store(mmap_s); + this->local_codebooks.load_from_mmap_store(mmap_s); + this->original_local_codebooks.load_from_mmap_store(mmap_s); } inline void pack_codebook_for_inference_default() { local_codebooks = original_local_codebooks; } - + inline void pad_parameters_default(index_type& max_degree, size_t& code_dimension) {} - + inline void approximate_neighbor_group_distance_default(size_t neighbor_size, float* ds, const char* neighbor_codes, uint8_t* lut_ptr, float scale, float bias) const { index_type num_groups = neighbor_size % 16 == 0 ? neighbor_size / 16 : neighbor_size / 16 + 1; - + std::vector d(num_of_local_centroids); int ptr = 0; - + const uint8_t *localID = reinterpret_cast(neighbor_codes); for (index_type iters = 0; iters < num_groups; iters++) { memset(d.data(), 0, sizeof(uint32_t) * num_of_local_centroids); @@ -103,7 +78,7 @@ namespace ann { } d[k] += *(local_lut_ptr + obj); } - + local_lut_ptr += num_of_local_centroids; } for (size_t k = 0; k < num_of_local_centroids; k++) { @@ -112,7 +87,7 @@ namespace ann { ptr += num_of_local_centroids; } } - + inline void setup_lut_default(float* query, uint8_t* lut_ptr, float& scale, float& bias) const { float min = std::numeric_limits::max(); float max = std::numeric_limits::min(); @@ -134,7 +109,7 @@ namespace ann { min = std::min(min, tmp_v); } } - + bias = min; scale = (max - min) / 255.0; // second iteration to calculate quantized distnace and put it into lut @@ -236,10 +211,7 @@ namespace ann { &original_local_codebooks[m * num_of_local_centroids * local_dimension], threads); } } - }; - } // end of namespace ann } // end of namespace pecos - diff --git a/test/pecos/ann/test_hnsw.py b/test/pecos/ann/test_hnsw.py index 03d3f15..c691c11 100644 --- a/test/pecos/ann/test_hnsw.py +++ b/test/pecos/ann/test_hnsw.py @@ -82,6 +82,15 @@ def calc_recall(Y_true, Y_pred): Y_true = np.argsort(Y_true)[:, :top_k] # test dense features + #train_params = HNSW.TrainParams(M=36, efC=90, metric_type="ip", threads=1) + #pred_params = HNSW.PredParams(efS=80, topk=10, threads=1) + #model = HNSW.train( + # X_trn, + # train_params=train_params, + # pred_params=pred_params, + #) + #model.save(dense_model_folder) + #del model model = HNSW.load(dense_model_folder) searchers = model.searchers_create(num_searcher_online) pred_params = model.get_pred_params() @@ -99,6 +108,13 @@ def calc_recall(Y_true, Y_pred): # test csr features, we just reuse the Y_true since data are the same X_trn = smat.csr_matrix(X_trn).astype(np.float32) X_tst = smat.csr_matrix(X_tst).astype(np.float32) + #model = HNSW.train( + # X_trn, + # train_params=train_params, + # pred_params=pred_params, + #) + #model.save(sparse_model_folder) + #del model model = HNSW.load(sparse_model_folder) searchers = model.searchers_create(num_searcher_online) pred_params = model.get_pred_params() diff --git a/test/tst-data/ann/hnsw-model-dense/c_model/config.json b/test/tst-data/ann/hnsw-model-dense/c_model/config.json index 9b554f4..5e86b50 100644 --- a/test/tst-data/ann/hnsw-model-dense/c_model/config.json +++ b/test/tst-data/ann/hnsw-model-dense/c_model/config.json @@ -1,12 +1,12 @@ { "hnsw_t": "pecos::ann::HNSW>", - "version": "v1.0", "train_params": { - "efC": 100, - "init_node": 50, - "maxM": 24, - "maxM0": 48, + "efC": 90, + "init_node": 66, + "maxM": 36, + "maxM0": 72, "max_level": 1, "num_node": 90 - } -} + }, + "version": "v2.0" +} \ No newline at end of file diff --git a/test/tst-data/ann/hnsw-model-dense/param.json b/test/tst-data/ann/hnsw-model-dense/param.json index 5ea2474..fcc3fdf 100644 --- a/test/tst-data/ann/hnsw-model-dense/param.json +++ b/test/tst-data/ann/hnsw-model-dense/param.json @@ -11,8 +11,8 @@ "__meta__": { "class_fullname": "pecos.ann.hnsw.model###HNSW.PredParams" }, - "efS": 100, + "efS": 80, "topk": 10, "threads": 1 } -} +} \ No newline at end of file diff --git a/test/tst-data/ann/hnsw-model-sparse/c_model/config.json b/test/tst-data/ann/hnsw-model-sparse/c_model/config.json index fd3a9b2..57c7957 100644 --- a/test/tst-data/ann/hnsw-model-sparse/c_model/config.json +++ b/test/tst-data/ann/hnsw-model-sparse/c_model/config.json @@ -1,12 +1,12 @@ { "hnsw_t": "pecos::ann::HNSW>", - "version": "v1.0", "train_params": { - "efC": 100, - "init_node": 50, - "maxM": 24, - "maxM0": 48, + "efC": 90, + "init_node": 66, + "maxM": 36, + "maxM0": 72, "max_level": 1, "num_node": 90 - } -} + }, + "version": "v2.0" +} \ No newline at end of file diff --git a/test/tst-data/ann/hnsw-model-sparse/param.json b/test/tst-data/ann/hnsw-model-sparse/param.json index 477be23..5da8c9b 100644 --- a/test/tst-data/ann/hnsw-model-sparse/param.json +++ b/test/tst-data/ann/hnsw-model-sparse/param.json @@ -15,4 +15,4 @@ "topk": 10, "threads": 1 } -} +} \ No newline at end of file