Skip to content

Commit

Permalink
fix tp&fp calc error (#1848)
Browse files Browse the repository at this point in the history
#1796 Compatibility is being fixed due to different sample trigger
points
  • Loading branch information
oslijunw authored Jan 18, 2025
1 parent b8c6be2 commit 5ce585c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ragas/metrics/_factual_correctness.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ async def _single_turn_ascore(
else:
response_reference = np.array([])

response_reference = np.array(response_reference, dtype=bool)
tp = sum(reference_response)
fp = sum(~reference_response)
if self.mode != "precision":
response_reference = np.array(response_reference, dtype=bool)
fn = sum(~response_reference)
else:
fn = 0
Expand Down
5 changes: 3 additions & 2 deletions src/ragas/testset/synthesizers/multi_hop/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ def convert_to_scenario(self, data: t.Dict[str, t.Any]) -> MultiHopScenario:
)

async def _generate_sample(
self, scenario: MultiHopScenario, callbacks: Callbacks
self, scenario: Scenario, callbacks: Callbacks
) -> SingleTurnSample:

if not isinstance(scenario, MultiHopScenario):
raise TypeError('scenario type should be MultiHopScenario')
reference_context = self.make_contexts(scenario)
prompt_input = QueryConditions(
persona=scenario.persona,
Expand Down
5 changes: 3 additions & 2 deletions src/ragas/testset/synthesizers/single_hop/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ def convert_to_scenario(self, data: t.Dict[str, t.Any]) -> SingleHopScenario:
)

async def _generate_sample(
self, scenario: SingleHopScenario, callbacks: Callbacks
self, scenario: Scenario, callbacks: Callbacks
) -> SingleTurnSample:

if not isinstance(scenario, SingleHopScenario):
raise TypeError('scenario type should be SingleHopScenario')
reference_context = scenario.nodes[0].properties.get("page_content", "")
prompt_input = QueryCondition(
persona=scenario.persona,
Expand Down

0 comments on commit 5ce585c

Please sign in to comment.