forked from facebookresearch/faiss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench_fw_test.py
61 lines (57 loc) · 1.64 KB
/
bench_fw_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from bench_fw.benchmark import Benchmark
from bench_fw.benchmark_io import BenchmarkIO
from bench_fw.descriptors import DatasetDescriptor, IndexDescriptor
logging.basicConfig(level=logging.INFO)
benchmark = Benchmark(
training_vectors=DatasetDescriptor(
tablename="training.npy", num_vectors=200000
),
database_vectors=DatasetDescriptor(
tablename="database.npy", num_vectors=200000
),
query_vectors=DatasetDescriptor(tablename="query.npy", num_vectors=2000),
index_descs=[
IndexDescriptor(
factory="Flat",
range_metrics={
"weighted": [
[0.1, 0.928],
[0.2, 0.865],
[0.3, 0.788],
[0.4, 0.689],
[0.5, 0.49],
[0.6, 0.308],
[0.7, 0.193],
[0.8, 0.0],
]
},
),
IndexDescriptor(
factory="OPQ32_128,IVF512,PQ32",
),
IndexDescriptor(
factory="OPQ32_256,IVF512,PQ32",
),
IndexDescriptor(
factory="HNSW32",
construction_params=[
{
"efConstruction": 64,
}
],
),
],
k=10,
distance_metric="L2",
range_ref_index_desc="Flat",
)
io = BenchmarkIO(
path="/checkpoint",
)
benchmark.set_io(io)
print(benchmark.benchmark("result.json"))