feat(glm-4-moe): Add {% generation %} markers for training chat template#5519
Conversation
|
Thanks! lgtm! @codex review |
|
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. |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a2ab2d109
ℹ️ 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".
…m/casinca/trl into glm4-generation-training-template
What does this PR do?
This PR add
{% generation %}tags/markers for glm-4-moe: part of #5471nit: sorted models list to lexicographical order
added
thinkpatch like in qwen3, same pattern, on top of{% generation %}TestGetTrainingChatTemplatesuite fully passes with transformers > 5(not sure) I didn't add a skipif like in :added per codex reviewtrl/tests/test_chat_template_utils.py
Lines 154 to 161 in c73c2ec
Llama PR reverted
This is going to be a long sentence with other models 😅
Before submitting
AI writing disclosure
We welcome the use of AI tools to help with contributions. For transparency and to help us improve our review process, please indicate the level of AI involvement in this PR.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
following tool call #5463 @qgallouedec
Note
Medium Risk
Changes prompt rendering for GLM-4-MoE during training, which can affect masking and prefix-preservation behavior; however the change is isolated to template selection/formatting and guarded by exact-template identity checks.
Overview
Adds GLM-4-MoE support to
get_training_chat_templateby introducing a newglm4moe_training.jinjatemplate and returning it when the tokenizer matches the GLM-4-MoE base template.The new training template wraps assistant output in
{% generation %}/{% endgeneration %}for assistant-only loss masking and tightens<think>extraction to require both opening and closing tags to avoid mis-splitting partial generations. Tests are extended to cover GLM-4-MoE (skipped ontransformers<5.0.0), and the chat-templates README is updated to document the new patch.Reviewed by Cursor Bugbot for commit 6835d31. Bugbot is set up for automated code reviews on this repo. Configure here.