MCPcopy Create free account
hub / github.com/MARIO-Math-Reasoning/Super_MARIO / eval_jsonl

Function eval_jsonl

eval_output_jsonl.py:18–37  ·  view source on GitHub ↗
(res_file: str, react: bool = False)

Source from the content-addressed store, hash-verified

16
17
18def eval_jsonl(res_file: str, react: bool = False) -> float:
19 cnt, total = 0, 0
20 with open(res_file, "r") as f:
21 for line in tqdm(f):
22 d = json.loads(line.strip())
23 answer = d["answer"]
24 if react:
25 # react is the only one solution.
26 last_tag = sorted(d["react"].keys(), key=lambda x: len(x), reverse=True)[0]
27 prediction = d["react"][last_tag]["final_answer"]
28 else:
29 if d["react"]["solutions"]:
30 # get top-1
31 prediction = d["react"]["solutions"][0]["final_answer"]
32 else:
33 prediction = ""
34 if math_is_equiv(answer, prediction):
35 cnt += 1
36 total += 1
37 return cnt / total
38
39
40if __name__ == '__main__':

Callers 1

Calls 1

math_is_equivFunction · 0.90

Tested by

no test coverage detected