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

DPO support remove_unused_columns #2233

Merged
merged 1 commit into from
Oct 16, 2024
Merged

DPO support remove_unused_columns #2233

merged 1 commit into from
Oct 16, 2024

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Oct 15, 2024

What does this PR do?

Currently,

  1. removing unused column isn't supported
  2. when not explicitly passing --no_remove_unused_columns, the following warning appears:
$ accelerate launch examples/scripts/dpo.py --output_dir Qwen2-0.5B-DPO --dataset_name trl-lib/lm-human-preferences-sentiment --model_name_or_path Qwen/Qwen2-0.5B-Instruct --logging_steps 10 --report_to none
/fsx/qgallouedec/trl/trl/trainer/dpo_trainer.py:720: UserWarning: When using DPODataCollatorWithPadding, you should set `remove_unused_columns=False` in your TrainingArguments. We have set it for you, but you should do it yourself in the future.
  warnings.warn(

This PR adds support for removing unused columns, which resolves the warning.

Does it remove unused columns?

Before After
--remove_unused_columns (default) No Yes
--no_remove_unused_columns No No

Does the training run successfully?

Before After
--remove_unused_columns (default) Yes, but raises a warning Yes
--no_remove_unused_columns Yes Yes

Context

Trying to split #2209 into smaller pieces

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Comment on lines -1547 to -1551
if not self.use_dpo_data_collator:
warnings.warn(
"compute_loss is only implemented for DPODataCollatorWithPadding, and you passed a datacollator that is different than "
"DPODataCollatorWithPadding - you might see unexpected behavior. Alternatively, you can implement your own prediction_step method if you are using a custom data collator"
)
Copy link
Member Author

@qgallouedec qgallouedec Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any warning, it should be possible for the user to take an action that removes it. In this case, it's not possible. Therefore, I suggest deleting it.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec qgallouedec changed the title DPO support `remove_unused_columns DPO support remove_unused_columns Oct 15, 2024
@qgallouedec qgallouedec merged commit 02f4e75 into main Oct 16, 2024
10 checks passed
@qgallouedec qgallouedec deleted the remove_unused_column branch October 16, 2024 08:00
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.

3 participants