mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-23 14:40:03 +08:00
refine rerank (#1056)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
8295979bb2
commit
b8eedbdd86
@ -67,12 +67,12 @@ class DefaultRerank(Base):
|
||||
token_count = 0
|
||||
for _, t in pairs:
|
||||
token_count += num_tokens_from_string(t)
|
||||
batch_size = 32
|
||||
batch_size = 4096
|
||||
res = []
|
||||
for i in range(0, len(pairs), batch_size):
|
||||
scores = self._model.compute_score(pairs[i:i + batch_size], max_length=2048)
|
||||
scores = sigmoid(np.array(scores)).tolist()
|
||||
res.extend(scores)
|
||||
if isinstance(scores, float): res.append(scores)
|
||||
else: res.extend(scores)
|
||||
return np.array(res), token_count
|
||||
|
||||
|
||||
@ -124,7 +124,9 @@ class YoudaoRerank(DefaultRerank):
|
||||
for i in range(0, len(pairs), batch_size):
|
||||
scores = self._model.compute_score(pairs[i:i + batch_size], max_length=self._model.max_length)
|
||||
scores = sigmoid(np.array(scores)).tolist()
|
||||
if isinstance(scores, float): res.append(scores)
|
||||
res.extend(scores)
|
||||
return np.array(res), token_count
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user