Skip to main content

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

ParameterTypeDefaultDescription
querystrThe query string for the Retriever.
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.

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 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:

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.
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
querystrThe query string for the Retriever.
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.