Skip to content

Commit cd9dbc4

Browse files
authored
Limit context relevancy to 1 (#105)
fixes: #103
1 parent 9f54d01 commit cd9dbc4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/ragas/metrics/context_relevance.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,9 @@ def _score_batch(
159159
overlap_scores = []
160160
context_sents = sent_tokenize(context)
161161
for output in n_response:
162-
indices = [
163-
context.find(sent)
164-
for sent in sent_tokenize(output)
165-
if context.find(sent) != -1
166-
]
167162
indices = sent_tokenize(output)
168-
overlap_scores.append(len(indices) / len(context_sents))
163+
score = min(len(indices) / len(context_sents), 1)
164+
overlap_scores.append(score)
169165
if self.strictness > 1:
170166
agr_score = self.sent_agreement.evaluate(n_response)
171167
else:

0 commit comments

Comments
 (0)