Upload 143 files
Browse files
hugging/td_fuse/grpo_reason.py
CHANGED
|
@@ -252,15 +252,27 @@ def verify_answer(problem: Dict, response: str) -> float:
|
|
| 252 |
says_one_heavier = any(w in answer_text for w in ["is heavier", "weighs more", "is more"])
|
| 253 |
return 1.0 if (has_same and not says_one_heavier) else 0.0
|
| 254 |
|
| 255 |
-
# For yes/no answers: check
|
| 256 |
if expected in ("yes", "no"):
|
| 257 |
-
# Look at the first sentence of the answer for the actual conclusion
|
| 258 |
-
first_sentence = answer_text.split(".")[0] if "." in answer_text else answer_text[:100]
|
| 259 |
if expected == "yes":
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
else:
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
# For "once" (subtract 5 from 25 trick):
|
| 266 |
if expected == "once":
|
|
|
|
| 252 |
says_one_heavier = any(w in answer_text for w in ["is heavier", "weighs more", "is more"])
|
| 253 |
return 1.0 if (has_same and not says_one_heavier) else 0.0
|
| 254 |
|
| 255 |
+
# For yes/no answers: check overall sentiment of the answer
|
| 256 |
if expected in ("yes", "no"):
|
|
|
|
|
|
|
| 257 |
if expected == "yes":
|
| 258 |
+
# Positive indicators anywhere in answer
|
| 259 |
+
yes_words = ["yes", "do breathe", "does breathe", "does need", "do need",
|
| 260 |
+
"correct", "true", "indeed", "absolutely", "certainly",
|
| 261 |
+
"they do", "it does", "they can", "it can"]
|
| 262 |
+
# Negative indicators that would flip it
|
| 263 |
+
no_words = ["no,", "no.", "not ", "cannot", "can't", "doesn't", "don't",
|
| 264 |
+
"is not", "are not", "do not"]
|
| 265 |
+
has_yes = any(w in answer_text for w in yes_words)
|
| 266 |
+
has_no = any(w in answer_text[:50] for w in no_words) # Only check start for negation
|
| 267 |
+
return 1.0 if has_yes and not has_no else 0.0
|
| 268 |
else:
|
| 269 |
+
# For "no" answers
|
| 270 |
+
no_words = ["no", "not", "cannot", "can't", "doesn't", "don't",
|
| 271 |
+
"neither", "isn't", "aren't", "we can't", "not necessarily",
|
| 272 |
+
"not definitely", "doesn't mean"]
|
| 273 |
+
yes_override = answer_text.strip().startswith("yes")
|
| 274 |
+
has_no = any(w in answer_text for w in no_words)
|
| 275 |
+
return 1.0 if has_no and not yes_override else 0.0
|
| 276 |
|
| 277 |
# For "once" (subtract 5 from 25 trick):
|
| 278 |
if expected == "once":
|