From 89c91ded2a8792dfc3eb07007cd459a182cac082 Mon Sep 17 00:00:00 2001 From: Serge Panev Date: Wed, 28 Aug 2024 01:12:19 +0300 Subject: [PATCH] SentenceTransformer encode with torch --- examples/text_embedder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/text_embedder.py b/examples/text_embedder.py index b277bc41..9094496b 100644 --- a/examples/text_embedder.py +++ b/examples/text_embedder.py @@ -15,4 +15,4 @@ def __init__(self, device: Optional[torch.device] = None): ) def __call__(self, sentences: List[str]) -> Tensor: - return torch.from_numpy(self.model.encode(sentences)) + return self.model.encode(sentences, convert_to_tensor=True)