Monet / RL /examples /reward_function /answer_transformation.py
doubleblindsubmission's picture
Upload folder using huggingface_hub
1b74191 verified
Raw History Blame Contribute Delete
296 Bytes
import re
sqrt_pattern = r"√(?:\\*\{|\()([^{}()]+)(?:\\*\}|\))"
def answer_transformation_fn(
ans: str, # The answer to be transformed
) -> bool:
# Check if gt or pred contains "√{*}" and convert to "\sqrt{*}"
ans = re.sub(sqrt_pattern, r"\\sqrt{\1}", ans)
return ans