InMemoryEmbeddingRetriever
Retrieves documents that are most semantically similar to the query.
Basic Information
- Type:
haystack_integrations.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| query_embedding | List[float] | Embedding of the query. | |
| filters | Optional[Dict[str, Any]] | None | A dictionary with filters to narrow down the search space when retrieving documents. |
| top_k | Optional[int] | None | The maximum number of documents to return. |
| scale_score | Optional[bool] | None | When 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_embedding | Optional[bool] | None | When True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | The retrieved documents. |
Overview
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
| document_store | InMemoryDocumentStore | An instance of InMemoryDocumentStore where the retriever should search for relevant documents. | |
| filters | Optional[Dict[str, Any]] | None | A dictionary with filters to narrow down the retriever's search space in the document store. |
| top_k | int | 10 | The maximum number of documents to retrieve. |
| scale_score | bool | False | When 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_embedding | bool | False | When True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings. |
| filter_policy | FilterPolicy | FilterPolicy.REPLACE | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query_embedding | List[float] | Embedding of the query. | |
| filters | Optional[Dict[str, Any]] | None | A dictionary with filters to narrow down the search space when retrieving documents. |
| top_k | Optional[int] | None | The maximum number of documents to return. |
| scale_score | Optional[bool] | None | When 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_embedding | Optional[bool] | None | When True, returns the embedding of the retrieved documents. When False, returns just the documents, without their embeddings. |
Was this page helpful?