Repository navigation
fix(sleep): match exact and keyword scores on token boundaries - #438
Merged
Yifan Yang (Yif-Yang) merged 2 commits intoNov 23, 2026
Merged
Yifan Yang (Yif-Yang) merged 2 commits into
Yifan Yang (Yif-Yang) merged 2 commits into
Conversation
exact_score checked `ref in resp` on normalized text, so a reference of "42" scored 1.0 against a response of "420", and "arXiv:1706.0376" against "arXiv:1706.03762". This is the hard score for tasks with an exact reference, scored locally on the real backends. keyword_soft_score had the same substring check, so "form" counted as found in "information". Pad both normalized strings with spaces for exact_score and compare keywords against the response's token set.
Keep both CHANGELOG entries; no other change.
Contributor
|
Merged, thank you. |
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.
Summary
exact_scoreinskillopt_sleep/backend.pycheckedref in respon normalized text, so a reference inside a longer token counted as an exact match:"42"scored 1.0 against"420", andarXiv:1706.0376againstarXiv:1706.03762. This is the hard score forexacttasks, scored locally by the real and mock backends.keyword_soft_scorehad the same substring check, soformcounted as found ininformation.Changes
exact_score: pads both normalized strings with spaces, so the reference has to appear as whole tokens.keyword_soft_score: checks each keyword against the response's set of tokens.CHANGELOG.md: entry under Fixed._normalizealready turns punctuation into spaces, soarXiv:1706.03762still matches inside a sentence, and the existing tests intests/test_sleep_engine.pypass unchanged.Tests
New
tests/test_sleep_exact_score.py:42in420, a shorter arXiv id,Parisincomparison) scores 0keyword_soft_scoreignores a keyword inside a longer word and counts whole wordsThe new negative tests fail on main and pass with the fix. Full suite: 2402 passed, 12 skipped, 4 xfailed.
ruff checkandruff format --checkpass on the new test file.Fixes #436