|
12 | 12 | @component
|
13 | 13 | class InMemoryBM25Retriever:
|
14 | 14 | """
|
15 |
| - Retrieves documents using the BM25 algorithm. |
| 15 | + Retrieves documents that are most similar to the query using keyword-based algorithm. |
| 16 | +
|
| 17 | + Use this retriever with the InMemoryDocumentStore. |
| 18 | +
|
| 19 | + ### Usage example |
16 | 20 |
|
17 |
| - Usage example: |
18 | 21 | ```python
|
19 | 22 | from haystack import Document
|
20 | 23 | from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
|
@@ -47,15 +50,19 @@ def __init__(
|
47 | 50 | Create the InMemoryBM25Retriever component.
|
48 | 51 |
|
49 | 52 | :param document_store:
|
50 |
| - An instance of InMemoryDocumentStore. |
| 53 | + An instance of InMemoryDocumentStore where the retriever should search for relevant documents. |
51 | 54 | :param filters:
|
52 |
| - A dictionary with filters to narrow down the search space. |
| 55 | + A dictionary with filters to narrow down the retriever's search space in the document store. |
53 | 56 | :param top_k:
|
54 | 57 | The maximum number of documents to retrieve.
|
55 | 58 | :param scale_score:
|
56 |
| - Scales the BM25 score to a unit interval in the range of 0 to 1, where 1 means extremely relevant. |
57 |
| - If set to `False`, uses raw similarity scores. |
| 59 | + When `True`, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant. |
| 60 | + When `False`, uses raw similarity scores. |
58 | 61 | :param filter_policy: The filter policy to apply during retrieval.
|
| 62 | + Filter policy determines how filters are applied when retrieving documents. You can choose: |
| 63 | + - `REPLACE` (default): Overrides the initialization filters with the filters specified at runtime. |
| 64 | + Use this policy to dynamically change filtering for specific queries. |
| 65 | + - `MERGE`: Combines runtime filters with initialization filters to narrow down the search. |
59 | 66 | :raises ValueError:
|
60 | 67 | If the specified `top_k` is not > 0.
|
61 | 68 | """
|
@@ -131,13 +138,12 @@ def run(
|
131 | 138 | :param query:
|
132 | 139 | The query string for the Retriever.
|
133 | 140 | :param filters:
|
134 |
| - A dictionary with filters to narrow down the search space. |
| 141 | + A dictionary with filters to narrow down the search space when retrieving documents. |
135 | 142 | :param top_k:
|
136 | 143 | The maximum number of documents to return.
|
137 | 144 | :param scale_score:
|
138 |
| - Scales the BM25 score to a unit interval in the range of 0 to 1, where 1 means extremely relevant. |
139 |
| - If set to `False`, uses raw similarity scores. If not specified, the value provided at initialization |
140 |
| - is used. |
| 145 | + When `True`, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant. |
| 146 | + When `False`, uses raw similarity scores. |
141 | 147 | :returns:
|
142 | 148 | The retrieved documents.
|
143 | 149 |
|
|
0 commit comments