Skip to content

dspy.evaluate.answer_exact_match

dspy.evaluate.answer_exact_match(example, pred, trace=None, frac=1.0)

Source code in dspy/evaluate/metrics.py
def answer_exact_match(example, pred, trace=None, frac=1.0):
    if isinstance(example.answer, str):
        return _answer_match(pred.answer, [example.answer], frac=frac)
    elif isinstance(example.answer, list):
        return _answer_match(pred.answer, example.answer, frac=frac)

    raise ValueError(f"Invalid answer type: {type(example.answer)}")