dspy.evaluate.answer_exact_match¶
dspy.evaluate.answer_exact_match(example, pred, trace=None, frac=1.0)
¶
Evaluate exact match or F1-thresholded match for an example/prediction pair.
If example.answer is a string, compare pred.answer against it. If it's a list,
compare against any of the references. When frac >= 1.0 (default), use EM;
otherwise require that the maximum F1 across references is at least frac.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
example
|
|
required | |
pred
|
|
required | |
trace
|
Unused; reserved for compatibility. |
None
|
|
frac
|
float
|
Threshold in [0.0, 1.0]. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the match condition holds; otherwise False. |
Example
Source code in dspy/evaluate/metrics.py
:::