Skip to content
Snippets Groups Projects
Unverified Commit 0e39c369 authored by Kirushikesh DB's avatar Kirushikesh DB Committed by GitHub
Browse files

Updated the simple fusion to handle duplicate nodes (#11542)

parent a88bc070
No related branches found
No related tags found
No related merge requests found
...@@ -130,7 +130,11 @@ class QueryFusionRetriever(BaseRetriever): ...@@ -130,7 +130,11 @@ class QueryFusionRetriever(BaseRetriever):
for nodes_with_scores in results.values(): for nodes_with_scores in results.values():
for node_with_score in nodes_with_scores: for node_with_score in nodes_with_scores:
text = node_with_score.node.get_content() text = node_with_score.node.get_content()
all_nodes[text] = node_with_score if text in all_nodes:
max_score = max(node_with_score.score, all_nodes[text].score)
all_nodes[text].score = max_score
else:
all_nodes[text] = node_with_score
return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True) return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True)
......
...@@ -127,7 +127,11 @@ class QueryFusionRetriever(BaseRetriever): ...@@ -127,7 +127,11 @@ class QueryFusionRetriever(BaseRetriever):
for nodes_with_scores in results.values(): for nodes_with_scores in results.values():
for node_with_score in nodes_with_scores: for node_with_score in nodes_with_scores:
text = node_with_score.node.get_content() text = node_with_score.node.get_content()
all_nodes[text] = node_with_score if text in all_nodes:
score = max(node_with_score.score, all_nodes[text].score)
all_nodes[text].score = score
else:
all_nodes[text] = node_with_score
return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True) return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment