Skip to content

Commit

Permalink
Enrich documents with embeddings instead of recreating documents (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
awinml authored Oct 19, 2023
1 parent 955f8f9 commit 8d15314
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 8d15314

Please sign in to comment.