Repository navigation
Fix for TypeError in train_new_from_iterator() in tokenization_utils_fast.py - #34661
Closed
sindhuvahinis wants to merge 2 commits into
Closed
sindhuvahinis wants to merge 2 commits into
sindhuvahinis wants to merge 2 commits into
Conversation
LysandreJik
approved these changes
Nov 18, 2024
LysandreJik
left a comment
Member
There was a problem hiding this comment.
This seems reasonable, yes
cc @ArthurZucker for final look but feel free to merge if you're lacking bandwidth
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
Sounds good but the failing test seems related: test_training_new_tokenizer_with_bytelevel vould you check it?
Collaborator
|
Thanks @sindhuvahinis for the fix! The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes # (issue)
When calling train_new_from_iterator() on a tokenizer initialized using AutoTokenizer.from_pretrained(), the following error is raised:
Error traceback:
Root Cause
The issue is due to improper handling of the conditional check for pre_tokenizer in tokenization_utils_fast.py. The current implementation does not correctly account for the case where tokenizer_json does not contain the "pre_tokenizer" key. This results in attempting to access "type" from a NoneType object, causing a TypeError. This bug seems to be existing from transformers version 4.45.2 onwards.
Manually tested with the above code.
@ArthurZucker