fix: score think_format_reward when <think> is prefilled in the prompt - #7141
Open
behroozazarkhalili wants to merge 5 commits into
Open
behroozazarkhalili wants to merge 5 commits into
behroozazarkhalili wants to merge 5 commits into
Conversation
8 tasks
|
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. |
…the prompt GRPO decodes only the generated tokens, so models whose chat template prefills <think> into the prompt scored 0.0 on every well-formed completion. The opening tag is now optional, </think> is still required, and completions that start with <think> keep scoring 1.0. Based on the approach proposed in huggingface#6995. Fixes huggingface#6966.
behroozazarkhalili
force-pushed
the
reopen/6995
branch
from
September 9, 2026 17:25
efe3e84 to
d913b9e
Compare
This branch has not been deployed
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.
think_format_rewardrejected valid completions when the chat template had already placed the opening thinking tag in the prompt. I made the opening tag optional while keeping the closing tag required and rejecting nested opening tags. The reward test suite passes apart from skipped tests, and lint and format checks pass on both files.Fixes #6966.
Note
Medium Risk
Changes RL reward criteria for format shaping; broader acceptance (any completion with
</think>) may shift GRPO training signal versus the old strict opening-tag rule.Overview
think_format_rewardno longer requires a leading<think>tag so GRPO runs that decode only generated tokens (with the opening tag prefilled in the chat template) can earn 1.0 on well-formed reasoning. The matcher still requires</think>, forbids nested<think>, and uses an optional(?:<think>)?prefix on the existing regex.Docs and doctest examples describe this GRPO/prefill behavior. Tests add prefilled-prompt-style completions as valid, drop “closing tag without opening” from the invalid set, and document that a bare or text-mention
</think>also scores 1.0.Reviewed by Cursor Bugbot for commit d66dbb5. Bugbot is set up for automated code reviews on this repo. Configure here.