Skip to content

Commit

Permalink
Limit context relevancy to 1 (#105)
Browse files Browse the repository at this point in the history
fixes: #103
  • Loading branch information
shahules786 authored Sep 4, 2023
1 parent 9f54d01 commit cd9dbc4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/ragas/metrics/context_relevance.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,9 @@ def _score_batch(
overlap_scores = []
context_sents = sent_tokenize(context)
for output in n_response:
indices = [
context.find(sent)
for sent in sent_tokenize(output)
if context.find(sent) != -1
]
indices = sent_tokenize(output)
overlap_scores.append(len(indices) / len(context_sents))
score = min(len(indices) / len(context_sents), 1)
overlap_scores.append(score)
if self.strictness > 1:
agr_score = self.sent_agreement.evaluate(n_response)
else:
Expand Down

0 comments on commit cd9dbc4

Please sign in to comment.