Skip to content

Fix AutoTokenizer.register() for transformers 5.13.0+ compatibility#1459

Open
jonpspri wants to merge 1 commit into
ml-explore:mainfrom
jonpspri:fix/issue-1458-autotokenizer-register
Open

Fix AutoTokenizer.register() for transformers 5.13.0+ compatibility#1459
jonpspri wants to merge 1 commit into
ml-explore:mainfrom
jonpspri:fix/issue-1458-autotokenizer-register

Conversation

@jonpspri

@jonpspri jonpspri commented Jul 3, 2026

Copy link
Copy Markdown

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

  • Added NewlineTokenizerConfig class: A proper PreTrainedConfig subclass with model_type = "newline_tokenizer"
  • Updated AutoTokenizer.register() call: Changed from string "NewlineTokenizer" to NewlineTokenizerConfig class
  • Added test case: test_newline_tokenizer_registration() to verify the fix and prevent regression

Compatibility

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

  • Verified import succeeds without AttributeError: 'str' object has no attribute '__module__'
  • Confirmed NewlineTokenizerConfig.__module__ = "mlx_lm.tokenizer_utils" (doesn't start with "transformers.")
  • Added unit test to verify config class attributes and registration

Related Issues

- 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
@menisadi

menisadi commented Jul 6, 2026

Copy link
Copy Markdown

See #1465

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.

transformers==5.13.0 breaks mlx-lm / mlx-vlm imports due to string auto-registration

2 participants