dspy.evaluate.answer_passage_match
dspy.evaluate.answer_passage_match
dspy.evaluate.answer_passage_match(example, pred, trace=None)
pred.context의 어떤 구절이라도 답(들)을 포함하면 True를 돌려줘요. 검색(retrieval) 평가용 메트릭이에요.
문자열은 정규화되고(구절은 내부적으로 DPR 정규화도 사용) 답에는 normalize_text가 적용돼요.
| 이름 | 타입 | 설명 | 기본값 |
|---|---|---|---|
example |
answer 필드(str 또는 list[str])가 있는 dspy.Example 객체 |
필수 | |
pred |
context 필드(list[str], 구절들)가 있는 dspy.Prediction 객체 |
필수 | |
trace |
사용 안 함. 호환성용 예약 | None |
반환:
| 이름 | 타입 | 설명 |
|---|---|---|
bool |
어떤 구절이 어떤 참조 답을 포함하면 True, 아니면 False |
예시:
import dspy
example = dspy.Example(answer="Eiffel Tower")
pred = dspy.Prediction(context=["The Eiffel Tower is in Paris.", "..."])
answer_passage_match(example, pred) # True
소스: dspy/evaluate/metrics.py
answer가 문자열이면 _passage_match(pred.context, [example.answer]), 리스트면 _passage_match(pred.context, example.answer)을 호출해요. 그 외 타입이면 ValueError가 나요.
출처: 공식문서
더 알아보기 (Learn more)
- 메트릭과 평가 —
answer_passage_match가 쓰는 정규화 동작. - 통합 평가 도구 dspy.Evaluate