Skip to content

Commit a501ba4

Browse files
Merge pull request #830 from tom-doerr/patch-2
Add missing gold_passages_retrieved function
2 parents eab1324 + 2d32d14 commit a501ba4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/docs/tutorials/simplified-baleen.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ Let's now define our evaluation function and compare the performance of the unco
193193
```python
194194
from dspy.evaluate.evaluate import Evaluate
195195

196+
# Define metric to check if we retrieved the correct documents
197+
def gold_passages_retrieved(example, pred, trace=None):
198+
gold_titles = set(map(dspy.evaluate.normalize_text, example["gold_titles"]))
199+
found_titles = set(
200+
map(dspy.evaluate.normalize_text, [c.split(" | ")[0] for c in pred.context])
201+
)
202+
return gold_titles.issubset(found_titles)
203+
196204
# Set up the `evaluate_on_hotpotqa` function. We'll use this many times below.
197205
evaluate_on_hotpotqa = Evaluate(devset=devset, num_threads=1, display_progress=True, display_table=5)
198206

0 commit comments

Comments
 (0)