MostSimilarDocumentsPipeline for Retrieving Similar Sentences #3299
-
Use Case: retrieve I'm thinking of using For my use case, I may have entirely new query sentences that are not part of the document store. And my understanding is that Any help is appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi,
You will simply pass the text from the sentence that you want to find all similar documents and it will create the embeddings that sentence and then just run the same query_by_embeddings method that the MSD uses. Here is a simple outline of the code: document_store = ElasticserachDocumentStore(similarity='cosine') Note, you may need to use a PreProcessor() to clean/split the text unless it is fairly short in length. I just kept this as a simple example. |
Beta Was this translation helpful? Give feedback.
Hi,
You will simply pass the text from the sentence that you want to find all similar documents and it will create the embeddings that sentence and then just run the same query_by_embeddings method that the MSD uses.
Here is a simple outline of the code:
document_store = ElasticserachDocumentStore(similarity='cosine')
retriever = EmbeddingRetriever(document_store=document_store, embedding_model='sentence-transformers/all-mpnet-base-v2')
search_pi…