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] use sympy only when necessary #255

Merged
merged 1 commit into from
Aug 24, 2023
Merged
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
5 changes: 3 additions & 2 deletions opencompass/datasets/game24.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import List

import pandas as pd
import sympy
from datasets import Dataset

from opencompass.openicl.icl_evaluator import BaseEvaluator
Expand Down Expand Up @@ -234,6 +233,8 @@ def game24_postprocess(output: str):
class Game24Evaluator(BaseEvaluator):

def __init__(self) -> None:
import sympy
self.sympy = sympy
super().__init__()

def check_nums(self, prediction, reference):
Expand All @@ -242,7 +243,7 @@ def check_nums(self, prediction, reference):
if sorted(numbers) != sorted(problem_numbers):
return 0
try:
return int(sympy.simplify(prediction) == 24)
return int(self.sympy.simplify(prediction) == 24)
except Exception:
return 0

Expand Down