pub struct InstructDataset { /* private fields */ }Expand description
Instruction-tuning dataset (multi-turn conversations).
Implementations§
Source§impl InstructDataset
impl InstructDataset
Sourcepub fn new(examples: Vec<TrainingExample>) -> Self
pub fn new(examples: Vec<TrainingExample>) -> Self
Create a new instruct dataset from a vector of examples.
Sourcepub fn from_examples(
examples: impl IntoIterator<Item = TrainingExample>,
) -> Self
pub fn from_examples( examples: impl IntoIterator<Item = TrainingExample>, ) -> Self
Create a new instruct dataset from an iterator of examples.
Sourcepub fn push(&mut self, example: TrainingExample)
pub fn push(&mut self, example: TrainingExample)
Append a single example to the dataset.
Sourcepub fn extend(&mut self, examples: impl IntoIterator<Item = TrainingExample>)
pub fn extend(&mut self, examples: impl IntoIterator<Item = TrainingExample>)
Extend the dataset with an iterator of examples.
Sourcepub fn remove(&mut self, index: usize) -> DatasetResult<TrainingExample>
pub fn remove(&mut self, index: usize) -> DatasetResult<TrainingExample>
Remove and return the example at the given index.
Sourcepub fn total_estimated_tokens(&self) -> usize
pub fn total_estimated_tokens(&self) -> usize
Total estimated tokens across all examples.
Sourcepub fn as_slice(&self) -> &[TrainingExample]
pub fn as_slice(&self) -> &[TrainingExample]
Get all examples as a slice.
Sourcepub fn into_inner(self) -> Vec<TrainingExample>
pub fn into_inner(self) -> Vec<TrainingExample>
Consume self and return the underlying Vec.
Trait Implementations§
Source§impl Clone for InstructDataset
impl Clone for InstructDataset
Source§fn clone(&self) -> InstructDataset
fn clone(&self) -> InstructDataset
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 moreSource§impl Dataset for InstructDataset
impl Dataset for InstructDataset
Source§type Item = TrainingExample
type Item = TrainingExample
The item type stored in this dataset.
Source§fn iter(&self) -> Box<dyn Iterator<Item = &TrainingExample> + '_>
fn iter(&self) -> Box<dyn Iterator<Item = &TrainingExample> + '_>
Return an iterator over all items.
Source§fn split(&self, ratio: f32) -> (Vec<TrainingExample>, Vec<TrainingExample>)
fn split(&self, ratio: f32) -> (Vec<TrainingExample>, Vec<TrainingExample>)
Split the dataset by ratio into two vectors.
Auto Trait Implementations§
impl Freeze for InstructDataset
impl RefUnwindSafe for InstructDataset
impl Send for InstructDataset
impl Sync for InstructDataset
impl Unpin for InstructDataset
impl UnsafeUnpin for InstructDataset
impl UnwindSafe for InstructDataset
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