MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / main

Function main

sample/python/symqg_querying.py:18–54  ·  view source on GitHub ↗
(args=None)

Source from the content-addressed store, hash-verified

16
17
18def main(args=None) -> None:
19 # 1. Load queries and ground truth
20 queries = read_fvecs(args.query_file)
21 gt = read_ivecs(args.gt_file)
22 nq = queries.shape[0]
23 print(f"Queries: {queries.shape}, GT: {gt.shape}")
24
25 # 2. Load index
26 idx = SymqgIndex.load(args.index_file)
27 print(f"Index loaded — dim={idx.dim}, metric={args.metric}")
28 print(f"TopK: {args.topk}")
29
30 print("\nsearch start >.....\n")
31
32 all_qps = np.zeros((args.test_rounds, len(EFS)))
33 all_recall = np.zeros((args.test_rounds, len(EFS)))
34
35 for i_probe, ef in enumerate(EFS):
36 for r in range(args.test_rounds):
37 t0 = time()
38 ids, _ = idx.search(queries, k=args.topk, ef=ef, num_threads=args.num_threads)
39 elapsed = time() - t0 # seconds
40
41 qps = nq / elapsed
42 recall = compute_recall(ids, gt, args.topk)
43
44 all_qps[r, i_probe] = qps
45 all_recall[r, i_probe] = recall
46
47 avg_qps = all_qps.mean(axis=0)
48 avg_recall = all_recall.mean(axis=0)
49
50 # 3. Print results table
51 print(f"{'EF':<8}{'QPS':<14}{'Recall'}")
52 print("-" * 35)
53 for i, ef in enumerate(EFS):
54 print(f"{ef:<8}{avg_qps[i]:<14.1f}{avg_recall[i]:<12.4f}")
55
56
57if __name__ == "__main__":

Callers 1

symqg_querying.pyFile · 0.70

Calls 7

read_fvecsFunction · 0.90
read_ivecsFunction · 0.90
compute_recallFunction · 0.90
printFunction · 0.50
loadMethod · 0.45
searchMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected