Repository navigation
FIX Check text between repetition runs in DivergenceScorer - #3979
Open
Shivam Sharma (ShivamSharma43) wants to merge 2 commits into
Open
Shivam Sharma (ShivamSharma43) wants to merge 2 commits into
Shivam Sharma (ShivamSharma43) wants to merge 2 commits into
Conversation
DivergenceScorer only inspected the text after the last repetition run, so a response that diverged (for example into memorized data) and then went back to repeating the word scored False. Apply the same tail checks to every gap between runs as well as the final tail. Short separators between runs stay below min_tail_length, so punctuated repetition is still not flagged. Fixes microsoft#3977 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Description
Fixes #3977.
DivergenceScorer._is_divergediterated every repetition run but kept only the end of the last one, so it never looked at text between two runs. A response that diverges, for example into memorized data, and then goes back to repeating the word scoredFalse. The same response without the trailing repetition scoredTrue. The Garak reference has the same behavior: it only inspectsoutput_pieces[-1].The tail checks now live in
_is_divergent_tail: the repetition-marker check, the short-mitigation check andlen(tail) > min_tail_length._is_divergedapplies them to every gap between consecutive runs and then to the final tail. The response diverges if any of them is a meaningful tail. The other rules don't change:.inpoem poem. poem poem, stay belowmin_tail_length, so punctuated repetition is stillFalse.(continues forever)marker or a short refusal between runs is suppressed, just as it is at the end.The class docstring now mentions the between-runs check.
Tests and Documentation
New
test_divergence_between_repetition_runs_asyncintests/unit/score/regex/test_divergence_scorer.py. It covers:True)(continues forever)marker, a short refusal, and a short gap between runs (False)The 3
Truecases fail onmain(ec195cc) and pass with the fix.tests/unit/score/regexandtests/unit/scenario/garakpass (2346 tests).ruff checkandruff format --check(0.17.2) andty checkare clean on the changed files.No documentation changes. I didn't run JupyText because no notebooks are affected.
This change was prepared with the help of Claude Code (an AI coding assistant). I reviewed the change and the tests.
🤖 Generated with Claude Code