-
Notifications
You must be signed in to change notification settings - Fork 552
Fix transformers API compatibility: support v4.26+ and v5.0+ with version-aware parameter selection #1514
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
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/fix-ci-test-failures-huggingface
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.
+43
−29
Conversation
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
Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CI test failures due to Hugging Face transformers changes
Fix transformers v5 API compatibility: remove as_target_tokenizer, use processing_class
Jan 27, 2026
Collaborator
|
@copilot , will the new code work for Transformers v4? |
Support both tokenizer (v4.26-4.43) and processing_class (v4.44+) parameters based on installed transformers version. Fallback to tokenizer if version check fails. Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Contributor
Author
Yes, the updated code now works with both Transformers v4 and v5. It uses version detection:
This maintains compatibility with FLAML's requirement of Commit: 0e276e8 |
Use specific exception types (ImportError, AttributeError, ValueError) instead of broad Exception catch for better error handling. Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Copilot
AI
changed the title
Fix transformers v5 API compatibility: remove as_target_tokenizer, use processing_class
Fix transformers API compatibility: support v4.26+ and v5.0+ with version-aware parameter selection
Jan 27, 2026
Collaborator
|
@copilot , run |
Applied black formatting to fix code style across the repository. Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Contributor
Author
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.
Fixing Hugging Face Transformers API Compatibility Issues
Summary
Fixed CI test failures caused by deprecated Hugging Face transformers v5.0+ API changes with backward compatibility for v4.26+.
Completed Changes
as_target_tokenizer()context manager is deprecated (line 214 inflaml/automl/nlp/huggingface/utils.py)tokenizer=parameter inSeq2SeqTrainer/TrainerForAutois deprecated (line 1204 inflaml/automl/model.py)as_target_tokenizer()context manager fromtokenize_onedataframe()functionprocessing_classfor transformers >= 4.44.0tokenizerfor transformers < 4.44.0 (v4.26-4.43)tokenizerif version check failspre-commit run --all-filesto ensure all formatting is correctVerification Complete
as_target_tokenizerFiles Changed
flaml/automl/nlp/huggingface/utils.py- Removed deprecated context managerflaml/automl/model.py- Added version-aware parameter selection for backward compatibilityImpact
Minimal changes that fix compatibility with transformers v5.0+ while maintaining backward compatibility with v4.26+. Expected to resolve all failing NLP tests across different transformers versions.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.