mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
[Fix] use sympy only when necessary (#255)
This commit is contained in:
parent
01372a4806
commit
bd47a00f27
@ -4,7 +4,6 @@ import re
|
||||
from typing import List
|
||||
|
||||
import pandas as pd
|
||||
import sympy
|
||||
from datasets import Dataset
|
||||
|
||||
from opencompass.openicl.icl_evaluator import BaseEvaluator
|
||||
@ -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):
|
||||
@ -242,7 +243,7 @@ class Game24Evaluator(BaseEvaluator):
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user