我想知道如何保存使用ScaNN工具构建的索引。
start = time.time()
searcher = scann.scann_ops_pybind.builder(normalized_dataset, 10, "dot_product").tree(
num_leaves=2000, num_leaves_to_search=100, training_sample_size=250000).score_ah(
2, anisotropic_quantization_threshold=0.2).reorder(100).build()
end = time.time()
print("索引延迟(ms): {:8.4f}"。Format (1000*(end - start))
答案在这个GitHub问题中提到。
下面是scann 1.2的工作语法INDEX_DIR = './index'
os.makedirs(INDEX_DIR, exist_ok=True)
searcher.serialize(INDEX_DIR) # store the scann_module
another_searcher = scann.scann_ops_pybind.load_searcher(INDEX_DIR)
neighbors, distances = another_searcher.search_batched(dataset, final_num_neighbors=25)