You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromhaystack_integrations.components.retrievers.mongodb_atlasimportMongoDBAtlasEmbeddingRetrieverfromhaystack_integrations.document_stores.mongodb_atlasimportMongoDBAtlasDocumentStoreimportosfromhaystack.dataclassesimportDocumentfromhaystack.components.embeddersimportSentenceTransformersDocumentEmbedderfromhaystack.components.embeddersimportSentenceTransformersDocumentEmbedderos.environ["MONGO_CONNECTION_STRING"]="..."document_store=MongoDBAtlasDocumentStore(
database_name="test",
collection_name="test",
vector_search_index="vector_index",
)
# indexing phasedocs= [Document(content="This is a test", meta={"name": "test"}), Document(content="this is a document about dogs", meta={"name": "dog_doc"}),
Document(content="this is a document about cats", meta={"name": "cat_doc"})]
embedder=SentenceTransformersDocumentEmbedder(model="BAAI/bge-small-en-v1.5")
embedder.warm_up()
docs_with_embeddings=embedder.run(docs)["documents"]
print(document_store.write_documents(docs_with_embeddings))
# 3# retrieval phaseretriever=MongoDBAtlasEmbeddingRetriever(document_store=document_store, top_k=3)
results=retriever.run(query_embedding=[0.1]*384)
print(results)
# {'documents': [Document(id=0fc6abdbe5192ea10917b506084077451b47ccf097d5899f963a193b048a33a7, content: 'this is a document about cats', meta: {'name': 'cat_doc'}, score: 0.5037540197372437, embedding: vector of size 384), Document(id=ffd30337557ed1870cb5833d832c1a3c41f4889b3545e9c0b5e69108592661fd, content: 'This is a test', meta: {'name': 'test'}, score: 0.503305971622467, embedding: vector of size 384), Document(id=274731104067ab6f2e07380d4b1cd20112b26cd99fc6f36da8f9f4a7d6f06e00, content: 'this is a document about dogs', meta: {'name': 'dog_doc'}, score: 0.5031192898750305, embedding: vector of size 384)]}
I also tried a more complex example, with a Retrieval Pipeline with a Text Embedder and a Ranker, but I cannot reproduce the error.
@tillwf I'm closing the issue. Feel free to reopen it and add more details if the problem persists.
Describe the bug
Like this bug: deepset-ai/haystack#7031 but with
haystack-ai==2.0.0
Error message
To Reproduce
Here is a simple code to reproduce:
Here is a screen of my index I made:
and the code I used to create it:
FAQ Check
System:
The text was updated successfully, but these errors were encountered: