Fix AutoTokenizer.register() for transformers 5.13.0+ compatibility#1459
Open
jonpspri wants to merge 1 commit into
Open
Fix AutoTokenizer.register() for transformers 5.13.0+ compatibility#1459jonpspri wants to merge 1 commit into
jonpspri wants to merge 1 commit into
Conversation
- Replace string parameter with NewlineTokenizerConfig class - Add NewlineTokenizerConfig with model_type='newline_tokenizer' - Add test case for registration verification - Maintains backward compatibility with transformers <5.13.0 Fixes ml-explore#1458
|
See #1465 |
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.
Description
Fixes #1458
This PR addresses the breaking change in transformers 5.13.0 where
AutoTokenizer.register()now requires a config class instead of a string as the first parameter.Changes
NewlineTokenizerConfigclass: A properPreTrainedConfigsubclass withmodel_type = "newline_tokenizer"AutoTokenizer.register()call: Changed from string"NewlineTokenizer"toNewlineTokenizerConfigclasstest_newline_tokenizer_registration()to verify the fix and prevent regressionCompatibility
✅ Backward compatible: Works with transformers 5.7.0+ (including 5.12.x and 5.13.0+)
The fix follows the proper API that was always documented - the string parameter was never officially supported but happened to work due to lax validation in older versions.
Testing
AttributeError: 'str' object has no attribute '__module__'NewlineTokenizerConfig.__module__="mlx_lm.tokenizer_utils"(doesn't start with "transformers.")Related Issues
transformers==5.13.0breaksmlx-lm/mlx-vlmimports due to string auto-registration #1458AutoProcessor.register()