Skip to main content

FDEEncoder

Struct FDEEncoder 

Source
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§

Source§

impl<T: FDEFloat> FDEEncoder<T>

Source

pub fn new(buckets: usize, dim: usize, seed: u64) -> Self

Creates a new FDE encoder with the specified number of buckets and embedding dimension.

§Arguments
  • buckets: Number of hash buckets (hyperplanes).
  • dim: Dimensionality of token embeddings.
  • seed: RNG seed for reproducible hyperplane initialization.
§Returns

A new FDEEncoder instance.

Trait Implementations§

Source§

impl Default for FDEEncoder<f32>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: FDEFloat + Send + Sync + FromPrimitive> FDEEncoding<T> for FDEEncoder<T>

Source§

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 (Sum or Avg).
§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>
where T: FDEFloat + Sync + Send, Self: Sync,

Encode a batch of multi-vectors using parallel processing.

Divides the batch across threads for concurrent encoding.

§Arguments
  • batch_tokens: 3D array (batch_size, num_tokens, dim).
  • mode: Aggregation mode (Sum or Avg).
§Returns

2D array of encoded vectors (batch_size, buckets * dim).

Source§

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>

Encode a document token embedding using average aggregation. Read more
Source§

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>

Batch encode documents using average aggregation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FDEEncoder<T>
where ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>: Freeze,

§

impl<T> RefUnwindSafe for FDEEncoder<T>

§

impl<T> Send for FDEEncoder<T>
where ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>: Send,

§

impl<T> Sync for FDEEncoder<T>
where ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>: Sync,

§

impl<T> Unpin for FDEEncoder<T>
where ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>: Unpin,

§

impl<T> UnsafeUnpin for FDEEncoder<T>

§

impl<T> UnwindSafe for FDEEncoder<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V