@@ -115,10 +115,10 @@ def __init__(
115
115
if isinstance (join_mode , str ):
116
116
join_mode = JoinMode .from_str (join_mode )
117
117
join_mode_functions = {
118
- JoinMode .CONCATENATE : self ._concatenate ,
118
+ JoinMode .CONCATENATE : DocumentJoiner ._concatenate ,
119
119
JoinMode .MERGE : self ._merge ,
120
120
JoinMode .RECIPROCAL_RANK_FUSION : self ._reciprocal_rank_fusion ,
121
- JoinMode .DISTRIBUTION_BASED_RANK_FUSION : self ._distribution_based_rank_fusion ,
121
+ JoinMode .DISTRIBUTION_BASED_RANK_FUSION : DocumentJoiner ._distribution_based_rank_fusion ,
122
122
}
123
123
self .join_mode_function = join_mode_functions [join_mode ]
124
124
self .join_mode = join_mode
@@ -162,7 +162,8 @@ def run(self, documents: Variadic[List[Document]], top_k: Optional[int] = None):
162
162
163
163
return {"documents" : output_documents }
164
164
165
- def _concatenate (self , document_lists : List [List [Document ]]) -> List [Document ]:
165
+ @staticmethod
166
+ def _concatenate (document_lists : List [List [Document ]]) -> List [Document ]:
166
167
"""
167
168
Concatenate multiple lists of Documents and return only the Document with the highest score for duplicates.
168
169
"""
@@ -230,7 +231,8 @@ def _reciprocal_rank_fusion(self, document_lists: List[List[Document]]) -> List[
230
231
231
232
return list (documents_map .values ())
232
233
233
- def _distribution_based_rank_fusion (self , document_lists : List [List [Document ]]) -> List [Document ]:
234
+ @staticmethod
235
+ def _distribution_based_rank_fusion (document_lists : List [List [Document ]]) -> List [Document ]:
234
236
"""
235
237
Merge multiple lists of Documents and assign scores based on Distribution-Based Score Fusion.
236
238
@@ -256,7 +258,7 @@ def _distribution_based_rank_fusion(self, document_lists: List[List[Document]])
256
258
doc .score = (doc .score - min_score ) / delta_score if delta_score != 0.0 else 0.0
257
259
# if all docs have the same score delta_score is 0, the docs are uninformative for the query
258
260
259
- output = self ._concatenate (document_lists = document_lists )
261
+ output = DocumentJoiner ._concatenate (document_lists = document_lists )
260
262
261
263
return output
262
264
0 commit comments