Use the last reasoning delimiter - #6662
Open
RerankerGuo wants to merge 1 commit into
Open
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
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.
What does this PR do?
reasoning_accuracy_rewarddocuments the final answer as the text after the last occurrence of any configured reasoning delimiter. The current loop instead stops at the first delimiter type fromreasoning_delimitersthat appears anywhere, even if another configured delimiter occurs later in the completion.This change computes the end positions of all matching delimiters and slices after the textually last one. It preserves the existing behavior for repeated occurrences of one delimiter and for completions with no matching delimiter.
Fixes #6661
PR #6222 also touches
accuracy_rewards.py, but it adds separate reward factories and does not modify this delimiter-selection block.Verification
The regression test replaces only the optional math parser/verifier so it runs even when
math_verifyis not installed. It demonstrates that argument-list order no longer overrides completion order.Before the fix:
After the fix:
Commands:
The 20 skipped tests are existing tests gated on optional math dependencies. The new regression test executed without that extra. Pre-commit passed Ruff check, Ruff format, and doc-builder style.
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 familiar with the reward utilities can review this focused change.
Note
Low Risk
Small, localized change to reward parsing logic with a targeted test; behavior only shifts for multi-delimiter completions where list order previously disagreed with text order.
Overview
reasoning_accuracy_rewardnow takes the final answer from the text after the latest matching delimiter in the completion, not after the first delimiter type listed inreasoning_delimiters. Delimiter selection usesrfindacross all configured delimiters and slices at the maximum end position; missing delimiters still yield a 0.0 incomplete-reasoning penalty.A regression test mocks
math_verifyso it runs without optional deps and checks that when</think>appears before</analysis>, grading uses the text after</analysis>.Reviewed by Cursor Bugbot for commit 1771628. Bugbot is set up for automated code reviews on this repo. Configure here.