Skip to content

dspy.evaluate.answer_passage_match

dspy.evaluate.answer_passage_match(example, pred, trace=None)

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

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