pub struct Seq2SeqBatcher {
pub layout: Seq2SeqBatchLayout,
pub ignore_index: i64,
pub maximum_encoder_length: Option<usize>,
pub maximum_decoder_length: Option<usize>,
}Available on crate feature
std only.Expand description
Native paired collation without model-specific target construction or truncation.
Fields§
§layout: Seq2SeqBatchLayoutActual source/decoder tensor layout.
ignore_index: i64Explicit decoder target sentinel; independent of either attention mask.
maximum_encoder_length: Option<usize>Optional source limit; excess documents are rejected, never truncated.
maximum_decoder_length: Option<usize>Optional decoder limit, independently enforced before uploading tensors.
Implementations§
Source§impl Seq2SeqBatcher
impl Seq2SeqBatcher
Sourcepub fn validate(
&self,
samples: &[Seq2SeqExample],
) -> Result<(), Seq2SeqDataError>
pub fn validate( &self, samples: &[Seq2SeqExample], ) -> Result<(), Seq2SeqDataError>
Validate both actual sequence axes and all explicit policies before tensor upload.
Sourcepub fn collate<B: Backend>(
&self,
samples: Vec<Seq2SeqExample>,
device: &B::Device,
) -> Result<Seq2SeqBatch<B>, Seq2SeqDataError>
pub fn collate<B: Backend>( &self, samples: Vec<Seq2SeqExample>, device: &B::Device, ) -> Result<Seq2SeqBatch<B>, Seq2SeqDataError>
Collate exact supplied pairs; reuse native aligned decoder label/count handling. No implicit teacher-forcing shift, BOS/EOS insertion, truncation or prompt masking.
Trait Implementations§
Source§impl<B: Backend> Batcher<B, Seq2SeqExample, Result<Seq2SeqBatch<B>, Seq2SeqDataError>> for Seq2SeqBatcher
Available on crate feature dataset only.
impl<B: Backend> Batcher<B, Seq2SeqExample, Result<Seq2SeqBatch<B>, Seq2SeqDataError>> for Seq2SeqBatcher
Available on crate feature
dataset only.Source§fn batch(
&self,
items: Vec<Seq2SeqExample>,
device: &B::Device,
) -> Result<Seq2SeqBatch<B>, Seq2SeqDataError>
fn batch( &self, items: Vec<Seq2SeqExample>, device: &B::Device, ) -> Result<Seq2SeqBatch<B>, Seq2SeqDataError>
Batches the given items on the specified device. Read more
Source§impl Clone for Seq2SeqBatcher
impl Clone for Seq2SeqBatcher
Source§impl Debug for Seq2SeqBatcher
impl Debug for Seq2SeqBatcher
Source§impl<'de> Deserialize<'de> for Seq2SeqBatcher
impl<'de> Deserialize<'de> for Seq2SeqBatcher
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 Seq2SeqBatcher
Source§impl PartialEq for Seq2SeqBatcher
impl PartialEq for Seq2SeqBatcher
Source§impl Serialize for Seq2SeqBatcher
impl Serialize for Seq2SeqBatcher
impl StructuralPartialEq for Seq2SeqBatcher
Auto Trait Implementations§
impl Freeze for Seq2SeqBatcher
impl RefUnwindSafe for Seq2SeqBatcher
impl Send for Seq2SeqBatcher
impl Sync for Seq2SeqBatcher
impl Unpin for Seq2SeqBatcher
impl UnsafeUnpin for Seq2SeqBatcher
impl UnwindSafe for Seq2SeqBatcher
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.