dspy.evaluate.answer_passage_match¶
dspy.evaluate.answer_passage_match(example, pred, trace=None)
¶
Return True if any passage in pred.context contains the answer(s).
Strings are normalized (and passages also use DPR normalization internally).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
example
|
|
required | |
pred
|
|
required | |
trace
|
Unused; reserved for compatibility. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if any passage contains any reference answer; otherwise False. |
Examples:
import dspy
example = dspy.Example(answer="Eiffel Tower")
pred = dspy.Prediction(context=["The Eiffel Tower is in Paris.", "..."])
answer_passage_match(example, pred) # True