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
Refa: Remove useless conver and fix a bug for DefaultRerank (#8887)
Stephen Hu38b34116ddfc
diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.pyindex 88fda1478f..4c21fd2708 100644--- a/rag/llm/rerank_model.py+++ b/rag/llm/rerank_model.py@@ -101,9 +101,10 @@ 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 = []+ res = np.array([], dtype=float)i = 0while i < len(pairs):+ cur_i = icurrent_batch = self._dynamic_batch_sizemax_retries = 5retry_count = 0@@ -111,7 +112,7 @@ class DefaultRerank(Base):try:# call subclass implemented batch processing calculationbatch_scores = self._compute_batch_scores(pairs[i : i + current_batch])- res.extend(batch_scores)+ res = np.append(res, batch_scores)i += current_batchself._dynamic_batch_size = min(self._dynamic_batch_size * 2, 8)break@@ -119,6 +120,7 @@ class DefaultRerank(Base):if "CUDA out of memory" in str(e) and current_batch > self._min_batch_size:current_batch = max(current_batch // 2, self._min_batch_size)self.torch_empty_cache()+ i = cur_i # reset i to the start of the current batchretry_count += 1else:raise@@ -134,7 +136,7 @@ class DefaultRerank(Base):scores = self._model.compute_score(batch_pairs)else:scores = self._model.compute_score(batch_pairs, max_length=max_length)- scores = sigmoid(np.array(scores)).tolist()+ scores = sigmoid(np.array(scores))if not isinstance(scores, Iterable):scores = [scores]return scores