Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/alignrl/dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def train(self) -> TrainResult:
trainer.save_model(str(output_dir / "final"))

loss_history = [log["loss"] for log in trainer.state.log_history if "loss" in log]
if not loss_history:
loss_history = [result.training_loss]

train_result = TrainResult(
output_dir=output_dir / "final",
Expand Down
2 changes: 2 additions & 0 deletions src/alignrl/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def train(self) -> TrainResult:
trainer.save_model(str(output_dir / "final"))

loss_history = [log["loss"] for log in trainer.state.log_history if "loss" in log]
if not loss_history:
loss_history = [result.training_loss]
reward_history = [
log.get("reward", 0.0) for log in trainer.state.log_history if "reward" in log
]
Expand Down
2 changes: 2 additions & 0 deletions src/alignrl/sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def train(self) -> TrainResult:
trainer.save_model(str(output_dir / "final"))

loss_history = [log["loss"] for log in trainer.state.log_history if "loss" in log]
if not loss_history:
loss_history = [result.training_loss]

train_result = TrainResult(
output_dir=output_dir / "final",
Expand Down
Loading