Skip to main content

InMemoryEmbeddingRetriever

Retrieves documents that are most semantically similar to the query.

Basic Information

  • Type: haystack_integrations.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever

Inputs

ParameterTypeDefaultDescription
query_embeddingList[float]Embedding of the query.
filtersOptional[Dict[str, Any]]NoneA dictionary with filters to narrow down the search space when retrieving documents.
top_kOptional[int]NoneThe maximum number of documents to return.
scale_scoreOptional[bool]NoneWhen True, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant. When False, uses raw similarity scores.
return_embeddingOptional[bool]NoneWhen True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings.

Outputs

ParameterTypeDefaultDescription
documentsList[Document]The retrieved documents.

Overview

Work in Progress

Bear with us while we're working on adding pipeline examples and most common components connections.

Retrieves documents that are most semantically similar to the query.

Use this retriever with the InMemoryDocumentStore.

When using this retriever, make sure it has query and document embeddings available. In indexing pipelines, use a DocumentEmbedder to embed documents. In query pipelines, use a TextEmbedder to embed queries and send them to the retriever.

Usage Example

components:
InMemoryEmbeddingRetriever:
type: components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
init_parameters:

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
document_storeInMemoryDocumentStoreAn instance of InMemoryDocumentStore where the retriever should search for relevant documents.
filtersOptional[Dict[str, Any]]NoneA dictionary with filters to narrow down the retriever's search space in the document store.
top_kint10The maximum number of documents to retrieve.
scale_scoreboolFalseWhen True, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant. When False, uses raw similarity scores.
return_embeddingboolFalseWhen True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings.
filter_policyFilterPolicyFilterPolicy.REPLACEThe filter policy to apply during retrieval. Filter policy determines how filters are applied when retrieving documents. You can choose: - REPLACE (default): Overrides the initialization filters with the filters specified at runtime. Use this policy to dynamically change filtering for specific queries. - MERGE: Combines runtime filters with initialization filters to narrow down the search.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
query_embeddingList[float]Embedding of the query.
filtersOptional[Dict[str, Any]]NoneA dictionary with filters to narrow down the search space when retrieving documents.
top_kOptional[int]NoneThe maximum number of documents to return.
scale_scoreOptional[bool]NoneWhen True, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant. When False, uses raw similarity scores.
return_embeddingOptional[bool]NoneWhen True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings.