-
Notifications
You must be signed in to change notification settings - Fork 457
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
[BUG] Fix basic tokenizer no special tokens #1640
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/1640
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 846002d with merge base 9a863c8 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@@ -239,6 +239,7 @@ def test_tokenize_messages(self, tokenizer): | |||
4, | |||
2, | |||
] | |||
expected_mask = [True] * 75 + [False] * 125 | |||
# Mask user, unmask assistant, add EOS token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were WRONG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1640 +/- ##
==========================================
- Coverage 70.96% 69.09% -1.88%
==========================================
Files 295 296 +1
Lines 15080 15112 +32
==========================================
- Hits 10701 10441 -260
- Misses 4379 4671 +292
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Context
What is the purpose of this PR? Is it to
Goal: Toggle
add_bos
andadd_eos
for Llama2 tokenizer.Problem: This is not configurable from the Llama2 tokenizer
tokenize_messages
, which is now the default API.Root cause: The underlying method used by the Llama2 tokenizer is
tokenize_messages_no_special_tokens
, which requires you to pass inbos_id
andeos_id
and always applies them.Solution: I made the
bos_id
andeos_id
optional for users to pass in. If they passed it in, I apply them. Otherwise, the method will not add the bos/eos tokens.Changelog
What are the changes made in this PR?
bos_id
andeos_id
optional. If they are specified, then I do add them. Otherwise, I don'tTest plan
Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.
pre-commit install
)pytest tests
pytest tests -m integration_test
UX
If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Here is a docstring example
and a tutorial example