InMemoryBM25Retriever
Retrieves documents that are most similar to the query using keyword-based algorithm.
Basic Information
- Type:
haystack_integrations.retrievers.in_memory.bm25_retriever.InMemoryBM25Retriever
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | The query string for the Retriever. | |
| 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. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[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 similar to the query using keyword-based algorithm.
Use this retriever with the InMemoryDocumentStore.
Usage Example
components:
InMemoryBM25Retriever:
type: components.retrievers.in_memory.bm25_retriever.InMemoryBM25Retriever
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. |
| 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 | str | The query string for the Retriever. | |
| 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. |
Was this page helpful?