Skip to content

Conversation

@SunMarc
Copy link
Member

@SunMarc SunMarc commented Nov 28, 2025

What does this PR do?

This PR fixes a warning that shouldn't appear in a specific case when calling AutoTokenizer.from_pretrained. config_tokenizer_class and cls.__name__ might not the same due to the alias we created.

# Backward-compatible alias: allow referring to TokenizersBackend as PreTrainedTokenizerFast
PreTrainedTokenizerFast = TokenizersBackend

So config_tokenizer_class ends up being PreTrainedTokenizerFast and when checking the class name cls.__name__ we get TokenizersBackend .

The warning is not needed anymore, so let's remove it entirely.

Reproduction

>>> from transformers import AutoTokenizer
>>> tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")

Warning:

The tokenizer class you load from this checkpoint is 'PreTrainedTokenizerFast'.
The class this function is called from is 'TokenizersBackend'.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to remove it entirely its no longer valid

@SunMarc SunMarc changed the title fix tokenizer warning remove tokenizer warning Nov 28, 2025
init_kwargs = json.load(tokenizer_config_handle)
# First attempt. We get tokenizer_class from tokenizer_config to check mismatch between tokenizers.
config_tokenizer_class = init_kwargs.get("tokenizer_class")
# used in the past to check if the tokenizer class matches the class in the repo
init_kwargs.pop("tokenizer_class", None)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a small comment here to understand why we pop tokenizer_class. Maybe we don't even need to pop it ?

@ArthurZucker ArthurZucker merged commit e51e75e into main Dec 1, 2025
20 of 24 checks passed
@ArthurZucker ArthurZucker deleted the fix-warning branch December 1, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants