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

[RewardTrainer] Tokenize inputs within trainer #2102

Merged
merged 15 commits into from
Sep 24, 2024
Merged

[RewardTrainer] Tokenize inputs within trainer #2102

merged 15 commits into from
Sep 24, 2024

Conversation

lewtun
Copy link
Member

@lewtun lewtun commented Sep 23, 2024

What does this PR do?

This PR aligns the RewardTrainer with the other TRL trainer to apply tokenization within the trainer itself. This has the nice effect of simplifying the example script significantly.

The training logs before/after this PR look within noise from random seed IMO

Screenshot 2024-09-23 at 14 21 36

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.

@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.

README.md Outdated
preprocess_function,
batched=True,
)
dataset = dataset.map(maybe_apply_chat_template, fn_kwargs={"tokenizer": tokenizer})
Copy link
Member

Choose a reason for hiding this comment

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

what about adding it in the trainer as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think this could be nice to make it consistent with the SFTTrainer! I'll push a change and fix the tests.

We should later apply this to the other trainers

Copy link
Member

Choose a reason for hiding this comment

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

Yes! see #2071

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 13b5ed0

@qgallouedec
Copy link
Member

qgallouedec commented Sep 23, 2024

Can you add/modify the tests? You should be able to use trl-internal-testing/zen as done in the other tests.

@lewtun
Copy link
Member Author

lewtun commented Sep 24, 2024

@qgallouedec I've refactored the tests to mostly use the zen dataset - let me know if you want other parts tested or if this is good to merge



class RewardTrainerTester(unittest.TestCase):
def setUp(self):
self.model_id = "hf-internal-testing/tiny-random-LlamaForCausalLM"
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should gradually move towards testing the most popular LLM architectures instead of relying on gpt2 which has a bunch of annoying things like a missing PAD token

README.md Outdated Show resolved Hide resolved
@qgallouedec
Copy link
Member

LGTM!

@qgallouedec qgallouedec merged commit cc23b51 into main Sep 24, 2024
9 of 10 checks passed
@qgallouedec qgallouedec deleted the rm-refactor branch September 24, 2024 11:03
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.

4 participants