pub struct Trainer { /* private fields */ }Expand description
High-level trainer that bundles a model and training config.
Construct via Trainer::builder() and the TrainerBuilder struct.
Users provide token sequences (Vec<Vec<u32>>) from their own tokenizer.
Implementations§
Source§impl Trainer
impl Trainer
Sourcepub fn builder() -> TrainerBuilder
pub fn builder() -> TrainerBuilder
Returns a new TrainerBuilder with sensible defaults.
Sourcepub fn train_on_token_sequences_with_callback(
&mut self,
sequences: &[Vec<u32>],
on_step: impl FnMut(usize, f32),
) -> Result<TrainingReport>
pub fn train_on_token_sequences_with_callback( &mut self, sequences: &[Vec<u32>], on_step: impl FnMut(usize, f32), ) -> Result<TrainingReport>
Trains the model on the provided token sequences.
Each inner Vec<u32> is a tokenized text sample. Use your own
tokenizer to produce these sequences before calling this method.
The on_step callback is invoked after each optimizer step with
(step_index, loss_value).
Sourcepub fn train_on_token_sequences(
&mut self,
sequences: &[Vec<u32>],
) -> Result<TrainingReport>
pub fn train_on_token_sequences( &mut self, sequences: &[Vec<u32>], ) -> Result<TrainingReport>
Convenience wrapper that trains without a per-step callback.
Sourcepub fn save_checkpoint(&self, path: &str) -> Result<()>
pub fn save_checkpoint(&self, path: &str) -> Result<()>
Saves a model checkpoint to the given path.
Sourcepub fn model(&self) -> &DefaultMultiscreenModel
pub fn model(&self) -> &DefaultMultiscreenModel
Returns a reference to the underlying model.
Sourcepub fn model_mut(&mut self) -> &mut DefaultMultiscreenModel
pub fn model_mut(&mut self) -> &mut DefaultMultiscreenModel
Returns a mutable reference to the underlying model.
Sourcepub fn training_config(&self) -> &ModelTrainingConfig
pub fn training_config(&self) -> &ModelTrainingConfig
Returns a reference to the training configuration.