RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Refactor: Use Input Length In DefaultRerank (#9516)
Stephen Hufb77f9917b27
diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.pyindex 67155ee8db..3dca735e41 100644--- a/rag/llm/rerank_model.py+++ b/rag/llm/rerank_model.py@@ -100,7 +100,7 @@ class DefaultRerank(Base):old_dynamic_batch_size = self._dynamic_batch_sizeif max_batch_size is not None:self._dynamic_batch_size = max_batch_size- res = np.array([], dtype=float)+ res = np.array(len(pairs), dtype=float)i = 0while i < len(pairs):cur_i = i@@ -111,7 +111,7 @@ class DefaultRerank(Base):try:# call subclass implemented batch processing calculationbatch_scores = self._compute_batch_scores(pairs[i : i + current_batch])- res = np.append(res, batch_scores)+ res[i : i + current_batch] = batch_scoresi += current_batchself._dynamic_batch_size = min(self._dynamic_batch_size * 2, 8)break@@ -125,8 +125,8 @@ class DefaultRerank(Base):raiseif retry_count >= max_retries:raise RuntimeError("max retry times, still cannot process batch, please check your GPU memory")- self.torch_empty_cache()-++ self.torch_empty_cache()self._dynamic_batch_size = old_dynamic_batch_sizereturn np.array(res)