From 50042f6655b60f6f2d0043c08a40237e56b323c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan?= Date: Sun, 18 May 2025 19:27:14 +0200 Subject: [PATCH] Update index.py --- index.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.py b/index.py index 7e78524..195826e 100644 --- a/index.py +++ b/index.py @@ -98,7 +98,9 @@ def main(): ) model = BGEM3FlagModel(MODEL_NAME, device="cpu") - emb = model.encode(new_docs, batch_size=BATCH, return_dict=False) + emb_out = model.encode(new_docs, batch_size=BATCH) + # FlagEmbedding renvoie soit un ndarray, soit un dict {"embedding": …} + emb = emb_out["embedding"] if isinstance(emb_out, dict) else emb_out emb = emb.astype("float32") emb /= np.linalg.norm(emb, axis=1, keepdims=True) + 1e-12