Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Failed to parse gold solution: error #509

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/open_r1/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ def accuracy_reward(completions, solution, **kwargs):
"""Reward function that checks if the completion is the same as the ground truth."""
contents = [completion[0]["content"] for completion in completions]
rewards = []
for content, sol in zip(contents, solution):
gold_parsed = parse(
sol,
extraction_mode="first_match",
extraction_config=[LatexExtractionConfig()],
)
answers = kwargs["answer"] if "answer" in kwargs else None
for content, answer in zip(contents, answers):
# No need to parse the solution, as grpo rewards function returns answers only
gold_parsed = answer
if len(gold_parsed) != 0:
# We require the answer to be provided in correct latex (no malformed operators)
answer_parsed = parse(
Expand Down Expand Up @@ -61,7 +59,7 @@ def accuracy_reward(completions, solution, **kwargs):
else:
# If the gold solution is not parseable, we reward 1 to skip this example
reward = 1.0
print("Failed to parse gold solution: ", sol)
print("Failed to parse gold solution: ", answer)
rewards.append(reward)

return rewards
Expand Down