Use AutoTokenizer.from() for faster tokenizer loading#33
Draft
DePasqualeOrg wants to merge 6 commits intoml-explore:mainfrom
Draft
Use AutoTokenizer.from() for faster tokenizer loading#33DePasqualeOrg wants to merge 6 commits intoml-explore:mainfrom
AutoTokenizer.from() for faster tokenizer loading#33DePasqualeOrg wants to merge 6 commits intoml-explore:mainfrom
Conversation
Collaborator
|
This looks good -- is is ready to merge? |
Contributor
Author
|
I think we should wait for huggingface/swift-transformers#303 to be merged. I'll mark this as ready for review at that time. |
Collaborator
|
8e741f3 to
607860b
Compare
8d50a4d to
e9f0f0d
Compare
e9f0f0d to
70a6635
Compare
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.
swift-transformers PR #303 offers significantly faster tokenizer loading when using
AutoTokenizer.from(). It also covers the tokenizer remapping and registration that is currently done in mlx-swift-lm, so we can remove that and use the fast path here after that PR is merged.Changes
loadTokenizernow usesAutoTokenizer.from()directly instead of manually loading configs and callingPreTrainedTokenizerinitAutoTokenizer.from()revisionparameter toModelConfigurationfor consistency with MLXLMCommonhub.snapshot()loadTokenizerinstead of inline config loadingAPI Changes
Deprecated:
loadTokenizerConfig: UseLanguageModelConfigurationFromHubfrom swift-transformers directly, which allows users to opt in to the fast path withstripVocabForPerformance: true.Unavailable (breaking change):
TokenizerReplacementRegistry/replacementTokenizers: UseAutoTokenizer.register(_:for:)from swift-transformers instead. These no longer function with the newAutoTokenizer.from()code path.Offline Mode
The offline fallback logic has been removed, as it's handled automatically by the swift-transformers Hub API. When offline,
HubApi.snapshot()detects the network state viaNWPathMonitorand falls back to cached files if available.