From 72f3e972cc0683b9c3a2a781a9b92febc85524a5 Mon Sep 17 00:00:00 2001 From: awinml <97467100+awinml@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:05:45 +0530 Subject: [PATCH] Enrich documents with embeddings instead of recreating documents --- .../instructor_embedders/instructor_document_embedder.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/instructor-embedders/instructor_embedders/instructor_document_embedder.py b/components/instructor-embedders/instructor_embedders/instructor_document_embedder.py index 7fd369cd2..fc2d43b93 100644 --- a/components/instructor-embedders/instructor_embedders/instructor_document_embedder.py +++ b/components/instructor-embedders/instructor_embedders/instructor_document_embedder.py @@ -126,11 +126,7 @@ def run(self, documents: List[Document]): normalize_embeddings=self.normalize_embeddings, ) - documents_with_embeddings = [] for doc, emb in zip(documents, embeddings): - doc_as_dict = doc.to_dict() - doc_as_dict["embedding"] = emb - del doc_as_dict["id"] - documents_with_embeddings.append(Document.from_dict(doc_as_dict)) + doc.embedding = emb - return {"documents": documents_with_embeddings} + return {"documents": documents}