Skip to content

Commit

Permalink
fix: inverse distance (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahules786 committed Sep 10, 2024
1 parent 4e6a96a commit c615a9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ragas/metrics/_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ async def _single_turn_ascore(
response = sample.response
assert isinstance(reference, str), "Expecting a string"
assert isinstance(response, str), "Expecting a string"
return DISTANCE_MEASURE_MAP[self.distance_measure].distance(reference, response)
return 1 - DISTANCE_MEASURE_MAP[self.distance_measure].normalized_distance(
reference, response
)

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

0 comments on commit c615a9f

Please sign in to comment.