Skip to content

Accept processor in get_training_chat_template#5560

Merged
qgallouedec merged 25 commits into
mainfrom
processor-in-get_training_chat_template
May 5, 2026
Merged

Accept processor in get_training_chat_template#5560
qgallouedec merged 25 commits into
mainfrom
processor-in-get_training_chat_template

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Apr 15, 2026

Copy link
Copy Markdown
Member

get_training_chat_template already works on both PreTrainedTokenizer and ProcessorMixin. The type hint, parameter name, and docstring were misleading by saying "tokenizer" only. Call sites (e.g. GRPOTrainer, SFTTrainer) already pass processing_class.


Note

Low Risk
Low risk API tweak: adds processing_class as the primary parameter with a deprecating alias for tokenizer, so breakage is unlikely but callers passing both args will now error and deprecation warnings may surface.

Overview
get_training_chat_template now takes a processing_class (tokenizer or ProcessorMixin) instead of a tokenizer-only parameter, aligning the type hints and docs with existing processor support.

For backward compatibility it adds a deprecated tokenizer alias that emits a FutureWarning and rejects passing both arguments, and updates internal checks/error messaging to reference the generic processing class/chat template rather than “tokenizer” specifically.

Reviewed by Cursor Bugbot for commit bb6d08d. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa61a92ea2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread trl/chat_template_utils.py Outdated
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6700975. Configure here.

Comment thread trl/chat_template_utils.py
Comment thread trl/chat_template_utils.py Outdated

@albertvillanova albertvillanova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is red:

AttributeError: 'NoneType' object has no attribute 'chat_template'

@albertvillanova albertvillanova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@albertvillanova

Copy link
Copy Markdown
Member

@qgallouedec, should we consider get_training_chat_template as a public API function?

@qgallouedec

Copy link
Copy Markdown
Member Author

currently, it is considered public. I don't have strong opinion about it. I was a bit uncertain in the first place, see #5090.

@qgallouedec qgallouedec merged commit 225a234 into main May 5, 2026
13 checks passed
@qgallouedec qgallouedec deleted the processor-in-get_training_chat_template branch May 5, 2026 15:48
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.

3 participants