Skip to content

length penalty in reward function #14

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paulinebourigault
Copy link

The length penalty is calculated using the formula: ((5 + length) / 6) ^ alpha

This is based on the formula used in Google Neural Machine Translation paper [https://arxiv.org/pdf/1609.08144]
When alpha < 0, shorter sequences get higher rewards
When alpha > 0, longer sequences get higher rewards

Length penalties are applied to the final reward scores, after the primary reward calculation

@paulinebourigault
Copy link
Author

example use in training script:
reward_model.length_penalty.enabled=True \
reward_model.length_penalty.alpha=-0.2 \
reward_model.length_penalty.min_length=20 \
reward_model.length_penalty.max_length=null \

@paulinebourigault paulinebourigault changed the title length penaly in reward function length penalty in reward function Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant