Skip to content
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

reward_fn in accelerate_ppo_trainer.py #602

Open
Jerrrrykun opened this issue Dec 11, 2024 · 0 comments
Open

reward_fn in accelerate_ppo_trainer.py #602

Jerrrrykun opened this issue Dec 11, 2024 · 0 comments

Comments

@Jerrrrykun
Copy link

Hi, may I know why these two reward_fn function differently while they seem to be the same one passed to the PPO trainer as input? In my understanding of PPO, the reward function should output rewards for each sample instead of a sequence of (sequence_length, ) rewards.

# reward_fn should return list of rewards at each token per sample
# NOTE: all_scores[0][i] is the reward due to token (action) i in prompt + response (b/c of how kl is computed)

trlx/trlx/trlx.py

Lines 38 to 40 in 3340c2f

reward_fn (`Optional[Callable[[List[str], List[str], List[str]], List[float]]]`):
A function to rate batches of generated samples. Its required arguments are
(`samples`, `prompts`, `outputs`) and the return is a list of scalar rewards per each sample in batch

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

No branches or pull requests

1 participant