pub struct FDEEncoder<T: FDEFloat> {
pub buckets: usize,
pub dim: usize,
pub hyperplanes: Array2<T>,
}Expand description
Fixed Dimensional Encoder (FDE) implementation.
Encodes variable-length token embeddings into fixed-length vectors using randomized hyperplanes and aggregation.
§Fields
buckets: Number of hyperplanes / buckets to hash tokens into.dim: Embedding dimensionality of input tokens.hyperplanes: Random hyperplanes matrix used for projection and hashing.
Fields§
§buckets: usize§dim: usize§hyperplanes: Array2<T>Implementations§
Trait Implementations§
Source§impl Default for FDEEncoder<f32>
impl Default for FDEEncoder<f32>
Source§impl<T: FDEFloat + Send + Sync + FromPrimitive> FDEEncoding<T> for FDEEncoder<T>
impl<T: FDEFloat + Send + Sync + FromPrimitive> FDEEncoding<T> for FDEEncoder<T>
Source§fn encode(
&self,
multi_vector_tokens: ArrayView2<'_, T>,
mode: Aggregation,
) -> Array1<T>
fn encode( &self, multi_vector_tokens: ArrayView2<'_, T>, mode: Aggregation, ) -> Array1<T>
Encode a single multi-vector of tokens into a fixed-dimensional vector.
Projects tokens onto hyperplanes, hashes them into buckets, aggregates by sum or average per bucket, and concatenates the results.
§Arguments
multi_vector_tokens: 2D array of token embeddings(num_tokens, dim).mode: Aggregation mode (SumorAvg).
§Returns
A 1D array of length buckets * dim representing the encoded vector.
Source§fn batch_encode(
&self,
batch_tokens: ArrayView3<'_, T>,
mode: Aggregation,
) -> Array2<T>
fn batch_encode( &self, batch_tokens: ArrayView3<'_, T>, mode: Aggregation, ) -> Array2<T>
Source§fn encode_query(&self, tokens: ArrayView2<'_, T>) -> Array1<T>
fn encode_query(&self, tokens: ArrayView2<'_, T>) -> Array1<T>
Encode a query token embedding using sum aggregation. Read more
Source§fn encode_doc(&self, tokens: ArrayView2<'_, T>) -> Array1<T>
fn encode_doc(&self, tokens: ArrayView2<'_, T>) -> Array1<T>
Encode a document token embedding using average aggregation. Read more
Source§fn encode_query_batch(&self, batch_tokens: ArrayView3<'_, T>) -> Array2<T>
fn encode_query_batch(&self, batch_tokens: ArrayView3<'_, T>) -> Array2<T>
Batch encode queries using sum aggregation. Read more
Source§fn encode_doc_batch(&self, batch_tokens: ArrayView3<'_, T>) -> Array2<T>
fn encode_doc_batch(&self, batch_tokens: ArrayView3<'_, T>) -> Array2<T>
Batch encode documents using average aggregation. Read more
Auto Trait Implementations§
impl<T> Freeze for FDEEncoder<T>
impl<T> RefUnwindSafe for FDEEncoder<T>
impl<T> Send for FDEEncoder<T>
impl<T> Sync for FDEEncoder<T>
impl<T> Unpin for FDEEncoder<T>
impl<T> UnsafeUnpin for FDEEncoder<T>
impl<T> UnwindSafe for FDEEncoder<T>
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