Docs: fix Training step by removing tokenizer from trainer initialization#43733
Merged
stevhliu merged 2 commits intohuggingface:mainfrom Feb 4, 2026
Merged
Docs: fix Training step by removing tokenizer from trainer initialization#43733stevhliu merged 2 commits intohuggingface:mainfrom
stevhliu merged 2 commits intohuggingface:mainfrom
Conversation
…tion We already provide the tokenizer in the data_collator. Trying to provide the tokenizer parameter in the Trainer() __init__() method produces the following error: TypeError: Trainer.__init__() got an unexpected keyword argument 'tokenizer'
There was a problem hiding this comment.
Pull request overview
Updates the Quicktour training example to align with the current Trainer API by removing the deprecated/removed tokenizer argument, preventing a runtime TypeError during initialization.
Changes:
- Remove
tokenizer=tokenizerfrom theTrainer(...)initialization snippet in the Quicktour docs.
SunMarc
reviewed
Feb 4, 2026
| args=training_args, | ||
| train_dataset=dataset["train"], | ||
| eval_dataset=dataset["test"], | ||
| tokenizer=tokenizer, |
Member
There was a problem hiding this comment.
we changed it to processing_class
Contributor
Author
There was a problem hiding this comment.
Thanks for the heads up, forgot that being optional does not mean it is not required for some cases.
I pushed the change and provided a similar replacement in 2 more docs
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Summary
This PR removes the deprecated tokenizer parameter from the Quicktour documentation examples.
As of the v5.0.0 release, the tokenizer argument was officially replaced from the Trainer constructor. Currently, the documentation example fails with a TypeError, preventing users from completing the introductory tutorial.
Changes
Location:
Action: Replaced tokenizer=tokenizer from the Trainer initialization by processing_class=tokenizer
Reasoning: The tokenizer is officially replaced by processing_class:
TypeError: Trainer.init() got an unexpected keyword argument 'tokenizer'
Related Resources
Breaking Change Reference: Transformers v5.0.0 Release Notes
Affected Doc Page: Quicktour - Training Step
Checklist
[x] This PR fixes a typo or improves the docs.
cc @stevhliu @SunMarc