Fix tokenizer files search on HunggingFace #1618
Open
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.
Fix: Tokenizer File Search When Loading Models from Hugging Face
The previous implementation only searched for tokenizer files (tokenizer_config.json, tokenizer.json, and special_tokens_map.json) if the model name pointed to a local directory. This meant that when loading a model from Hugging Face, the tokenizer files were not properly searched for or loaded. As a result, the chat_template from a locally saved tokenizer would load successfully, but the same would fail for models downloaded from Hugging Face.
This fix ensures that tokenizer files are searched for both locally and on Hugging Face. Now, the chat_template and other tokenizer configurations will load correctly regardless of whether the model is loaded from a local directory or Hugging Face.