Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add-slow-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
younesbelkada committed Jan 15, 2024
2 parents 01b8ac0 + 97b9fa2 commit 57d1401
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion docs/source/how_to_train.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ If you generate text by purely sampling from the model distribution things work

- **top-k sampling**: the model can smooth out the probability distribution causing the top-k tokens having a smaller probability than those of the reference model but they still are selected
- **min_length**: this ignores the EOS token until `min_length` is reached. thus the model can assign a very low log prob to the EOS token and very high probs to all others until min_length is reached
- **min_length**: this ignores the EOS token until `min_length` is reached, thus the model can assign a very low log prob to the EOS token and very high probs to all others until min_length is reached

These are just a few examples. Why is negative KL an issue? The total reward `R` is computed `R = r - beta * KL` so if the model can learn how to drive KL-divergence negative it effectively gets a positive reward. In many cases it can be much easier to exploit such a bug in the generation than actually learning the reward function. In addition the KL can become arbitrarily small thus the actual reward can be very small compared to it.

Expand Down
6 changes: 2 additions & 4 deletions trl/trainer/dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,7 @@ def compute_loss(
loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="train")

# force log the metrics
if self.accelerator.is_main_process:
self.store_metrics(metrics, train_eval="train")
self.store_metrics(metrics, train_eval="train")

if return_outputs:
return (loss, metrics)
Expand Down Expand Up @@ -1130,8 +1129,7 @@ def prediction_step(
loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="eval")

# force log the metrics
if self.accelerator.is_main_process:
self.store_metrics(metrics, train_eval="eval")
self.store_metrics(metrics, train_eval="eval")

if prediction_loss_only:
return (loss.detach(), None, None)
Expand Down

0 comments on commit 57d1401

Please sign in to comment.