MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / extract_ans

Function extract_ans

light-eval/src/eval_math.py:90–105  ·  view source on GitHub ↗
(completion, answer)

Source from the content-addressed store, hash-verified

88 return None
89
90def extract_ans(completion, answer):
91
92 split_ans = re.split("Problem:", completion, flags=re.IGNORECASE)[0]
93 split_ans = re.split("answer is ", split_ans, flags=re.IGNORECASE)
94 if len(split_ans) > 1:
95 ans = split_ans[-1]
96 extract_ans_temp = ans.split('.\n')[0]
97 extract_ans_temp = extract_ans_temp.strip()
98 if len(extract_ans_temp)>0 and extract_ans_temp[-1] == '.':
99 extract_ans = extract_ans_temp[0:-1]
100 else:
101 extract_ans = extract_ans_temp
102 extract_ans = extract_ans.strip()
103 return extract_ans
104 else:
105 return None
106
107def batch_data(prompts, batch_size=1):
108 batch_data = []

Callers 1

run_evalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected