Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/maxtext/trainers/post_train/sft/train_sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def loss_func(
targets,
targets_position,
targets_segmentation,
images=None,
image_masks=None,
**kwargs,
):
data = {
"inputs": inputs,
Expand All @@ -219,6 +222,10 @@ def loss_func(
"targets_position": targets_position,
"targets_segmentation": targets_segmentation,
}
if images is not None:
data["images"] = images
if image_masks is not None:
data["image_masks"] = image_masks
return loss_fn(model, mt_config, data, dropout_rng=None, params=None, is_train=True)

trainer = trainer.with_loss_fn(loss_func, has_aux=True)
Expand Down