Skip to main content

Module ann_benchmark

Module ann_benchmark 

Source
Expand description

ANN (Approximate Nearest Neighbour) recall and latency benchmarking.

Provides utilities for evaluating the quality and performance of ANN indices: recall@k, QPS, build time, memory usage, ground-truth generation, precision-recall tradeoff, latency percentiles, and report generation.

Structs§

BenchmarkReport
A complete benchmark report.
BuildTimeResult
Result of a build-time measurement.
BuildTimer
Track how long an index build takes.
PrecisionRecallPoint
A data point on the precision-recall curve.
QpsResult
Result of a QPS measurement.

Functions§

average_distance_ratio
Compute the average distance ratio: sum of approx_dist / true_dist for each query’s k-th neighbour. A perfect index has ratio = 1.0.
brute_force_knn
Brute-force computation of exact k nearest neighbours for a set of queries.
estimate_flat_memory
Estimate the memory footprint of a flat vector index (vectors only).
estimate_hnsw_memory
Estimate memory for an HNSW-like graph index.
estimate_pq_memory
Estimate memory for a product-quantised (PQ) index.
measure_qps
Measure queries per second for a given search function.
per_query_recall
Compute recall@k for individual queries (not averaged).
precision
Compute precision: the fraction of returned results that are true neighbours.
precision_recall_sweep
Run a sweep over a set of parameter values and collect recall/precision at each setting.
recall_at_k
Compute recall@k: the fraction of true k-NN that appear in the approximate result set.

Type Aliases§

Neighbour
A single query result: (vector_id, distance).