pub struct EmbeddingNormalizer { /* private fields */ }Expand description
Embedding normalizer with configurable strategies and statistics tracking.
Implementations§
Source§impl EmbeddingNormalizer
impl EmbeddingNormalizer
Sourcepub fn new(config: NormalizerConfig) -> Self
pub fn new(config: NormalizerConfig) -> Self
Create a new normalizer with the given configuration.
Sourcepub fn normalize(&mut self, embedding: &mut [f64]) -> NormStats
pub fn normalize(&mut self, embedding: &mut [f64]) -> NormStats
Normalize a single embedding vector in-place, returning statistics.
Sourcepub fn normalize_batch(&mut self, embeddings: &mut [Vec<f64>]) -> Vec<NormStats>
pub fn normalize_batch(&mut self, embeddings: &mut [Vec<f64>]) -> Vec<NormStats>
Normalize a batch of embeddings, returning per-vector statistics.
Sourcepub fn linf_norm(v: &[f64]) -> f64
pub fn linf_norm(v: &[f64]) -> f64
Compute the L-infinity norm (maximum absolute value) of a vector.
Sourcepub fn compute_mean(v: &[f64]) -> f64
pub fn compute_mean(v: &[f64]) -> f64
Compute the arithmetic mean of a vector.
Sourcepub fn compute_std_dev(v: &[f64], mean: f64) -> f64
pub fn compute_std_dev(v: &[f64], mean: f64) -> f64
Compute the population standard deviation given a precomputed mean.
Sourcepub fn clip(&self, embedding: &mut [f64])
pub fn clip(&self, embedding: &mut [f64])
Clip embedding values to the configured bounds (if any).
Sourcepub fn cosine_similarity(a: &[f64], b: &[f64]) -> f64
pub fn cosine_similarity(a: &[f64], b: &[f64]) -> f64
Compute cosine similarity between two vectors.
Returns 0.0 if either vector has zero norm.
Sourcepub fn compute_norm_stats(original: &[f64], normalized: &[f64]) -> NormStats
pub fn compute_norm_stats(original: &[f64], normalized: &[f64]) -> NormStats
Compute comprehensive statistics comparing original and normalized vectors.
Sourcepub fn stats(&self) -> &NormalizerStats
pub fn stats(&self) -> &NormalizerStats
Get a reference to the aggregate normalizer statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset all aggregate statistics to their defaults.
Auto Trait Implementations§
impl Freeze for EmbeddingNormalizer
impl RefUnwindSafe for EmbeddingNormalizer
impl Send for EmbeddingNormalizer
impl Sync for EmbeddingNormalizer
impl Unpin for EmbeddingNormalizer
impl UnsafeUnpin for EmbeddingNormalizer
impl UnwindSafe for EmbeddingNormalizer
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
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>
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
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>
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.