Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tp&fp calc error #1848

Merged
merged 3 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines 259 to 264
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahules786 can you check this part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this looks better.

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
Loading