pub struct IndexOptimizer { /* private fields */ }Expand description
Hyperparameter search engine for ANN index configurations.
Collects benchmark observations and provides:
- best-parameter selection for a given
OptimizationTarget, - Pareto-front extraction in the recall–QPS plane,
- a simple grid-expansion suggestion for the next candidate.
Implementations§
Source§impl IndexOptimizer
impl IndexOptimizer
Sourcepub fn new(index_type: IndexType, target: OptimizationTarget) -> Self
pub fn new(index_type: IndexType, target: OptimizationTarget) -> Self
Create a new optimiser for index_type that pursues target.
Sourcepub fn add_benchmark(&mut self, point: BenchmarkPoint)
pub fn add_benchmark(&mut self, point: BenchmarkPoint)
Record a new benchmark observation.
Sourcepub fn benchmark_count(&self) -> usize
pub fn benchmark_count(&self) -> usize
Number of recorded benchmark observations.
Sourcepub fn best_params(&self) -> Option<&BenchmarkPoint>
pub fn best_params(&self) -> Option<&BenchmarkPoint>
Return the benchmark point with the highest score under the current target,
or None if no benchmarks have been recorded.
Sourcepub fn pareto_front(&self) -> Vec<&BenchmarkPoint>
pub fn pareto_front(&self) -> Vec<&BenchmarkPoint>
Extract the Pareto-optimal front in the (recall_at_10, qps) plane.
A point a dominates b when a.recall_at_10 >= b.recall_at_10 and
a.qps >= b.qps with at least one strict inequality. The returned vector
contains only non-dominated points, sorted by descending recall.
Sourcepub fn suggest_next_params(&self) -> Option<IndexParams>
pub fn suggest_next_params(&self) -> Option<IndexParams>
Suggest the next parameter configuration to benchmark.
The strategy is a simple grid expansion: take the best observed
configuration and propose a neighbouring point by incrementing the most
impactful parameter by one step. Returns None when no benchmarks exist
or the index type is Flat (no free parameters).
Sourcepub fn index_type(&self) -> &IndexType
pub fn index_type(&self) -> &IndexType
Reference to the index type being optimised.
Sourcepub fn benchmarks(&self) -> &[BenchmarkPoint]
pub fn benchmarks(&self) -> &[BenchmarkPoint]
All recorded benchmark points.
Sourcepub fn ranked_benchmarks(&self) -> Vec<&BenchmarkPoint>
pub fn ranked_benchmarks(&self) -> Vec<&BenchmarkPoint>
Return all benchmarks sorted by score under the current target (descending).
Sourcepub fn score_of(&self, point: &BenchmarkPoint) -> f64
pub fn score_of(&self, point: &BenchmarkPoint) -> f64
Return the score of the given benchmark point under the current target.
Sourcepub fn filter_by_recall(&self, min_recall: f64) -> Vec<&BenchmarkPoint>
pub fn filter_by_recall(&self, min_recall: f64) -> Vec<&BenchmarkPoint>
Return benchmarks that achieve at least min_recall recall@10.
Sourcepub fn filter_by_qps(&self, min_qps: f64) -> Vec<&BenchmarkPoint>
pub fn filter_by_qps(&self, min_qps: f64) -> Vec<&BenchmarkPoint>
Return benchmarks that achieve at least min_qps queries per second.
Sourcepub fn recall_stats(&self) -> Option<RecallStats>
pub fn recall_stats(&self) -> Option<RecallStats>
Compute summary statistics (min/max/mean) over recall@10 values.
Sourcepub fn group_by_variant(&self) -> HashMap<&'static str, Vec<&BenchmarkPoint>>
pub fn group_by_variant(&self) -> HashMap<&'static str, Vec<&BenchmarkPoint>>
Group benchmarks by their parameter variant (Hnsw vs Ivf).
Auto Trait Implementations§
impl Freeze for IndexOptimizer
impl RefUnwindSafe for IndexOptimizer
impl Send for IndexOptimizer
impl Sync for IndexOptimizer
impl Unpin for IndexOptimizer
impl UnsafeUnpin for IndexOptimizer
impl UnwindSafe for IndexOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.