-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SumanthRH <sumanthrh@anyscale.com>
- Loading branch information
Showing
16 changed files
with
1,457 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
from .base import Scorer | ||
from .gsm8k import GSM8KScorer | ||
from .ifeval import IfEvalScorer | ||
from .livecodebench import LiveCodeBenchScorer | ||
from .math import MathScorer | ||
from .math import MathEqualScorer, MathVerifyScorer | ||
|
||
__all__ = ["Scorer", "MathScorer", "GSM8KScorer", "LiveCodeBenchScorer", "IfEvalScorer"] | ||
__all__ = ["Scorer", "MathEqualScorer", "MathVerifyScorer", "GSM8KScorer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .apps import APPSScorer | ||
|
||
__all__ = ["APPSScorer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import copy | ||
import json | ||
from typing import Any, Dict | ||
|
||
import numpy as np | ||
import ray | ||
from ray.exceptions import GetTimeoutError | ||
|
||
from skythought.evals.scoring.base import Scorer | ||
from skythought.evals.tasks.apps.apps_util import run_test as apps_run_test | ||
from skythought.evals.util.common import has_code | ||
|
||
|
||
class APPSScorer(Scorer): | ||
SCORE_COLUMN = "apps_score" | ||
|
||
def __init__( | ||
self, | ||
response_column="response", | ||
answer_column="solutions", | ||
input_column="input_output", | ||
) -> None: | ||
super().__init__() | ||
self.response_column = response_column | ||
self.answer_column = answer_column | ||
self.input_column = input_column | ||
|
||
def score(self, row: Dict[str, Any]): | ||
TIMEOUT = 10 | ||
code_filter_result = has_code(row[self.response_column]) | ||
if len(code_filter_result) == 0: | ||
return {self.SCORE_COLUMN: False} | ||
else: | ||
last_code = code_filter_result[-1] | ||
problem_to_check = copy.deepcopy(row) | ||
problem_to_check[self.input_column] = json.loads(row[self.input_column]) | ||
try: | ||
problem_to_check[self.answer_column] = json.loads( | ||
row[self.answer_column] | ||
) | ||
except Exception: | ||
problem_to_check[self.answer_column] = "" | ||
|
||
@ray.remote | ||
def _temp_run(problem, generation, debug): | ||
try: | ||
result = apps_run_test(problem=problem, test=generation, debug=debug) | ||
return result | ||
except Exception: | ||
pass | ||
|
||
try: | ||
result = ray.get( | ||
_temp_run.remote(problem_to_check, last_code, False), | ||
timeout=TIMEOUT + 1, | ||
) | ||
except GetTimeoutError: | ||
result = [] | ||
|
||
score = bool(result and np.all(result[0])) | ||
return {self.SCORE_COLUMN: score} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.