pub struct BatchedTokenizedInput {
pub input_ids: Vec<Vec<u32>>,
pub attention_mask: Vec<Vec<u8>>,
pub token_type_ids: Option<Vec<Vec<u32>>>,
}Expand description
Batched tokenized input with convenient access methods
Fields§
§input_ids: Vec<Vec<u32>>§attention_mask: Vec<Vec<u8>>§token_type_ids: Option<Vec<Vec<u32>>>Implementations§
Source§impl BatchedTokenizedInput
impl BatchedTokenizedInput
Sourcepub fn from_batch(batch: Vec<TokenizedInput>) -> Self
pub fn from_batch(batch: Vec<TokenizedInput>) -> Self
Create from a batch of TokenizedInput
Sourcepub fn batch_size(&self) -> usize
pub fn batch_size(&self) -> usize
Get the batch size
Sourcepub fn sequence_lengths(&self) -> Vec<usize>
pub fn sequence_lengths(&self) -> Vec<usize>
Get the sequence length for each sample
Sourcepub fn to_individual(self) -> Vec<TokenizedInput>
pub fn to_individual(self) -> Vec<TokenizedInput>
Convert to individual TokenizedInput items
Sourcepub fn input_ids_tensor(&self) -> &Vec<Vec<u32>>
pub fn input_ids_tensor(&self) -> &Vec<Vec<u32>>
Get input IDs as a flat tensor-like structure
Sourcepub fn attention_mask_tensor(&self) -> &Vec<Vec<u8>>
pub fn attention_mask_tensor(&self) -> &Vec<Vec<u8>>
Get attention mask as a flat tensor-like structure
Trait Implementations§
Source§impl Clone for BatchedTokenizedInput
impl Clone for BatchedTokenizedInput
Source§fn clone(&self) -> BatchedTokenizedInput
fn clone(&self) -> BatchedTokenizedInput
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BatchedTokenizedInput
impl RefUnwindSafe for BatchedTokenizedInput
impl Send for BatchedTokenizedInput
impl Sync for BatchedTokenizedInput
impl Unpin for BatchedTokenizedInput
impl UnsafeUnpin for BatchedTokenizedInput
impl UnwindSafe for BatchedTokenizedInput
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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