pub enum UniversalPoolingStrategy {
ClsToken,
Mean,
Max,
MeanSqrt,
AttentionPooling,
WeightedMean,
}Expand description
Pooling strategy for UniversalSentenceEncoder.
Each variant describes how per-token embeddings are collapsed into a single fixed-length sentence vector.
Variants§
ClsToken
Use only the embedding of the first token (CLS-token style).
Mean
Arithmetic mean over all token embeddings.
Max
Component-wise maximum over all token embeddings.
MeanSqrt
Mean divided by √(n_tokens).
This down-scales the pooled vector for longer sequences, which can help when sequences have variable lengths.
AttentionPooling
Attention-weighted mean with a learnable query vector q.
Scores are computed as softmax(E·q), then the result is Eᵀ·scores.
Requires calling UniversalSentenceEncoder::fit_attention_pooling
before use, or the mean pool is used as a fallback.
WeightedMean
Weighted mean using log-IDF weights per token.
Requires calling UniversalSentenceEncoder::fit_idf_weights before
use, or the mean pool is used as a fallback.
Trait Implementations§
Source§impl Clone for UniversalPoolingStrategy
impl Clone for UniversalPoolingStrategy
Source§fn clone(&self) -> UniversalPoolingStrategy
fn clone(&self) -> UniversalPoolingStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UniversalPoolingStrategy
impl Debug for UniversalPoolingStrategy
Source§impl PartialEq for UniversalPoolingStrategy
impl PartialEq for UniversalPoolingStrategy
Source§fn eq(&self, other: &UniversalPoolingStrategy) -> bool
fn eq(&self, other: &UniversalPoolingStrategy) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for UniversalPoolingStrategy
Auto Trait Implementations§
impl Freeze for UniversalPoolingStrategy
impl RefUnwindSafe for UniversalPoolingStrategy
impl Send for UniversalPoolingStrategy
impl Sync for UniversalPoolingStrategy
impl Unpin for UniversalPoolingStrategy
impl UnsafeUnpin for UniversalPoolingStrategy
impl UnwindSafe for UniversalPoolingStrategy
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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.