Skip to content

Commit

Permalink
Clone labels for end-dec model to solve RuntimeError
Browse files Browse the repository at this point in the history
  • Loading branch information
pablovicente committed Jan 10, 2024
1 parent 628e666 commit d153183
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions trl/trainer/kto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ def get_batch_logps(
if not is_encoder_decoder:
labels = labels[:, 1:].clone()
logits = logits[:, :-1, :]
else:
# Fixes end-dec RuntimeError
labels = labels.clone()

loss_mask = labels != label_pad_token_id

# dummy token; we'll ignore the losses on these tokens later
Expand Down

0 comments on commit d153183

Please sign in to comment.