Skip to content

Commit

Permalink
run eval on the first step to get a baseline (#617)
Browse files Browse the repository at this point in the history
* run eval on the first step to get a baseline

* wandb kleeps getting moved around by pre-commit ...
  • Loading branch information
winglian authored Sep 22, 2023
1 parent e85d2eb commit 2844eb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/axolotl/utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ def on_save(
return control


class EvalFirstStepCallback(
TrainerCallback
): # pylint: disable=too-few-public-methods disable=unused-argument
"""
Callback to trigger evals on the first step
"""

def on_step_end(
self,
args: TrainingArguments,
state: TrainerState,
control: TrainerControl,
**kwargs,
):
if (
args.evaluation_strategy == IntervalStrategy.STEPS
and args.eval_steps < 1.0
and state.global_step == 1
):
control.should_evaluate = True
return control


class SaveBetterTransformerModelCallback(
TrainerCallback
): # pylint: disable=too-few-public-methods
Expand Down
2 changes: 2 additions & 0 deletions src/axolotl/utils/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from axolotl.monkeypatch.relora import ReLoRACallback, ReLoRAScheduler
from axolotl.utils.callbacks import (
EvalFirstStepCallback,
GPUStatsCallback,
SaveBetterTransformerModelCallback,
SavePeftModelCallback,
Expand Down Expand Up @@ -704,6 +705,7 @@ def setup_trainer(cfg, train_dataset, eval_dataset, model, tokenizer, total_num_

callbacks = []
callbacks.append(GPUStatsCallback(cfg))
callbacks.append(EvalFirstStepCallback)

if cfg.relora_steps:
callbacks.append(ReLoRACallback(cfg))
Expand Down

0 comments on commit 2844eb2

Please sign in to comment.