Expand description
§iqdb-eval
Index-agnostic evaluation harness for the HiveDB iqdb vector-database
spine. Measures recall@k and per-query latency percentiles for
any type that implements iqdb_index::IndexCore.
§Surface
All measurements are top-level free functions generic over the index
under test, so a single harness call works against
iqdb_flat::FlatIndex, an HNSW index, or any future index that
implements the same trait:
recall_at_k— recall@k for an index against an externally suppliedVec<Vec<u32>>ground truth (typically loaded from a SIFT.ivecsfile viaread_ivecs).recall_at_k_vs_oracle— convenience wrapper that takes a secondIndexCore(typicallyiqdb_flat::FlatIndex) as the oracle and computes ground truth on the fly.compute_ground_truth— the oracle-only half: returns the per-query ground-truth ids asVec<Vec<u32>>, matching the.ivecsshape.latency— collect per-query wall-clock samples and report mean / min / max / p50 / p95 / p99 (nearest-rank) and single-thread QPS.build_index_from_base— build a fresh index from a&[Vec<f32>]base set, inserting each row atVectorId::U64(row_index)so the resulting ids align with.ivecsground-truth files.read_fvecs/read_ivecs/load_sift_dataset— TEXMEX SIFT-family loaders.
§Correctness invariants
- Row-index ↔
VectorId::U64.build_index_from_baseinserts each row of the base set atVectorId::U64(row_index as u64). Callers that build oracles or indexes by hand must do the same; otherwise ids in.ivecsground-truth cannot match the ids returned bysearch. - Latency excludes build cost.
latencytakes a borrowed&I, so the index is constructed (and therefore paid for) before timing begins. - Percentiles are nearest-rank. No interpolation; every reported
percentile is an observed sample. See
LatencyReport. - Metric is read from the oracle.
compute_ground_truthderives the metric fromoracle.metric()so a mismatched metric cannot silently corrupt the ground-truth set.
§Example
use iqdb_eval::{
build_index_from_base, latency, recall_at_k_vs_oracle, LatencyConfig,
};
use iqdb_flat::{FlatConfig, FlatIndex};
use iqdb_types::{DistanceMetric, SearchParams};
let base: Vec<Vec<f32>> = vec![
vec![0.0, 0.0],
vec![3.0, 4.0],
vec![1.0, 1.0],
];
let queries: Vec<Vec<f32>> = vec![vec![0.5, 0.5]];
let target: FlatIndex =
build_index_from_base(FlatConfig, 2, DistanceMetric::Euclidean, &base)?;
let oracle: FlatIndex =
build_index_from_base(FlatConfig, 2, DistanceMetric::Euclidean, &base)?;
let params = SearchParams::new(2, DistanceMetric::Euclidean);
let recall = recall_at_k_vs_oracle(&target, &oracle, &queries, ¶ms)?;
assert_eq!(recall.mean_recall, 1.0);
let lat = latency(&target, &queries, ¶ms, &LatencyConfig::default())?;
assert!(lat.p50_us <= lat.p95_us);Structs§
- Latency
Config - Controls how
latencyruns its measurement loop. - Latency
Report - Summary of a per-query latency measurement.
- Recall
Report - Summary of a recall@k measurement against a known or computed ground-truth set.
- Sift
Dataset - One full SIFT-family dataset: base vectors, query vectors, per-query ground-truth neighbour ids, and the shared dimensionality.
Enums§
- Eval
Error - An error from an
iqdb-evalmeasurement or dataset-loading operation.
Constants§
- VERSION
- The version of this crate, taken from
Cargo.tomlat compile time.
Functions§
- build_
index_ from_ base - Build a fresh index from a
&[Vec<f32>]base set, inserting each row atVectorId::U64(row_index). - compute_
ground_ truth - Compute per-query top-
kground truth usingoracle. - latency
- Measure per-query latency for
indexoverqueriesand return aLatencyReport. - load_
sift_ dataset - Load a SIFT-family dataset rooted at
rootand named byprefix. - read_
fvecs - Read a
.fvecsfile (TEXMEX corpus format) into oneVec<f32>per record. - read_
ivecs - Read an
.ivecsfile (TEXMEX corpus format) into oneVec<u32>per record. - recall_
at_ k - Measure recall@k for
indexagainst an externally-suppliedground_truth. - recall_
at_ k_ vs_ oracle - Convenience wrapper: compute ground truth from
oracle, then measureindexagainst it.