-
Notifications
You must be signed in to change notification settings - Fork 76
Add transformers v5 compatibility #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Maxusmusti
wants to merge
1
commit into
main
Choose a base branch
from
transformer-v5-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,19 +18,17 @@ def setup_tokenizer_with_existing_chat_template( | |
| # we need to set the padding token | ||
| tokenizer.add_special_tokens({"pad_token": tokenizer.eos_token}) | ||
|
|
||
| # ensure the pad token is in the additional special tokens without duplicating anything else | ||
| # ensure the pad token is in the extra special tokens without duplicating anything else | ||
| new_tokens = [] | ||
| if tokenizer.pad_token not in tokenizer.additional_special_tokens: | ||
| if tokenizer.pad_token not in tokenizer.extra_special_tokens: | ||
| new_tokens.append(tokenizer.pad_token) | ||
| if tokenizer.eos_token not in tokenizer.additional_special_tokens: | ||
| if tokenizer.eos_token not in tokenizer.extra_special_tokens: | ||
| new_tokens.append(tokenizer.eos_token) | ||
|
|
||
| # ensure the tokens are being sorted to prevent any issues | ||
| new_tokens = sorted(new_tokens) | ||
| additional_special_tokens = tokenizer.additional_special_tokens + new_tokens | ||
| tokenizer.add_special_tokens( | ||
| {"additional_special_tokens": additional_special_tokens} | ||
| ) | ||
| extra_special_tokens = tokenizer.extra_special_tokens + new_tokens | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol these tokens are extra special |
||
| tokenizer.add_special_tokens({"extra_special_tokens": extra_special_tokens}) | ||
|
|
||
| # ensure the necessary tokens exist | ||
| assert len(get_sp_token(tokenizer, tokenizer.pad_token)) == 1, ( | ||
|
|
@@ -57,7 +55,7 @@ def setup_tokenizer_from_new_chat_template( | |
| } | ||
| ) | ||
| tokenizer.add_special_tokens( | ||
| {"additional_special_tokens": SPECIAL_TOKENS.get_tokens_to_add()} | ||
| {"extra_special_tokens": SPECIAL_TOKENS.get_tokens_to_add()} | ||
| ) | ||
| if getattr(tokenizer, "add_bos_token", False) or getattr( | ||
| tokenizer, "add_eos_token", False | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
transformers 5.0.0 minimum Python version requirements dependencies💡 Result:
transformers 5.0.0 minimum Python version
Requires-Pythonon PyPI). [1]Runtime (core) dependencies (required)
Listed dependencies for
transformerson piwheels are: filelock, huggingface-hub, numpy, packaging, pyyaml, regex, requests, safetensors, tokenizers, tqdm. [2]Framework requirement (practical)
pip install "transformers[torch]"). [1]Sources: [1], [2]
🌐 Web query:
transformers 5.0.0 breaking changes release notes💡 Result:
Here are the Transformers 5.0.0 breaking / backward-incompatible changes, straight from the official v5.0.0 release notes (released Jan 26, 2026). [1]
Library-wide
from_pretrained(... )default dtype is nowauto(instead of forcing FP32). [2]use_auth_tokenis deprecated in favor oftokeneverywhere. [2]Attention / Torch / Quantization
torchscriptandtorch.fx(focus is now ondynamo/export). [3]load_in_4bitandload_in_8bit→ usequantization_configinstead. [4]Configuration
from_xxx_config. [4]config.rope_parameters; e.g. accessingconfig.rope_thetacan now error. [4]generation_config;model.config.generation_configmay now error. [5]Tokenization / Processing
tokenization_<model>.pywith backend selection. [6]encode_plus -> __call__,batch_decode -> decode, andapply_chat_templatenow returns aBatchEncoding. [5]XXXFeatureExtractorsremoved in favor ofXXXImageProcessorfor vision models. [5]Modeling / Generate / Trainer / Hub / CLI
forward()now accept**kwargs. [7]no_cuda -> use_cpu,per_gpu_* -> per_device_*, etc.). [8]push_to_hubis now keyword-only (exceptrepo_id), no**kwargs, removeduse_temp_dir, etc. [8]transformers-cliremoved;transformers ...is the only entry point;transformers chat/servesplit, andtransformers runremoved. [8]TRANSFORMERS_CACHEin favor ofHF_HOME; plushuggingface_hub-related changes (e.g. requests→httpx error type). [9]If you tell me what you’re upgrading from (e.g. 4.57.x → 5.0.0) and which parts you use (Trainer, tokenizers, quantization, CLI), I can produce a short “search/replace + code changes” checklist.
🌐 Web query:
transformers 5.0.0 PyPI package metadata tokenizers huggingface-hub compatibility💡 Result:
For
transformers==5.0.0(released Jan 26, 2026), the published package metadata indicates:Python >=3.10(PyPI) [1]huggingface-hubandtokenizers(among others likenumpy,safetensors,tqdm, etc.) [2]transformersnow requireshuggingface_hub >= 1.0.0[3]What this means for
tokenizers/huggingface-hubcompatibilityBecause
transformersdepends on bothhuggingface-hubandtokenizers[2] and also enforceshuggingface_hub >= 1.0.0[3], you must use atokenizersversion that does not pinhuggingface_hubto<1.0.0—otherwise pip’s resolver will fail with a version conflict (this kind of conflict is documented historically whentokenizerspinnedhuggingface_hubto an upper bound) [4].Practical rule: with
transformers==5.0.0, keephuggingface_hubon 1.x and ensuretokenizersis new enough to be compatible with that.Sources:
[1] https://pypi.org/project/transformers/
[2] https://www.piwheels.org/project/transformers/
[3] https://newreleases.io/project/pypi/transformers/release/5.0.0
[4] huggingface/transformers#26276
Verify Transformers v5.0.0 compatibility—breaking changes affect multiple APIs.
The bump to >=5.0.0 introduces major breaking changes beyond Python/dependency updates:
huggingface-hub >= 1.0.0andtokenizers(ensure no version conflicts; oldertokenizersmay pinhuggingface-hubto <1.0.0).auto(not FP32); quantization args (load_in_4bit,load_in_8bit) removed in favor ofquantization_config; tokenizers API consolidated; Trainer args renamed/removed;transformers-cliremoved entirely;use_auth_tokendeprecated fortoken; and many more.Confirm your code does not use deprecated/removed APIs (quantization, trainer args, CLI, tokenizers functions, model config patterns). Update all affected code, CI, and docs accordingly.
🤖 Prompt for AI Agents