Skip to content

Commit c615a9f

Browse files
authored
fix: inverse distance (#1267)
1 parent 4e6a96a commit c615a9f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ragas/metrics/_string.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ async def _single_turn_ascore(
8181
response = sample.response
8282
assert isinstance(reference, str), "Expecting a string"
8383
assert isinstance(response, str), "Expecting a string"
84-
return DISTANCE_MEASURE_MAP[self.distance_measure].distance(reference, response)
84+
return 1 - DISTANCE_MEASURE_MAP[self.distance_measure].normalized_distance(
85+
reference, response
86+
)
8587

8688
async def _ascore(self, row: t.Dict, callbacks: Callbacks) -> float:
8789
return await self._single_turn_ascore(SingleTurnSample(**row), callbacks)

0 commit comments

Comments
 (0)