pub struct EmbeddingDriftMonitor {
pub baseline: Option<BaselineStats>,
pub recent: Vec<Vec<f32>>,
pub config: DriftMonitorConfig,
pub stats: DriftMonitorStats,
pub update_counter: usize,
}Expand description
Monitors concept drift in embedding distributions.
Maintains a sliding window of recent vectors, periodically recomputes a baseline, and classifies each new vector against the baseline using normalised per-dimension deviation.
Fields§
§baseline: Option<BaselineStats>Current baseline statistics, if enough samples have been seen.
recent: Vec<Vec<f32>>Sliding window of recent vectors.
config: DriftMonitorConfigMonitor configuration.
stats: DriftMonitorStatsCumulative statistics.
update_counter: usizeNumber of vectors added since the last baseline update.
Implementations§
Source§impl EmbeddingDriftMonitor
impl EmbeddingDriftMonitor
Sourcepub fn new(config: DriftMonitorConfig) -> Self
pub fn new(config: DriftMonitorConfig) -> Self
Create a new monitor with the given configuration.
Sourcepub fn add_vector(&mut self, vec: Vec<f32>) -> DriftSignal
pub fn add_vector(&mut self, vec: Vec<f32>) -> DriftSignal
Add a vector to the monitor and return a DriftSignal.
Steps:
- Push
vecinto the sliding window, evicting the oldest entry whenrecent.len() > window_size. - Increment
update_counter; ifupdate_counter >= baseline_update_intervaland enough samples exist, recompute the baseline. - If no baseline is available, return
DriftSignal::InsufficientData. - Otherwise, compute the mean absolute normalised deviation and classify.
Sourcepub fn baseline(&self) -> Option<&BaselineStats>
pub fn baseline(&self) -> Option<&BaselineStats>
Return a reference to the current baseline statistics, if available.
Sourcepub fn stats(&self) -> &DriftMonitorStats
pub fn stats(&self) -> &DriftMonitorStats
Return a reference to the cumulative statistics.
Sourcepub fn reset_baseline(&mut self)
pub fn reset_baseline(&mut self)
Clear the baseline, recent window, and reset counters.
Auto Trait Implementations§
impl Freeze for EmbeddingDriftMonitor
impl RefUnwindSafe for EmbeddingDriftMonitor
impl Send for EmbeddingDriftMonitor
impl Sync for EmbeddingDriftMonitor
impl Unpin for EmbeddingDriftMonitor
impl UnsafeUnpin for EmbeddingDriftMonitor
impl UnwindSafe for EmbeddingDriftMonitor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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
impl<T> Read<Exclusive, BecauseExclusive> 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.