-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log Token distribution of Query / Response #295
Conversation
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @natolambert! Generally looks good, added two comments.
trl/trainer/ppo_config.py
Outdated
@@ -73,6 +73,10 @@ class PPOConfig(object): | |||
"help": "Log with either 'wandb' or 'tensorboard', check https://huggingface.co/docs/accelerate/usage_guides/tracking for more details" | |||
}, | |||
) | |||
log_token_distribution: Optional[bool] = field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not add another config and just always log it. It's cheap to do.
trl/trainer/ppo_trainer.py
Outdated
stats["tokens/query_len_mean"] = torch.mean(query_lens).cpu().numpy().item() | ||
stats["tokens/query_len_std"] = torch.std(query_lens).cpu().numpy().item() | ||
stats["tokens/responses_len_mean"] = torch.mean(response_lens).cpu().numpy().item() | ||
stats["tokens/responses_len_std"] = torch.std(response_lens).cpu().numpy().item() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to rewards i would also log the distribution so we can look at histograms in the logs.
KK should be good, example here: https://wandb.ai/huggingface/trl/runs/r2w2101u?workspace=user-natolambert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Here's an example run https://wandb.ai/huggingface/trl/runs/gjxlr3on?workspace=user-natolambert