Skip to content

Commit

Permalink
Updated the simple fusion to handle duplicate nodes (#11542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirushikesh authored Mar 1, 2024
1 parent a88bc07 commit 0e39c36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ def _simple_fusion(
for nodes_with_scores in results.values():
for node_with_score in nodes_with_scores:
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)

This comment has been minimized.

Copy link
@c4pi

c4pi Mar 5, 2024

Please fix. This is not working if we are using a KeywordTableSimpleRetriever and pass them to a QueryFusionRetriever. This will throw an error because the nodes from the KeywordTableSimpleRetriever have no scores.

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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def _simple_fusion(
for nodes_with_scores in results.values():
for node_with_score in nodes_with_scores:
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

This comment has been minimized.

Copy link
@c4pi

c4pi Mar 5, 2024

Please fix. This is not working if we are using a KeywordTableSimpleRetriever and pass them to a QueryFusionRetriever. This will throw an error because the nodes from the KeywordTableSimpleRetriever have no scores.

else:
all_nodes[text] = node_with_score

return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True)

Expand Down

0 comments on commit 0e39c36

Please sign in to comment.