We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Change `MemoryEmbeddingRetriever` to non-batch mode


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `haystack/preview/components/retrievers/memory.py`
Content:
```
1 from typing import Dict, List, Any, Optional
2 
3 from haystack.preview import component, Document, default_to_dict, default_from_dict, DeserializationError
4 from haystack.preview.document_stores import MemoryDocumentStore, document_store
5 
6 
7 @component
8 class MemoryBM25Retriever:
9     """
10     A component for retrieving documents from a MemoryDocumentStore using the BM25 algorithm.
11 
12     Needs to be connected to a MemoryDocumentStore to run.
13     """
14 
15     def __init__(
16         self,
17         document_store: MemoryDocumentStore,
18         filters: Optional[Dict[str, Any]] = None,
19         top_k: int = 10,
20         scale_score: bool = True,
21     ):
22         """
23         Create a MemoryBM25Retriever component.
24 
25         :param document_store: An instance of MemoryDocumentStore.
26         :param filters: A dictionary with filters to narrow down the search space. Default is None.
27         :param top_k: The maximum number of documents to retrieve. Default is 10.
28         :param scale_score: Whether to scale the BM25 score or not. Default is True.
29 
30         :raises ValueError: If the specified top_k is not > 0.
31         """
32         if not isinstance(document_store, MemoryDocumentStore):
33             raise ValueError("document_store must be an instance of MemoryDocumentStore")
34 
35         self.document_store = document_store
36 
37         if top_k <= 0:
38             raise ValueError(f"top_k must be > 0, but got {top_k}")
39 
40         self.filters = filters
41         self.top_k = top_k
42         self.scale_score = scale_score
43 
44     def to_dict(self) -> Dict[str, Any]:
45         """
46         Serialize this component to a dictionary.
47         """
48         docstore = self.document_store.to_dict()
49         return default_to_dict(
50             self, document_store=docstore, filters=self.filters, top_k=self.top_k, scale_score=self.scale_score
51         )
52 
53     @classmethod
54     def from_dict(cls, data: Dict[str, Any]) -> "MemoryBM25Retriever":
55         """
56         Deserialize this component from a dictionary.
57         """
58         init_params = data.get("init_parameters", {})
59         if "document_store" not in init_params:
60             raise DeserializationError("Missing 'document_store' in serialization data")
61         if "type" not in init_params["document_store"]:
62             raise DeserializationError("Missing 'type' in document store's serialization data")
63         if init_params["document_store"]["type"] not in document_store.registry:
64             raise DeserializationError(f"DocumentStore type '{init_params['document_store']['type']}' not found")
65 
66         docstore_class = document_store.registry[init_params["document_store"]["type"]]
67         docstore = docstore_class.from_dict(init_params["document_store"])
68         data["init_parameters"]["document_store"] = docstore
69         return default_from_dict(cls, data)
70 
71     @component.output_types(documents=List[Document])
72     def run(
73         self,
74         query: str,
75         filters: Optional[Dict[str, Any]] = None,
76         top_k: Optional[int] = None,
77         scale_score: Optional[bool] = None,
78     ):
79         """
80         Run the MemoryBM25Retriever on the given input data.
81 
82         :param query: The query string for the retriever.
83         :param filters: A dictionary with filters to narrow down the search space.
84         :param top_k: The maximum number of documents to return.
85         :param scale_score: Whether to scale the BM25 scores or not.
86         :return: The retrieved documents.
87 
88         :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.
89         """
90         if filters is None:
91             filters = self.filters
92         if top_k is None:
93             top_k = self.top_k
94         if scale_score is None:
95             scale_score = self.scale_score
96 
97         docs = self.document_store.bm25_retrieval(query=query, filters=filters, top_k=top_k, scale_score=scale_score)
98         return {"documents": docs}
99 
100 
101 @component
102 class MemoryEmbeddingRetriever:
103     """
104     A component for retrieving documents from a MemoryDocumentStore using a vector similarity metric.
105 
106     Needs to be connected to a MemoryDocumentStore to run.
107     """
108 
109     def __init__(
110         self,
111         document_store: MemoryDocumentStore,
112         filters: Optional[Dict[str, Any]] = None,
113         top_k: int = 10,
114         scale_score: bool = True,
115         return_embedding: bool = False,
116     ):
117         """
118         Create a MemoryEmbeddingRetriever component.
119 
120         :param document_store: An instance of MemoryDocumentStore.
121         :param filters: A dictionary with filters to narrow down the search space. Default is None.
122         :param top_k: The maximum number of documents to retrieve. Default is 10.
123         :param scale_score: Whether to scale the scores of the retrieved documents or not. Default is True.
124         :param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.
125 
126         :raises ValueError: If the specified top_k is not > 0.
127         """
128         if not isinstance(document_store, MemoryDocumentStore):
129             raise ValueError("document_store must be an instance of MemoryDocumentStore")
130 
131         self.document_store = document_store
132 
133         if top_k <= 0:
134             raise ValueError(f"top_k must be > 0, but got {top_k}")
135 
136         self.filters = filters
137         self.top_k = top_k
138         self.scale_score = scale_score
139         self.return_embedding = return_embedding
140 
141     def to_dict(self) -> Dict[str, Any]:
142         """
143         Serialize this component to a dictionary.
144         """
145         docstore = self.document_store.to_dict()
146         return default_to_dict(
147             self,
148             document_store=docstore,
149             filters=self.filters,
150             top_k=self.top_k,
151             scale_score=self.scale_score,
152             return_embedding=self.return_embedding,
153         )
154 
155     @classmethod
156     def from_dict(cls, data: Dict[str, Any]) -> "MemoryBM25Retriever":
157         """
158         Deserialize this component from a dictionary.
159         """
160         init_params = data.get("init_parameters", {})
161         if "document_store" not in init_params:
162             raise DeserializationError("Missing 'document_store' in serialization data")
163         if "type" not in init_params["document_store"]:
164             raise DeserializationError("Missing 'type' in document store's serialization data")
165         if init_params["document_store"]["type"] not in document_store.registry:
166             raise DeserializationError(f"DocumentStore type '{init_params['document_store']['type']}' not found")
167 
168         docstore_class = document_store.registry[init_params["document_store"]["type"]]
169         docstore = docstore_class.from_dict(init_params["document_store"])
170         data["init_parameters"]["document_store"] = docstore
171         return default_from_dict(cls, data)
172 
173     @component.output_types(documents=List[List[Document]])
174     def run(
175         self,
176         queries_embeddings: List[List[float]],
177         filters: Optional[Dict[str, Any]] = None,
178         top_k: Optional[int] = None,
179         scale_score: Optional[bool] = None,
180         return_embedding: Optional[bool] = None,
181     ):
182         """
183         Run the MemoryEmbeddingRetriever on the given input data.
184 
185         :param queries_embeddings: Embeddings of the queries.
186         :param filters: A dictionary with filters to narrow down the search space.
187         :param top_k: The maximum number of documents to return.
188         :param scale_score: Whether to scale the scores of the retrieved documents or not.
189         :param return_embedding: Whether to return the embedding of the retrieved Documents.
190         :return: The retrieved documents.
191 
192         :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.
193         """
194         if filters is None:
195             filters = self.filters
196         if top_k is None:
197             top_k = self.top_k
198         if scale_score is None:
199             scale_score = self.scale_score
200         if return_embedding is None:
201             return_embedding = self.return_embedding
202 
203         docs = []
204         for query_embedding in queries_embeddings:
205             docs.append(
206                 self.document_store.embedding_retrieval(
207                     query_embedding=query_embedding,
208                     filters=filters,
209                     top_k=top_k,
210                     scale_score=scale_score,
211                     return_embedding=return_embedding,
212                 )
213             )
214         return {"documents": docs}
215
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/haystack/preview/components/retrievers/memory.py b/haystack/preview/components/retrievers/memory.py
--- a/haystack/preview/components/retrievers/memory.py
+++ b/haystack/preview/components/retrievers/memory.py
@@ -173,7 +173,7 @@
     @component.output_types(documents=List[List[Document]])
     def run(
         self,
-        queries_embeddings: List[List[float]],
+        query_embedding: List[float],
         filters: Optional[Dict[str, Any]] = None,
         top_k: Optional[int] = None,
         scale_score: Optional[bool] = None,
@@ -182,7 +182,7 @@
         """
         Run the MemoryEmbeddingRetriever on the given input data.
 
-        :param queries_embeddings: Embeddings of the queries.
+        :param query_embedding: Embedding of the query.
         :param filters: A dictionary with filters to narrow down the search space.
         :param top_k: The maximum number of documents to return.
         :param scale_score: Whether to scale the scores of the retrieved documents or not.
@@ -200,15 +200,12 @@
         if return_embedding is None:
             return_embedding = self.return_embedding
 
-        docs = []
-        for query_embedding in queries_embeddings:
-            docs.append(
-                self.document_store.embedding_retrieval(
-                    query_embedding=query_embedding,
-                    filters=filters,
-                    top_k=top_k,
-                    scale_score=scale_score,
-                    return_embedding=return_embedding,
-                )
-            )
+        docs = self.document_store.embedding_retrieval(
+            query_embedding=query_embedding,
+            filters=filters,
+            top_k=top_k,
+            scale_score=scale_score,
+            return_embedding=return_embedding,
+        )
+
         return {"documents": docs}

{"golden_diff": "diff --git a/haystack/preview/components/retrievers/memory.py b/haystack/preview/components/retrievers/memory.py\n--- a/haystack/preview/components/retrievers/memory.py\n+++ b/haystack/preview/components/retrievers/memory.py\n@@ -173,7 +173,7 @@\n     @component.output_types(documents=List[List[Document]])\n     def run(\n         self,\n-        queries_embeddings: List[List[float]],\n+        query_embedding: List[float],\n         filters: Optional[Dict[str, Any]] = None,\n         top_k: Optional[int] = None,\n         scale_score: Optional[bool] = None,\n@@ -182,7 +182,7 @@\n         \"\"\"\n         Run the MemoryEmbeddingRetriever on the given input data.\n \n-        :param queries_embeddings: Embeddings of the queries.\n+        :param query_embedding: Embedding of the query.\n         :param filters: A dictionary with filters to narrow down the search space.\n         :param top_k: The maximum number of documents to return.\n         :param scale_score: Whether to scale the scores of the retrieved documents or not.\n@@ -200,15 +200,12 @@\n         if return_embedding is None:\n             return_embedding = self.return_embedding\n \n-        docs = []\n-        for query_embedding in queries_embeddings:\n-            docs.append(\n-                self.document_store.embedding_retrieval(\n-                    query_embedding=query_embedding,\n-                    filters=filters,\n-                    top_k=top_k,\n-                    scale_score=scale_score,\n-                    return_embedding=return_embedding,\n-                )\n-            )\n+        docs = self.document_store.embedding_retrieval(\n+            query_embedding=query_embedding,\n+            filters=filters,\n+            top_k=top_k,\n+            scale_score=scale_score,\n+            return_embedding=return_embedding,\n+        )\n+\n         return {\"documents\": docs}\n", "issue": "Change `MemoryEmbeddingRetriever` to non-batch mode\n\n", "before_files": [{"content": "from typing import Dict, List, Any, Optional\n\nfrom haystack.preview import component, Document, default_to_dict, default_from_dict, DeserializationError\nfrom haystack.preview.document_stores import MemoryDocumentStore, document_store\n\n\n@component\nclass MemoryBM25Retriever:\n    \"\"\"\n    A component for retrieving documents from a MemoryDocumentStore using the BM25 algorithm.\n\n    Needs to be connected to a MemoryDocumentStore to run.\n    \"\"\"\n\n    def __init__(\n        self,\n        document_store: MemoryDocumentStore,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: int = 10,\n        scale_score: bool = True,\n    ):\n        \"\"\"\n        Create a MemoryBM25Retriever component.\n\n        :param document_store: An instance of MemoryDocumentStore.\n        :param filters: A dictionary with filters to narrow down the search space. Default is None.\n        :param top_k: The maximum number of documents to retrieve. Default is 10.\n        :param scale_score: Whether to scale the BM25 score or not. Default is True.\n\n        :raises ValueError: If the specified top_k is not > 0.\n        \"\"\"\n        if not isinstance(document_store, MemoryDocumentStore):\n            raise ValueError(\"document_store must be an instance of MemoryDocumentStore\")\n\n        self.document_store = document_store\n\n        if top_k <= 0:\n            raise ValueError(f\"top_k must be > 0, but got {top_k}\")\n\n        self.filters = filters\n        self.top_k = top_k\n        self.scale_score = scale_score\n\n    def to_dict(self) -> Dict[str, Any]:\n        \"\"\"\n        Serialize this component to a dictionary.\n        \"\"\"\n        docstore = self.document_store.to_dict()\n        return default_to_dict(\n            self, document_store=docstore, filters=self.filters, top_k=self.top_k, scale_score=self.scale_score\n        )\n\n    @classmethod\n    def from_dict(cls, data: Dict[str, Any]) -> \"MemoryBM25Retriever\":\n        \"\"\"\n        Deserialize this component from a dictionary.\n        \"\"\"\n        init_params = data.get(\"init_parameters\", {})\n        if \"document_store\" not in init_params:\n            raise DeserializationError(\"Missing 'document_store' in serialization data\")\n        if \"type\" not in init_params[\"document_store\"]:\n            raise DeserializationError(\"Missing 'type' in document store's serialization data\")\n        if init_params[\"document_store\"][\"type\"] not in document_store.registry:\n            raise DeserializationError(f\"DocumentStore type '{init_params['document_store']['type']}' not found\")\n\n        docstore_class = document_store.registry[init_params[\"document_store\"][\"type\"]]\n        docstore = docstore_class.from_dict(init_params[\"document_store\"])\n        data[\"init_parameters\"][\"document_store\"] = docstore\n        return default_from_dict(cls, data)\n\n    @component.output_types(documents=List[Document])\n    def run(\n        self,\n        query: str,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: Optional[int] = None,\n        scale_score: Optional[bool] = None,\n    ):\n        \"\"\"\n        Run the MemoryBM25Retriever on the given input data.\n\n        :param query: The query string for the retriever.\n        :param filters: A dictionary with filters to narrow down the search space.\n        :param top_k: The maximum number of documents to return.\n        :param scale_score: Whether to scale the BM25 scores or not.\n        :return: The retrieved documents.\n\n        :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.\n        \"\"\"\n        if filters is None:\n            filters = self.filters\n        if top_k is None:\n            top_k = self.top_k\n        if scale_score is None:\n            scale_score = self.scale_score\n\n        docs = self.document_store.bm25_retrieval(query=query, filters=filters, top_k=top_k, scale_score=scale_score)\n        return {\"documents\": docs}\n\n\n@component\nclass MemoryEmbeddingRetriever:\n    \"\"\"\n    A component for retrieving documents from a MemoryDocumentStore using a vector similarity metric.\n\n    Needs to be connected to a MemoryDocumentStore to run.\n    \"\"\"\n\n    def __init__(\n        self,\n        document_store: MemoryDocumentStore,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: int = 10,\n        scale_score: bool = True,\n        return_embedding: bool = False,\n    ):\n        \"\"\"\n        Create a MemoryEmbeddingRetriever component.\n\n        :param document_store: An instance of MemoryDocumentStore.\n        :param filters: A dictionary with filters to narrow down the search space. Default is None.\n        :param top_k: The maximum number of documents to retrieve. Default is 10.\n        :param scale_score: Whether to scale the scores of the retrieved documents or not. Default is True.\n        :param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.\n\n        :raises ValueError: If the specified top_k is not > 0.\n        \"\"\"\n        if not isinstance(document_store, MemoryDocumentStore):\n            raise ValueError(\"document_store must be an instance of MemoryDocumentStore\")\n\n        self.document_store = document_store\n\n        if top_k <= 0:\n            raise ValueError(f\"top_k must be > 0, but got {top_k}\")\n\n        self.filters = filters\n        self.top_k = top_k\n        self.scale_score = scale_score\n        self.return_embedding = return_embedding\n\n    def to_dict(self) -> Dict[str, Any]:\n        \"\"\"\n        Serialize this component to a dictionary.\n        \"\"\"\n        docstore = self.document_store.to_dict()\n        return default_to_dict(\n            self,\n            document_store=docstore,\n            filters=self.filters,\n            top_k=self.top_k,\n            scale_score=self.scale_score,\n            return_embedding=self.return_embedding,\n        )\n\n    @classmethod\n    def from_dict(cls, data: Dict[str, Any]) -> \"MemoryBM25Retriever\":\n        \"\"\"\n        Deserialize this component from a dictionary.\n        \"\"\"\n        init_params = data.get(\"init_parameters\", {})\n        if \"document_store\" not in init_params:\n            raise DeserializationError(\"Missing 'document_store' in serialization data\")\n        if \"type\" not in init_params[\"document_store\"]:\n            raise DeserializationError(\"Missing 'type' in document store's serialization data\")\n        if init_params[\"document_store\"][\"type\"] not in document_store.registry:\n            raise DeserializationError(f\"DocumentStore type '{init_params['document_store']['type']}' not found\")\n\n        docstore_class = document_store.registry[init_params[\"document_store\"][\"type\"]]\n        docstore = docstore_class.from_dict(init_params[\"document_store\"])\n        data[\"init_parameters\"][\"document_store\"] = docstore\n        return default_from_dict(cls, data)\n\n    @component.output_types(documents=List[List[Document]])\n    def run(\n        self,\n        queries_embeddings: List[List[float]],\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: Optional[int] = None,\n        scale_score: Optional[bool] = None,\n        return_embedding: Optional[bool] = None,\n    ):\n        \"\"\"\n        Run the MemoryEmbeddingRetriever on the given input data.\n\n        :param queries_embeddings: Embeddings of the queries.\n        :param filters: A dictionary with filters to narrow down the search space.\n        :param top_k: The maximum number of documents to return.\n        :param scale_score: Whether to scale the scores of the retrieved documents or not.\n        :param return_embedding: Whether to return the embedding of the retrieved Documents.\n        :return: The retrieved documents.\n\n        :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.\n        \"\"\"\n        if filters is None:\n            filters = self.filters\n        if top_k is None:\n            top_k = self.top_k\n        if scale_score is None:\n            scale_score = self.scale_score\n        if return_embedding is None:\n            return_embedding = self.return_embedding\n\n        docs = []\n        for query_embedding in queries_embeddings:\n            docs.append(\n                self.document_store.embedding_retrieval(\n                    query_embedding=query_embedding,\n                    filters=filters,\n                    top_k=top_k,\n                    scale_score=scale_score,\n                    return_embedding=return_embedding,\n                )\n            )\n        return {\"documents\": docs}\n", "path": "haystack/preview/components/retrievers/memory.py"}], "after_files": [{"content": "from typing import Dict, List, Any, Optional\n\nfrom haystack.preview import component, Document, default_to_dict, default_from_dict, DeserializationError\nfrom haystack.preview.document_stores import MemoryDocumentStore, document_store\n\n\n@component\nclass MemoryBM25Retriever:\n    \"\"\"\n    A component for retrieving documents from a MemoryDocumentStore using the BM25 algorithm.\n\n    Needs to be connected to a MemoryDocumentStore to run.\n    \"\"\"\n\n    def __init__(\n        self,\n        document_store: MemoryDocumentStore,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: int = 10,\n        scale_score: bool = True,\n    ):\n        \"\"\"\n        Create a MemoryBM25Retriever component.\n\n        :param document_store: An instance of MemoryDocumentStore.\n        :param filters: A dictionary with filters to narrow down the search space. Default is None.\n        :param top_k: The maximum number of documents to retrieve. Default is 10.\n        :param scale_score: Whether to scale the BM25 score or not. Default is True.\n\n        :raises ValueError: If the specified top_k is not > 0.\n        \"\"\"\n        if not isinstance(document_store, MemoryDocumentStore):\n            raise ValueError(\"document_store must be an instance of MemoryDocumentStore\")\n\n        self.document_store = document_store\n\n        if top_k <= 0:\n            raise ValueError(f\"top_k must be > 0, but got {top_k}\")\n\n        self.filters = filters\n        self.top_k = top_k\n        self.scale_score = scale_score\n\n    def to_dict(self) -> Dict[str, Any]:\n        \"\"\"\n        Serialize this component to a dictionary.\n        \"\"\"\n        docstore = self.document_store.to_dict()\n        return default_to_dict(\n            self, document_store=docstore, filters=self.filters, top_k=self.top_k, scale_score=self.scale_score\n        )\n\n    @classmethod\n    def from_dict(cls, data: Dict[str, Any]) -> \"MemoryBM25Retriever\":\n        \"\"\"\n        Deserialize this component from a dictionary.\n        \"\"\"\n        init_params = data.get(\"init_parameters\", {})\n        if \"document_store\" not in init_params:\n            raise DeserializationError(\"Missing 'document_store' in serialization data\")\n        if \"type\" not in init_params[\"document_store\"]:\n            raise DeserializationError(\"Missing 'type' in document store's serialization data\")\n        if init_params[\"document_store\"][\"type\"] not in document_store.registry:\n            raise DeserializationError(f\"DocumentStore type '{init_params['document_store']['type']}' not found\")\n\n        docstore_class = document_store.registry[init_params[\"document_store\"][\"type\"]]\n        docstore = docstore_class.from_dict(init_params[\"document_store\"])\n        data[\"init_parameters\"][\"document_store\"] = docstore\n        return default_from_dict(cls, data)\n\n    @component.output_types(documents=List[Document])\n    def run(\n        self,\n        query: str,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: Optional[int] = None,\n        scale_score: Optional[bool] = None,\n    ):\n        \"\"\"\n        Run the MemoryBM25Retriever on the given input data.\n\n        :param query: The query string for the retriever.\n        :param filters: A dictionary with filters to narrow down the search space.\n        :param top_k: The maximum number of documents to return.\n        :param scale_score: Whether to scale the BM25 scores or not.\n        :return: The retrieved documents.\n\n        :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.\n        \"\"\"\n        if filters is None:\n            filters = self.filters\n        if top_k is None:\n            top_k = self.top_k\n        if scale_score is None:\n            scale_score = self.scale_score\n\n        docs = self.document_store.bm25_retrieval(query=query, filters=filters, top_k=top_k, scale_score=scale_score)\n        return {\"documents\": docs}\n\n\n@component\nclass MemoryEmbeddingRetriever:\n    \"\"\"\n    A component for retrieving documents from a MemoryDocumentStore using a vector similarity metric.\n\n    Needs to be connected to a MemoryDocumentStore to run.\n    \"\"\"\n\n    def __init__(\n        self,\n        document_store: MemoryDocumentStore,\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: int = 10,\n        scale_score: bool = True,\n        return_embedding: bool = False,\n    ):\n        \"\"\"\n        Create a MemoryEmbeddingRetriever component.\n\n        :param document_store: An instance of MemoryDocumentStore.\n        :param filters: A dictionary with filters to narrow down the search space. Default is None.\n        :param top_k: The maximum number of documents to retrieve. Default is 10.\n        :param scale_score: Whether to scale the scores of the retrieved documents or not. Default is True.\n        :param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.\n\n        :raises ValueError: If the specified top_k is not > 0.\n        \"\"\"\n        if not isinstance(document_store, MemoryDocumentStore):\n            raise ValueError(\"document_store must be an instance of MemoryDocumentStore\")\n\n        self.document_store = document_store\n\n        if top_k <= 0:\n            raise ValueError(f\"top_k must be > 0, but got {top_k}\")\n\n        self.filters = filters\n        self.top_k = top_k\n        self.scale_score = scale_score\n        self.return_embedding = return_embedding\n\n    def to_dict(self) -> Dict[str, Any]:\n        \"\"\"\n        Serialize this component to a dictionary.\n        \"\"\"\n        docstore = self.document_store.to_dict()\n        return default_to_dict(\n            self,\n            document_store=docstore,\n            filters=self.filters,\n            top_k=self.top_k,\n            scale_score=self.scale_score,\n            return_embedding=self.return_embedding,\n        )\n\n    @classmethod\n    def from_dict(cls, data: Dict[str, Any]) -> \"MemoryBM25Retriever\":\n        \"\"\"\n        Deserialize this component from a dictionary.\n        \"\"\"\n        init_params = data.get(\"init_parameters\", {})\n        if \"document_store\" not in init_params:\n            raise DeserializationError(\"Missing 'document_store' in serialization data\")\n        if \"type\" not in init_params[\"document_store\"]:\n            raise DeserializationError(\"Missing 'type' in document store's serialization data\")\n        if init_params[\"document_store\"][\"type\"] not in document_store.registry:\n            raise DeserializationError(f\"DocumentStore type '{init_params['document_store']['type']}' not found\")\n\n        docstore_class = document_store.registry[init_params[\"document_store\"][\"type\"]]\n        docstore = docstore_class.from_dict(init_params[\"document_store\"])\n        data[\"init_parameters\"][\"document_store\"] = docstore\n        return default_from_dict(cls, data)\n\n    @component.output_types(documents=List[List[Document]])\n    def run(\n        self,\n        query_embedding: List[float],\n        filters: Optional[Dict[str, Any]] = None,\n        top_k: Optional[int] = None,\n        scale_score: Optional[bool] = None,\n        return_embedding: Optional[bool] = None,\n    ):\n        \"\"\"\n        Run the MemoryEmbeddingRetriever on the given input data.\n\n        :param query_embedding: Embedding of the query.\n        :param filters: A dictionary with filters to narrow down the search space.\n        :param top_k: The maximum number of documents to return.\n        :param scale_score: Whether to scale the scores of the retrieved documents or not.\n        :param return_embedding: Whether to return the embedding of the retrieved Documents.\n        :return: The retrieved documents.\n\n        :raises ValueError: If the specified DocumentStore is not found or is not a MemoryDocumentStore instance.\n        \"\"\"\n        if filters is None:\n            filters = self.filters\n        if top_k is None:\n            top_k = self.top_k\n        if scale_score is None:\n            scale_score = self.scale_score\n        if return_embedding is None:\n            return_embedding = self.return_embedding\n\n        docs = self.document_store.embedding_retrieval(\n            query_embedding=query_embedding,\n            filters=filters,\n            top_k=top_k,\n            scale_score=scale_score,\n            return_embedding=return_embedding,\n        )\n\n        return {\"documents\": docs}\n", "path": "haystack/preview/components/retrievers/memory.py"}]}