[DPO
] Resolve logging for DPOTrainer
#570
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #569, resolves #568
Hello!
Pull Request overview
TrainingArguments
parameters likelogging_steps
,Details
In the transformers Trainer, a
log
method is called in a handful of different occasions, but primarily here:https://github.com/huggingface/transformers/blob/ee1eb3b325ce360bbd6c910c1402bca9dfb418f9/src/transformers/trainer.py#L2188-L2208
This method is essentially always called with a very specific dictionary, e.g. one with only a
loss
andlearning_rate
key. These cannot easily be extended without overriding large methods like_maybe_log_save_evaluate
or_inner_training_loop
in which these calls occur.So, we can't easily update the values with which
log
is initially called.Instead, we can override
log
itself, and insert the means of some stored metrics directly in that method. That is what this PR does. In particular, I create astore_metrics
method, and call it wheneverlog_metrics
used to forcibly be called, and I overridelog
with a middle-man as mentioned.Limitations
One of the primary annoyances with this implementation is that the output
metrics
ofdpo_trainer.evaluate(metric_key_prefix="test")
will start witheval
, e.g.:Results
I tried this example script to try it out:
Click to see training script
Which had the following terminal logs:
Click to see logs
and it produced the following W&B logs:
https://wandb.ai/tomaarsen/huggingface/reports/TRL-DPOTrainer-on-GPT2--Vmlldzo0OTY3MzAx
Crucially:
What now?
I'd love some feedback: Is it too much logging? In short, do we need to log
logps
andlogits
?Feedback & Discussion is welcome as always.
cc: @kashif