-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
precompute_ref_log_probs not working correctly? #2423
Comments
That's a good catch, thanks @dakru012! Do you want to submit a PR to fix it? |
I think these lines within output["chosen_logps"] = all_logps[:num_examples]
output["rejected_logps"] = all_logps[num_examples:] Let me know if the PR is there otherwise I can include the relevant fixes inside #2426 or made a new one |
@SwayamInSync I don't think that's the problem. |
While looking on another issue in transformers library, I think this function was the problem of this issue def _set_signature_columns_if_needed(self):
# If `self.args.remove_unused_columns` is True, non-signature columns are removed.
# By default, this method sets `self._signature_columns` to the model's expected inputs.
# In DPOTrainer, we preprocess data, so using the model's signature columns doesn't work.
# Instead, we set them to the columns expected by `DPODataCollatorWithPadding`, hence the override.
if self._signature_columns is None:
self._signature_columns = ["prompt_input_ids", "chosen_input_ids", "rejected_input_ids", "image_sizes"] It is used to remove the unused columns and since there is no def _set_signature_columns_if_needed(self):
# If `self.args.remove_unused_columns` is True, non-signature columns are removed.
# By default, this method sets `self._signature_columns` to the model's expected inputs.
# In DPOTrainer, we preprocess data, so using the model's signature columns doesn't work.
# Instead, we set them to the columns expected by `DPODataCollatorWithPadding`, hence the override.
if self._signature_columns is None:
self._signature_columns = ["prompt_input_ids", "chosen_input_ids", "rejected_input_ids", "image_sizes", "ref_chosen_logps", "ref_rejected_logps"] Fixed that condtion check cc: @dakru012 |
@SwayamInSync That is a good find, I overlooked that one and just set I think there is also an small error in the data_collator description. It says that |
Hey awesome and yes, the documentation about collator is misleading there, I would drop a quick fix to both in a PR later, please feel free to add any modifications needed |
System Info
Information
Tasks
examples
folderReproduction
Expected behavior
Hi,
I have some questions about a potential issue or misunderstanding on my side.
The point of
precompute_ref_log_probs
is to calculate the ref log probabilities for the whole dataset before the actual training process, and then later during training we can just load the precomputed probabilities while saving the GPU memory space for the ref model, right?However, it seems like the precomputed log probabilities are never actually loaded.
In the corresponding part in
get_batch_loss_metrics()
:The if condition is never true, even if the log probabilities were computed, resulting in unnecessary computations for the ref model.
This is because the
PreferenceCollator
does not include theref_chosen_logps
andref_rejected_logps
in the batch.I made some changes to the Collator to include those, but first I wanted to make sure that I understood the
precompute_ref_log_probs
argument correctly.Checklist
The text was updated successfully, but these errors were encountered: