Skip to content

Commit

Permalink
fix: add missing query qualifier (#1733)
Browse files Browse the repository at this point in the history
fixes: #1718
  • Loading branch information
shahules786 authored Dec 5, 2024
1 parent 1ac4eac commit 99d9425
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ragas/testset/synthesizers/multi_hop/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def _generate_scenarios(
nodes,
concept_combination.combinations,
personas=persona_list,
persona_item_mapping=persona_concepts.mappping,
persona_item_mapping=persona_concepts.mapping,
property_name="themes",
)
base_scenarios = self.sample_diverse_combinations(
Expand Down
18 changes: 12 additions & 6 deletions src/ragas/testset/synthesizers/multi_hop/specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class MultiHopSpecificQuerySynthesizer(MultiHopQuerySynthesizer):
theme_persona_matching_prompt: PydanticPrompt = ThemesPersonasMatchingPrompt()
generate_query_reference_prompt: PydanticPrompt = QueryAnswerGenerationPrompt()

def get_node_clusters(self, knowledge_graph: KnowledgeGraph) -> t.List[t.Tuple]:

node_clusters = knowledge_graph.find_two_nodes_single_rel(
relationship_condition=lambda rel: (
True if rel.type == self.relation_type else False
)
)
logger.info("found %d clusters", len(node_clusters))
return node_clusters

async def _generate_scenarios(
self,
n: int,
Expand All @@ -63,11 +73,7 @@ async def _generate_scenarios(
4. Return the list of scenarios of length n
"""

triplets = knowledge_graph.find_two_nodes_single_rel(
relationship_condition=lambda rel: (
True if rel.type == self.relation_type else False
)
)
triplets = self.get_node_clusters(knowledge_graph)

if len(triplets) == 0:
raise ValueError(
Expand Down Expand Up @@ -97,7 +103,7 @@ async def _generate_scenarios(
[node_a, node_b],
overlapped_items,
personas=persona_list,
persona_item_mapping=persona_concepts.mappping,
persona_item_mapping=persona_concepts.mapping,
property_name=self.property_name,
)
base_scenarios = self.sample_diverse_combinations(
Expand Down

0 comments on commit 99d9425

Please sign in to comment.