pub struct CausalBatcher {
pub layout: CausalBatchLayout,
pub ignore_index: i64,
pub target_alignment: CausalTargetAlignment,
pub maximum_sequence_length: Option<usize>,
}Available on crate feature
std only.Expand description
Explicit supervision/layout policy shared by every call of a data batcher.
Fields§
§layout: CausalBatchLayoutActual device token-axis geometry.
ignore_index: i64Label sentinel, distinct from attention visibility and padding token ID.
target_alignment: CausalTargetAlignmentMust match the downstream loss’s causal-shift setting.
maximum_sequence_length: Option<usize>Optional maximum actual sequence length; excess data is rejected, not cut.
Implementations§
Source§impl CausalBatcher
impl CausalBatcher
Sourcepub fn validate(&self, samples: &[CausalExample]) -> Result<(), CausalDataError>
pub fn validate(&self, samples: &[CausalExample]) -> Result<(), CausalDataError>
Validate explicit policy and all actual source examples before uploading.
Sourcepub fn collate<B: Backend>(
&self,
samples: Vec<CausalExample>,
device: &B::Device,
) -> Result<CausalBatch<B>, CausalDataError>
pub fn collate<B: Backend>( &self, samples: Vec<CausalExample>, device: &B::Device, ) -> Result<CausalBatch<B>, CausalDataError>
Collate explicit labels/IDs on the selected device, without tokenization.
Next-token mode ignores each document’s first target even for left padding, so a padded hidden state cannot supervise the first real token. Packed mode never inserts EOS, changes labels within a document, or authorizes a model to attend across the retained boundaries.
Trait Implementations§
Source§impl<B: Backend> Batcher<B, CausalExample, Result<CausalBatch<B>, CausalDataError>> for CausalBatcher
Available on crate feature dataset only.
impl<B: Backend> Batcher<B, CausalExample, Result<CausalBatch<B>, CausalDataError>> for CausalBatcher
Available on crate feature
dataset only.Source§fn batch(
&self,
items: Vec<CausalExample>,
device: &B::Device,
) -> Result<CausalBatch<B>, CausalDataError>
fn batch( &self, items: Vec<CausalExample>, device: &B::Device, ) -> Result<CausalBatch<B>, CausalDataError>
Batches the given items on the specified device. Read more
Source§impl Clone for CausalBatcher
impl Clone for CausalBatcher
Source§impl Debug for CausalBatcher
impl Debug for CausalBatcher
Source§impl<'de> Deserialize<'de> for CausalBatcher
impl<'de> Deserialize<'de> for CausalBatcher
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CausalBatcher
Source§impl PartialEq for CausalBatcher
impl PartialEq for CausalBatcher
Source§impl Serialize for CausalBatcher
impl Serialize for CausalBatcher
impl StructuralPartialEq for CausalBatcher
Auto Trait Implementations§
impl Freeze for CausalBatcher
impl RefUnwindSafe for CausalBatcher
impl Send for CausalBatcher
impl Sync for CausalBatcher
impl Unpin for CausalBatcher
impl UnsafeUnpin for CausalBatcher
impl UnwindSafe for CausalBatcher
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.