-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the simple fusion to handle duplicate nodes (#11542)
- Loading branch information
1 parent
a88bc07
commit 0e39c36
Showing
2 changed files
with
10 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong.
c4pi
|
||
else: | ||
all_nodes[text] = node_with_score | ||
|
||
return sorted(all_nodes.values(), key=lambda x: x.score or 0.0, reverse=True) | ||
|
||
|
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.