pub struct QueryDriftDetector { /* private fields */ }Expand description
Detects drift in the intent mix of incoming queries.
Clusters the baseline embeddings with k-means, then re-assigns the current embeddings to those baseline centroids. The score is the symmetric Kullback–Leibler divergence between the two assignment distributions.
Implementations§
Source§impl QueryDriftDetector
impl QueryDriftDetector
Sourcepub fn new(threshold: f64, k: usize) -> Self
pub fn new(threshold: f64, k: usize) -> Self
Create a detector with k clusters. Defaults: 50 Lloyd iters, tol 1e-4,
1e-6 add-epsilon for KL smoothing.
Sourcepub fn detect(
&self,
baseline: ArrayView2<'_, f32>,
current: ArrayView2<'_, f32>,
) -> Result<DriftScore>
pub fn detect( &self, baseline: ArrayView2<'_, f32>, current: ArrayView2<'_, f32>, ) -> Result<DriftScore>
Run the detector against baseline and current query embeddings.
Auto Trait Implementations§
impl Freeze for QueryDriftDetector
impl RefUnwindSafe for QueryDriftDetector
impl Send for QueryDriftDetector
impl Sync for QueryDriftDetector
impl Unpin for QueryDriftDetector
impl UnsafeUnpin for QueryDriftDetector
impl UnwindSafe for QueryDriftDetector
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
Mutably borrows from an owned value. Read more
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 more