core.trainers.base

core.trainers.base

Module for customized trainers

Classes

Name Description
AxolotlTrainer Extend the base Trainer for axolotl helpers

AxolotlTrainer

core.trainers.base.AxolotlTrainer(
    *_args,
    bench_data_collator=None,
    eval_data_collator=None,
    dataset_tags=None,
    **kwargs,
)

Extend the base Trainer for axolotl helpers

Methods

Name Description
log Log logs on the various objects watching training, including stored metrics.
push_to_hub Overwrite the push_to_hub method in order to force-add the tags when pushing the
store_metrics Store metrics with specified reduction type.
log
core.trainers.base.AxolotlTrainer.log(logs, start_time=None)

Log logs on the various objects watching training, including stored metrics.

Parameters
Name Type Description Default
logs dict[str, float] The values to log. required
start_time float | None The start of training. None
push_to_hub
core.trainers.base.AxolotlTrainer.push_to_hub(*args, **kwargs)

Overwrite the push_to_hub method in order to force-add the tags when pushing the model on the Hub. Please refer to ~transformers.Trainer.push_to_hub for more details.

store_metrics
core.trainers.base.AxolotlTrainer.store_metrics(
    metrics,
    train_eval='train',
    reduction='mean',
)

Store metrics with specified reduction type.

Parameters
Name Type Description Default
metrics dict[str, float] | dict[str, tuple[int | float, str]] Dictionary of metric names to values, or metric names to (value, reduction_type) tuples. required
train_eval Literal['train', 'eval'] Whether this is for training or evaluation. 'train'

Functions

Name Description
model_loss_accepts_num_items_in_batch Whether model’s loss function consumes num_items_in_batch.

model_loss_accepts_num_items_in_batch

core.trainers.base.model_loss_accepts_num_items_in_batch(model)

Whether model’s loss function consumes num_items_in_batch.

The kwarg is a parameter of loss_function, not of forward(), which only receives it through **kwargs, so inspecting forward() never finds it. PEFT wrappers are unwrapped via get_base_model() rather than by walking .base_model, which is a property on every PreTrainedModel and would descend from e.g. LlamaForCausalLM into the LlamaModel that computes no loss at all.