in evaluate_model_outputs.py [0:0]
def compare_answers(extracted: Any, gold: Any) -> bool:
"""Compare extracted answer with gold answer."""
if extracted is None or gold is None:
return False
try:
# Handle lists/tuples of expressions
if isinstance(extracted, (list, tuple)) and isinstance(gold, (list, tuple)):
if len(extracted) != len(gold):
return False
return all(sympy.simplify(a - b) == 0 for a, b in zip(extracted, gold))
# Handle single expressions
return sympy.simplify(extracted - gold) == 0
except Exception:
# If comparison fails (e.g. different types), return False
return False