Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/fixEmbeddin…
Browse files Browse the repository at this point in the history
…gCompatibility

* upstream/main:
  fix: zero division error (#1530)
  • Loading branch information
Yuri-Albuquerque committed Oct 18, 2024
2 parents 56b4106 + 807c313 commit 5d7525b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/ragas/metrics/_factual_correctness.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ async def _single_turn_ascore(
false_negatives = sum(~response_reference)

if self.mode == "precision":
score = true_positives / (true_positives + false_positives)
score = true_positives / (true_positives + false_positives + 1e-8)
elif self.mode == "recall":
score = true_positives / (true_positives + false_negatives)
score = true_positives / (true_positives + false_negatives + 1e-8)
else:
precision = true_positives / (true_positives + false_positives)
recall = true_positives / (true_positives + false_negatives)
precision = true_positives / (true_positives + false_positives + 1e-8)
recall = true_positives / (true_positives + false_negatives + 1e-8)
score = 2 * (precision * recall) / (precision + recall + 1e-8)

return np.round(score, 2)
Expand Down
3 changes: 0 additions & 3 deletions src/ragas/testset/synthesizers/testset_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
SingleTurnSample,
)

if t.TYPE_CHECKING:
from ragas.dataset_schema import MultiTurnSample, SingleTurnSample


class TestsetSample(BaseSample):
"""
Expand Down

0 comments on commit 5d7525b

Please sign in to comment.