pub struct EmbeddingComposer {
pub stats: ComposerStats,
}Expand description
Composes multiple embeddings into a single representation using a chosen
CompositionStrategy.
§Example
use ipfrs_semantic::embedding_composer::{
EmbeddingComposer, EmbeddingInput, CompositionStrategy,
};
let mut composer = EmbeddingComposer::new();
let inputs = vec![
EmbeddingInput::new(1, vec![1.0, 2.0], 1.0),
EmbeddingInput::new(2, vec![3.0, 4.0], 1.0),
];
let result = composer
.compose(&inputs, CompositionStrategy::Concatenate)
.unwrap();
assert_eq!(result.composed, vec![1.0, 2.0, 3.0, 4.0]);Fields§
§stats: ComposerStatsAccumulated statistics across all compose calls.
Implementations§
Source§impl EmbeddingComposer
impl EmbeddingComposer
Sourcepub fn compose(
&mut self,
inputs: &[EmbeddingInput],
strategy: CompositionStrategy,
) -> Result<CompositionResult, String>
pub fn compose( &mut self, inputs: &[EmbeddingInput], strategy: CompositionStrategy, ) -> Result<CompositionResult, String>
Compose inputs using strategy and return the result.
§Errors
- Returns
Err("no inputs")wheninputsis empty. - Returns
Err("dimension mismatch")when a strategy that requires equal dimensions receives inputs of differing dimensionality.
Sourcepub fn batch_compose(
&mut self,
batches: Vec<(Vec<EmbeddingInput>, CompositionStrategy)>,
) -> Vec<Result<CompositionResult, String>>
pub fn batch_compose( &mut self, batches: Vec<(Vec<EmbeddingInput>, CompositionStrategy)>, ) -> Vec<Result<CompositionResult, String>>
Compose multiple independent batches in a single call.
Each element of batches is a (inputs, strategy) pair. Results are
returned in the same order as the input batches.
Sourcepub fn stats(&self) -> &ComposerStats
pub fn stats(&self) -> &ComposerStats
Return a reference to the accumulated statistics.
Trait Implementations§
Source§impl Debug for EmbeddingComposer
impl Debug for EmbeddingComposer
Source§impl Default for EmbeddingComposer
impl Default for EmbeddingComposer
Source§fn default() -> EmbeddingComposer
fn default() -> EmbeddingComposer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EmbeddingComposer
impl RefUnwindSafe for EmbeddingComposer
impl Send for EmbeddingComposer
impl Sync for EmbeddingComposer
impl Unpin for EmbeddingComposer
impl UnsafeUnpin for EmbeddingComposer
impl UnwindSafe for EmbeddingComposer
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.