You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-website/reference/haystack-api/retrievers_api.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -927,7 +927,8 @@ __init__(
927
927
*,
928
928
retrievers: dict[str, TextRetriever],
929
929
filters: dict[str, Any] |None=None,
930
-
top_k: int=10,
930
+
top_k_per_retriever: int|None=None,
931
+
top_k: int|None=None,
931
932
max_workers: int=4,
932
933
join_mode: Literal[
933
934
"concatenate", "reciprocal_rank_fusion"
@@ -942,7 +943,12 @@ Create the MultiRetriever component.
942
943
-**retrievers** (<code>dict\[str, TextRetriever\]</code>) – A dictionary mapping names to text retrievers (implementing the `TextRetriever` protocol) to run in
943
944
parallel.
944
945
-**filters** (<code>dict\[str, Any\] | None</code>) – A dictionary of filters to apply when retrieving documents.
945
-
-**top_k** (<code>int</code>) – The maximum number of documents to return per retriever.
946
+
-**top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. If set, this will override the `top_k`
947
+
parameter for each retriever. If None, the `top_k` parameter of retrievers will be used.
948
+
-**top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
949
+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
950
+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
951
+
`top_k`. If None, all results are returned.
946
952
-**max_workers** (<code>int</code>) – The maximum number of threads to use for parallel retrieval.
947
953
-**join_mode** (<code>Literal['concatenate', 'reciprocal_rank_fusion']</code>) – How to merge results from multiple retrievers. Available modes:
948
954
-`concatenate`: Combines all results into a single list and deduplicates.
@@ -962,6 +968,7 @@ Warm up the retrievers if any has a warm_up method.
962
968
run(
963
969
query: str,
964
970
filters: dict[str, Any] |None=None,
971
+
top_k_per_retriever: int|None=None,
965
972
top_k: int|None=None,
966
973
*,
967
974
active_retrievers: list[str] |None=None
@@ -974,7 +981,13 @@ Runs retrievers in parallel on the given query and returns deduplicated results.
974
981
975
982
-**query** (<code>str</code>) – The query to run the retrievers on.
976
983
-**filters** (<code>dict\[str, Any\] | None</code>) – Filters to apply. Defaults to the value set at initialization.
977
-
-**top_k** (<code>int | None</code>) – Maximum documents to return per retriever. Defaults to the value set at initialization.
984
+
-**top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. When set, this will override the `top_k`
985
+
parameter for each retriever. If None, the `top_k` parameter set for retrievers will be used.
986
+
Defaults to the value set at initialization.
987
+
-**top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
988
+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
989
+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
990
+
`top_k`. If None, all results are returned. Defaults to the value set at initialization.
978
991
-**active_retrievers** (<code>list\[str\] | None</code>) – Names of retrievers to run. Defaults to all. Must match keys in the `retrievers` dictionary.
979
992
980
993
**Returns:**
@@ -992,6 +1005,7 @@ Runs retrievers in parallel on the given query and returns deduplicated results.
992
1005
run_async(
993
1006
query: str,
994
1007
filters: dict[str, Any] |None=None,
1008
+
top_k_per_retriever: int|None=None,
995
1009
top_k: int|None=None,
996
1010
*,
997
1011
active_retrievers: list[str] |None=None
@@ -1006,7 +1020,13 @@ Uses each retriever's `run_async` method if available, otherwise runs `run` in a
1006
1020
1007
1021
-**query** (<code>str</code>) – The query to run the retrievers on.
1008
1022
-**filters** (<code>dict\[str, Any\] | None</code>) – Filters to apply. Defaults to the value set at initialization.
1009
-
-**top_k** (<code>int | None</code>) – Maximum documents to return per retriever. Defaults to the value set at initialization.
1023
+
-**top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. When set, this will override the `top_k`
1024
+
parameter for each retriever. If None, the `top_k` parameter set for retrievers will be used.
1025
+
Defaults to the value set at initialization.
1026
+
-**top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
1027
+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
1028
+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
1029
+
`top_k`. If None, all results are returned. Defaults to the value set at initialization.
1010
1030
-**active_retrievers** (<code>list\[str\] | None</code>) – Names of retrievers to run. Defaults to all. Must match keys in the `retrievers` dictionary.
0 commit comments