in benchmarks/index_query.py [0:0]
def setup_cache(self) -> Dict:
param_combinations = product(*self.params)
data = {}
for param_combination in param_combinations:
num_dimensions, num_elements, space, storage_data_type, ef_construction = param_combination
generator = np.random.default_rng(seed=1234)
input_data = generator.random((num_elements, num_dimensions)).astype(np.float32) * 2 - 1
if storage_data_type == voyager.StorageDataType.Float8:
input_data = np.round(input_data * 127) / 127
index = voyager.Index(
space=space,
num_dimensions=num_dimensions,
ef_construction=ef_construction,
M=20,
storage_data_type=storage_data_type,
random_seed=4321,
)
index.add_items(input_data, num_threads=1)
data[param_combination] = (index.as_bytes(), input_data)
return data