fix: restore missing tokenizer_class attribute in ModelInfos.__init__ - #44663
Closed
Ker102 wants to merge 1 commit into
Closed
fix: restore missing tokenizer_class attribute in ModelInfos.__init__#44663Ker102 wants to merge 1 commit into
tokenizer_class attribute in ModelInfos.__init__#44663Ker102 wants to merge 1 commit into
Conversation
PR huggingface#40936 changed TOKENIZER_MAPPING_NAMES from (slow, fast) tuples to single fast tokenizer class names, but forgot to set self.tokenizer_class in the 'if' branch of ModelInfos.__init__. This causes an AttributeError when get_user_input() accesses old_model_infos.tokenizer_class at line 719 for models that are in TOKENIZER_MAPPING_NAMES (e.g. qwen2_5_vl). The else branch already correctly sets both tokenizer_class and fast_tokenizer_class to None. This fix adds the same assignment in the if branch. Fixes huggingface#44661
Member
|
No drive-by code agent PRs! https://github.com/huggingface/transformers/blob/main/AGENTS.md#coordination-before-coding |
Author
|
Sorry, I had only read the CONTRIBUTING.md file, I just wanted to provide a solution to this issue, could I still work on it? |
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.
Summary
Fixes #44661 —
transformers add-new-model-likecrashes withAttributeError: 'ModelInfos' object has no attribute 'tokenizer_class'when selecting a model that is inTOKENIZER_MAPPING_NAMES.Root Cause
PR #40936 refactored
TOKENIZER_MAPPING_NAMESfrom(slow_class, fast_class)tuples to single fast tokenizer class names. During this change,self.tokenizer_classwas removed from theifbranch inModelInfos.__init__(line 144), butget_user_input()still accesses it at line 719:The
elsebranch (when the model is NOT inTOKENIZER_MAPPING_NAMES) correctly setsself.tokenizer_class = None, but theifbranch (when it IS in the mapping) never assigns it at all.Fix
Add
self.tokenizer_class = Nonein theifbranch ofModelInfos.__init__, matching the behavior of theelsebranch:if self.lowercase_name in TOKENIZER_MAPPING_NAMES: + self.tokenizer_class = None self.fast_tokenizer_class = TOKENIZER_MAPPING_NAMES[self.lowercase_name]Reproduction