Skip to main content

TrainerBuilder

Struct TrainerBuilder 

Source
pub struct TrainerBuilder { /* private fields */ }
Expand description

Builder for constructing a Trainer with sensible defaults.

Implementations§

Source§

impl TrainerBuilder

Source

pub fn vocab_size(self, size: usize) -> Self

Sets the vocabulary size (required).

This is the number of distinct token IDs your tokenizer produces.

Source

pub fn budget(self, budget: ParameterBudget) -> Self

Sets the parameter budget. Defaults to ParameterBudget::Params10M.

Source

pub fn device(self, device: Device) -> Self

Sets the compute device. Defaults to default_device().

Source

pub fn batch_size(self, size: usize) -> Self

Sets the batch size. Defaults to 4.

Source

pub fn seq_len(self, len: usize) -> Self

Sets the sequence length. Defaults to 128.

Source

pub fn steps(self, steps: usize) -> Self

Sets the number of training steps. Defaults to 1000.

Source

pub fn learning_rate(self, lr: f64) -> Self

Sets the learning rate. Defaults to 2e-4.

Source

pub fn weight_decay(self, wd: f64) -> Self

Sets the weight decay. Defaults to 0.01.

Source

pub fn grad_clip_norm(self, norm: Option<f64>) -> Self

Sets gradient clip norm. Defaults to Some(1.0).

Source

pub fn checkpoint_dir(self, dir: impl Into<String>) -> Self

Sets the directory where checkpoints are saved.

Source

pub fn checkpoint_interval(self, steps: usize) -> Self

Sets how often (in steps) to save checkpoints. Defaults to 1000.

Source

pub fn run_dir(self, dir: impl Into<String>) -> Self

Overrides the run directory.

Source

pub fn build(self) -> Result<Trainer>

Builds the Trainer.

This constructs the model config from the parameter budget + vocab size, and creates the model.

Trait Implementations§

Source§

impl Default for TrainerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.