Explorar el Código

FIX:ZeroDivisionError when using large page_size in client.retrieve() (#7595)

### What problem does this PR solve?

Close #7592

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.0
Stephen Hu hace 5 meses
padre
commit
573d46a4ef
No account linked to committer's email address
Se han modificado 2 ficheros con 3 adiciones y 1 borrados
  1. 1
    1
      api/apps/api_app.py
  2. 2
    0
      rag/nlp/search.py

+ 1
- 1
api/apps/api_app.py Ver fichero

@@ -861,7 +861,7 @@ def retrieval():
doc_ids = req.get("doc_ids", [])
question = req.get("question")
page = int(req.get("page", 1))
size = int(req.get("size", 30))
size = int(req.get("page_size", 30))
similarity_threshold = float(req.get("similarity_threshold", 0.2))
vector_similarity_weight = float(req.get("vector_similarity_weight", 0.3))
top = int(req.get("top_k", 1024))

+ 2
- 0
rag/nlp/search.py Ver fichero

@@ -355,6 +355,8 @@ class Dealer:

RERANK_LIMIT = 64
RERANK_LIMIT = int(RERANK_LIMIT//page_size + ((RERANK_LIMIT%page_size)/(page_size*1.) + 0.5)) * page_size if page_size>1 else 1
if RERANK_LIMIT < 1: ## when page_size is very large the RERANK_LIMIT will be 0.
RERANK_LIMIT = 1
req = {"kb_ids": kb_ids, "doc_ids": doc_ids, "page": math.ceil(page_size*page/RERANK_LIMIT), "size": RERANK_LIMIT,
"question": question, "vector": True, "topk": top,
"similarity": similarity_threshold,

Cargando…
Cancelar
Guardar