Skip to content

Commit

Permalink
Fix vector_id collision in FAISS (#1961)
Browse files Browse the repository at this point in the history
* Fix FAISS vector_id count

* Fix mypy errors

Co-authored-by: Yorick van Zweeden <git@yorickvanzweeden.nl>
  • Loading branch information
yorickvanzweeden and yorickvanzweeden authored Jan 5, 2022
1 parent 0b0b968 commit 65cd39b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions haystack/document_stores/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def update_embeddings(
return

logger.info(f"Updating embeddings for {document_count} docs...")
vector_id = self.faiss_indexes[index].ntotal
vector_id = sum([self.faiss_indexes[index].ntotal for index in self.faiss_indexes.keys()])

result = self._query(
index=index,
Expand All @@ -329,7 +329,7 @@ def update_embeddings(

vector_id_map = {}
for doc in document_batch:
vector_id_map[doc.id] = vector_id
vector_id_map[str(doc.id)] = str(vector_id)
vector_id += 1
self.update_vector_ids(vector_id_map, index=index)
progress_bar.set_description_str("Documents Processed")
Expand Down

0 comments on commit 65cd39b

Please sign in to comment.