Skip to main content

Dataset

Trait Dataset 

Source
pub trait Dataset: Send + Sync {
    // Required methods
    fn len(&self) -> usize;
    fn get(&self, idx: usize) -> (Vec<u32>, Vec<u32>);

    // Provided methods
    fn get_loss_mask(&self, idx: usize) -> Option<Vec<u8>> { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait for datasets that provide training samples

Required Methods§

Source

fn len(&self) -> usize

Number of samples in the dataset

Source

fn get(&self, idx: usize) -> (Vec<u32>, Vec<u32>)

Get a single sample by index Returns (input_ids, target_ids) as token vectors

Provided Methods§

Source

fn get_loss_mask(&self, idx: usize) -> Option<Vec<u8>>

Optional per-token loss mask aligned with targets (1 = include, 0 = ignore)

Source

fn is_empty(&self) -> bool

Check if dataset is empty

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§