pub struct AdapterTrainingState {
pub global_step: usize,
pub epoch: usize,
pub steps_in_epoch: usize,
pub accumulated_steps: usize,
pub best_val_loss: Option<f64>,
/* private fields */
}Expand description
Training state for adapter fine-tuning.
Fields§
§global_step: usizeCurrent global step
epoch: usizeCurrent epoch
steps_in_epoch: usizeSteps within current epoch
accumulated_steps: usizeAccumulated gradient steps (for gradient accumulation)
best_val_loss: Option<f64>Best validation loss seen
Implementations§
Source§impl AdapterTrainingState
impl AdapterTrainingState
Sourcepub fn new(config: AdapterTrainingConfig) -> AdapterTrainingState
pub fn new(config: AdapterTrainingConfig) -> AdapterTrainingState
Create new training state with the given configuration.
Sourcepub fn current_lr(&self) -> f64
pub fn current_lr(&self) -> f64
Get the current learning rate based on schedule.
Sourcepub fn should_update(&self) -> bool
pub fn should_update(&self) -> bool
Check if gradient accumulation is complete.
Sourcepub fn step(&mut self) -> bool
pub fn step(&mut self) -> bool
Step after processing a batch.
Returns true if an optimizer step should be taken.
Sourcepub fn update_best_val_loss(&mut self, val_loss: f64) -> bool
pub fn update_best_val_loss(&mut self, val_loss: f64) -> bool
Update best validation loss.
Returns true if this is the new best loss.
Sourcepub fn gradient_accumulation_steps(&self) -> usize
pub fn gradient_accumulation_steps(&self) -> usize
Get gradient accumulation steps.
Sourcepub fn max_grad_norm(&self) -> Option<f64>
pub fn max_grad_norm(&self) -> Option<f64>
Get maximum gradient norm for clipping.
Sourcepub fn weight_decay(&self) -> f64
pub fn weight_decay(&self) -> f64
Get weight decay.
Trait Implementations§
Source§impl Clone for AdapterTrainingState
impl Clone for AdapterTrainingState
Source§fn clone(&self) -> AdapterTrainingState
fn clone(&self) -> AdapterTrainingState
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 AdapterTrainingState
impl RefUnwindSafe for AdapterTrainingState
impl Send for AdapterTrainingState
impl Sync for AdapterTrainingState
impl Unpin for AdapterTrainingState
impl UnwindSafe for AdapterTrainingState
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