-
Notifications
You must be signed in to change notification settings - Fork 28.8k
PreTrainedTokenizer
(slow) strip tokens that are around unique_no_split_tokens
#21120
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
Comments
This is probably due to the following line, which is still not fixed in the HEAD. transformers/src/transformers/tokenization_utils.py Lines 532 to 537 in f58248b
|
This bug strips away |
@ArthurZucker I can pick up this, Let me know what should be possible fix ? |
There is indeed a discrepancy between the |
The cleanest way is to have the tokens as |
@ArthurZucker I think |
This is untrue for pretty much all tokenizers, since tokenization is a destructive operation. At the very least you get back the normalized text (with some minimal unicode clean up) but for some tokenizers like BERT you will have whitespace simplified or text lowercased. |
I agree that minimal unicode clean up is acceptable (mostly because that does not break my use cases), but whitespace simplification or text lowercasing is not by default enabled, so by default users do get a mostly conservative tokenizer. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Is there any progress on this issue? @ArthurZucker |
Not yet! I finally have time so this week should be good! |
Is there any progress on this issue? |
Hey, to follow progress is suggest you check #23909, which should try to adresse this. |
Quick update, this is gonna take a bit more time as a more in-depth refactoring is needed |
PR will be merged this week! 🤗 |
System Info
transformers
version: 4.24.0Who can help?
@ArthurZucker
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Steps to reproduce the behavior:
PreTrainedTokenizer
that containsunique_no_split_tokens
, e.g.EleutherAI/gpt-j-6B
.unique_no_split_tokens
, e.g." <|extratoken_1|> "
.Expected behavior
The tokenizer splits the string into 3 tokens (
" "
,"<|extratoken_1|>"
and" "
), and gives their ids ([220, 50257, 220]
). This is the behavior ofPreTrainedTokenizerFast
.But the actual behavior is that the
PreTrainedTokenizer
only gives the id of"<|extratoken_1|>"
, i.e.50257
The text was updated successfully, but these errors were encountered: