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

realign values #137

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions trl/trainer/ppo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def batched_forward_pass(
if len(logprobs[j, start:end]) < 2:
raise ValueError("Responses are too short. Make sure they are at least 4 tokens long.")

all_values.append(v[j, start - 1 : end - 1])
all_values.append(v[j, start:end])
all_logprobs.append(logprobs[j, start:end])
all_ref_logprobs.append(ref_logprobs[j, start:end])

Expand Down Expand Up @@ -713,11 +713,11 @@ def loss(
if self.is_encoder_decoder:
logprob = logprobs_from_logits(logits[:, :-1, :], model_input[:, 1:])
start, end = 1, response.shape[-1] - 1
vpred = vpred[:, start - 1 : end - 1]
vpred = vpred[:, start:end]
logprob = logprob[:, start:end]
else:
logprob = logprobs_from_logits(logits[:, :-1, :], model_input[:, 1:])
logprob, vpred = logprob[:, -gen_len:], vpred[:, -gen_len - 1 : -1]
logprob, vpred = logprob[:, -gen_len:], vpred[:, -gen_len:]

vpredclipped = clip_by_value(vpred, values - self.config.cliprange_value, values + self.config.cliprange_value)

Expand Down