mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-22 16:49:06 +00:00
updated spell backward impl
This commit is contained in:
parent
1c930a5e23
commit
35fe482c4d
1 changed files with 14 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import re
|
||||
from dataclasses import dataclass
|
||||
from random import Random
|
||||
from typing import Optional
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from ..data import read_data_file
|
||||
from ..factory import ProceduralDataset, register_dataset
|
||||
|
|
@ -49,5 +49,18 @@ class SpellBackwardDataset(ProceduralDataset):
|
|||
"metadata": {"word": word, "word_len": len(word)},
|
||||
}
|
||||
|
||||
def score_answer(self, answer: Optional[str], entry: Dict[str, Any]) -> float:
|
||||
reward = 0
|
||||
expected_answer = entry["answer"]
|
||||
if answer is not None:
|
||||
try:
|
||||
if expected_answer.lower() == answer.lower():
|
||||
reward = 1.0
|
||||
else:
|
||||
reward = 0.05
|
||||
except:
|
||||
reward = 0.01
|
||||
return reward
|
||||
|
||||
|
||||
register_dataset("spell_backward", SpellBackwardDataset, SpellBackwardConfig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue