Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retrieval and retrieval token metrics to use unaswerable #371

Merged
merged 13 commits into from
Apr 26, 2024
8 changes: 7 additions & 1 deletion autorag/evaluate/metric/retrieval.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,13 @@
def retrieval_metric(func):
@functools.wraps(func)
def wrapper(retrieval_gt: List[List[List[str]]], pred_ids: List[List[str]]) -> List[float]:
return [func(gt, pred) for gt, pred in zip(retrieval_gt, pred_ids) if gt != [[]]]
results = []
for gt, pred in zip(retrieval_gt, pred_ids):
if gt == [[]]:
results.append(None)
else:
results.append(func(gt, pred))
return results

return wrapper