-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
[Tests] Speed up tokenizer tests #14964
[Tests] Speed up tokenizer tests #14964
Conversation
|
||
def get_tokenizer(self, **kwargs) -> CanineTokenizer: | ||
return self.tokenizer_class.from_pretrained(self.tmpdirname, **kwargs) | ||
tokenizer = self.tokenizer_class.from_pretrained(self.tmpdirname, **kwargs) | ||
tokenizer._unicode_vocab_size = 1024 |
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.
This change alone gives a speed up of 2.5 minutes. The reason is that len(tokenizer)
is by default > 1,000,000 for every Canine tokenizer and the 4 slowest tests encode every single character in the vocabulary in a for loop.
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.
Nice catch!
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.
Fantastic! Looking forward to the test speed up!
|
||
def get_tokenizer(self, **kwargs) -> CanineTokenizer: | ||
return self.tokenizer_class.from_pretrained(self.tmpdirname, **kwargs) | ||
tokenizer = self.tokenizer_class.from_pretrained(self.tmpdirname, **kwargs) | ||
tokenizer._unicode_vocab_size = 1024 |
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.
Nice catch!
* speed up canine and mluke * speed up mbart and mbart50 toks * upload files
What does this PR do?
This PR speeds up the 7 slowest tokenizer tests significantly which should lead to a speed-up of ca. 3 minutes for every test that runs all tokenizer tests
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.