eval_multi_choice:v42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import re
import weave
@weave.op()
def extract_answer(output: str) -> str:
match = re.search(r"Final Answer:\s*([A-F])", output.strip(), re.IGNORECASE)
if match:
return match.group(1).upper()
else:
raise ValueError("No answer found in model output")
@weave.op()
def eval_multi_choice(output: str, answer: str):
model_answer = extract_answer(output)
return model_answer == answer