Skip to content

Commit

Permalink
ZeroDivisionError in context_relevance (#154)
Browse files Browse the repository at this point in the history
Changed: python3.9/site-packages/ragas/metrics/context_relevance.py",
line 162, in _score_batch

From: `score = min(len(indices) / len(context_sents), 1)`

To: ``` if len(context_sents) == 0:
                        score = 0
                else:
score = min(len(indices) / len(context_sents), 1)```

fixes: #153

Co-authored-by: devtribble <[email protected]>
  • Loading branch information
DevanshuBrahmbhatt and devtribble authored Sep 23, 2023
1 parent eb9da37 commit 16407ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ragas/metrics/context_relevance.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def _score_batch(
if output.lower() != "insufficient information."
else []
)
score = min(len(indices) / len(context_sents), 1)
if len(context_sents) == 0:
score = 0
else:
score = min(len(indices) / len(context_sents), 1)
overlap_scores.append(score)
if self.strictness > 1:
agr_score = self.sent_agreement.evaluate(n_response)
Expand Down

0 comments on commit 16407ea

Please sign in to comment.