Skip to main content

ZunaEncoder

Struct ZunaEncoder 

Source
pub struct ZunaEncoder<B: Backend> {
    pub model_cfg: ModelConfig,
    pub data_cfg: DataConfig,
    /* private fields */
}
Expand description

Standalone ZUNA encoder.

Loads only the encoder half of the pretrained weights — useful when you only need latent embeddings and want to save memory and startup time compared to loading the full crate::ZunaInference.

§Backend

Compile-time choice (same as the full model):

  • CPU (default): --features ndarray
  • GPU: --no-default-features --features wgpu

Fields§

§model_cfg: ModelConfig

Architecture hyperparameters (from config.json).

§data_cfg: DataConfig

Preprocessing / tokenisation parameters.

Implementations§

Source§

impl<B: Backend> ZunaEncoder<B>

Source

pub fn load( config_path: &Path, weights_path: &Path, device: B::Device, ) -> Result<(Self, f64)>

Load encoder weights from a HuggingFace config.json and model.safetensors. Decoder tensors are read from disk but not kept in memory (the full file is parsed once for key extraction).

Returns (encoder, weight_load_ms).

Source

pub fn describe(&self) -> String

One-line description of the loaded encoder.

Source

pub fn encode_fif( &self, fif_path: &Path, data_norm: f32, ) -> Result<EncodingResult>

Preprocess a .fif recording and encode it into latent embeddings.

data_norm is the same divisor used to train ZUNA (default: 10.0). It is applied during preprocessing; the encoder output is not re-scaled — it reflects the MMD-regularised latent space directly.

Source

pub fn encode_batch(&self, batch_path: &Path) -> Result<EncodingResult>

Encode a pre-processed safetensors batch (Python / legacy input path).

The batch is assumed to already be normalised (÷ data_norm); the data_norm argument is not applied again here — it exists only to document the convention used when the file was created.

Source

pub fn encode_tensor(&self, batch: &InputBatch<B>) -> Tensor<B, 3>

Encode a single prepared InputBatch, returning the raw encoder output tensor [1, S, output_dim].

This is the MMD-regularised embedding: training constrains the distribution to N(0, I); at inference the bottleneck is a passthrough. No further normalisation is applied here.

Source

pub fn preprocess_fif( &self, fif_path: &Path, data_norm: f32, ) -> Result<(Vec<InputBatch<B>>, FifInfo)>

Run the FIF preprocessing pipeline and return raw InputBatches without running the encoder.

Use together with Self::encode_batches to time encode separately, or to export the pre-tokenised tensors for external comparison.

Source

pub fn encode_batches( &self, batches: Vec<InputBatch<B>>, ) -> Result<Vec<EpochEmbedding>>

Encode a list of InputBatches produced by Self::preprocess_fif.

Source

pub fn device(&self) -> &B::Device

Reference to the Burn device this encoder was loaded on.

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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