pub struct TrainingExample {
pub input_ids: Vec<u32>,
pub target_ids: Vec<u32>,
pub loss_mask: Vec<u8>,
}Expand description
One training example with optional response-only loss mask.
Fields§
§input_ids: Vec<u32>Tokens fed to the model.
target_ids: Vec<u32>Next-token targets, aligned with input_ids.
loss_mask: Vec<u8>1 = compute loss, 0 = ignore. Same length as target_ids.
Implementations§
Source§impl TrainingExample
impl TrainingExample
Sourcepub fn from_next_token(sequence: Vec<u32>) -> Self
pub fn from_next_token(sequence: Vec<u32>) -> Self
Next-token example over a whole sequence: inputs are all but the last token, targets all but the first, every target supervised.
Sourcepub fn from_sft_prompt_response(
prompt_tokens: Vec<u32>,
response_tokens: Vec<u32>,
) -> Self
pub fn from_sft_prompt_response( prompt_tokens: Vec<u32>, response_tokens: Vec<u32>, ) -> Self
Build an SFT example where loss is only computed on response tokens.
prompt_tokens are the tokens up to (and including) the assistant prefix,
response_tokens are the generated / supervised response ids.
Trait Implementations§
Source§impl Clone for TrainingExample
impl Clone for TrainingExample
Auto Trait Implementations§
impl Freeze for TrainingExample
impl RefUnwindSafe for TrainingExample
impl Send for TrainingExample
impl Sync for TrainingExample
impl Unpin for TrainingExample
impl UnsafeUnpin for TrainingExample
impl UnwindSafe for TrainingExample
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> 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