From fcf19139b10c5ee3f678c0663f4753cc4693f186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20=C4=90=C3=ACnh=20=C4=90=E1=BA=A1t?= Date: Fri, 26 Apr 2024 06:03:00 +0700 Subject: [PATCH] Fix for fusion retriever sometime return Nonetype query(s) before similarity search. (#13112) --- .../llama_index/core/retrievers/fusion_retriever.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llama-index-core/llama_index/core/retrievers/fusion_retriever.py b/llama-index-core/llama_index/core/retrievers/fusion_retriever.py index ae84a98e875c1..5c788ad25c940 100644 --- a/llama-index-core/llama_index/core/retrievers/fusion_retriever.py +++ b/llama-index-core/llama_index/core/retrievers/fusion_retriever.py @@ -89,6 +89,7 @@ def _get_queries(self, original_query: str) -> List[QueryBundle]: # assume LLM proper put each query on a newline queries = response.text.split("\n") + queries = [q.strip() for q in queries if q.strip()] if self._verbose: queries_str = "\n".join(queries) print(f"Generated queries:\n{queries_str}") @@ -99,7 +100,8 @@ def _get_queries(self, original_query: str) -> List[QueryBundle]: def _reciprocal_rerank_fusion( self, results: Dict[Tuple[str, int], List[NodeWithScore]] ) -> List[NodeWithScore]: - """Apply reciprocal rank fusion. + """ + Apply reciprocal rank fusion. The original paper uses k=60 for best results: https://plg.uwaterloo.ca/~gvcormac/cormacksigir09-rrf.pdf