From b236ea49e3f373fdd7ecd11712a28e084a73d85e Mon Sep 17 00:00:00 2001 From: ZanSara Date: Mon, 15 Jan 2024 14:20:02 +0100 Subject: [PATCH] fix: hybrid pipeline e2e test (#6740) * fix hybrid pipeline e2e test * warmup * write to the right docstore --- e2e/pipelines/test_hybrid_doc_search_pipeline.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e/pipelines/test_hybrid_doc_search_pipeline.py b/e2e/pipelines/test_hybrid_doc_search_pipeline.py index 477e9f731..4436bfab6 100644 --- a/e2e/pipelines/test_hybrid_doc_search_pipeline.py +++ b/e2e/pipelines/test_hybrid_doc_search_pipeline.py @@ -1,10 +1,11 @@ import json from haystack import Pipeline, Document -from haystack.components.embedders import SentenceTransformersTextEmbedder +from haystack.components.embedders import SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder from haystack.components.rankers import TransformersSimilarityRanker from haystack.components.joiners.document_joiner import DocumentJoiner from haystack.document_stores.in_memory import InMemoryDocumentStore +from haystack.document_stores.types import DuplicatePolicy from haystack.components.retrievers.in_memory import InMemoryBM25Retriever, InMemoryEmbeddingRetriever @@ -47,6 +48,10 @@ def test_hybrid_doc_search_pipeline(tmp_path): Document(content="My name is Giorgio and I live in Rome."), ] hybrid_pipeline.get_component("bm25_retriever").document_store.write_documents(documents) + doc_embedder = SentenceTransformersDocumentEmbedder(model="sentence-transformers/all-MiniLM-L6-v2") + doc_embedder.warm_up() + embedded_documents = doc_embedder.run(documents=documents)["documents"] + hybrid_pipeline.get_component("embedding_retriever").document_store.write_documents(embedded_documents) query = "Who lives in Rome?" result = hybrid_pipeline.run(