Repository: deepset-ai/haystack

Issue:
`MetaFieldRanker` - the `weight` parameter passed in the `run` method is not taken into account
**Describe the bug**
When passing the `weight` in the `run` method, it is not taken into account.
Only `self.weight` (defined during initialization) is used.

**To Reproduce**
```python
from haystack import Document
from haystack.components.rankers import MetaFieldRanker

ranker = MetaFieldRanker(meta_field="rating", weight=0) # weight=0 disables ranking by a meta field.
docs = [
    Document(content="Paris", meta={"rating": 1}),
    Document(content="Berlin", meta={"rating": 0.5}),
    Document(content="Barcelona", meta={"rating": 5}),
]

output = ranker.run(documents=docs, weight=1) # weight=1 means ranking by a meta field only

print(output)
# we get Documents with the original order, weight=1 is not taken into account
```

**System:**
 - Haystack version (commit or version number): 2.0-beta8


Discussion:

Patch:
diff --git a/haystack/components/rankers/meta_field.py b/haystack/components/rankers/meta_field.py
index 2ce4876c..aa62ebf5 100644
--- a/haystack/components/rankers/meta_field.py
+++ b/haystack/components/rankers/meta_field.py
@@ -3,7 +3,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional
 
 from dateutil.parser import parse as date_parse
 
-from haystack import Document, component, default_to_dict, logging
+from haystack import Document, component, logging
 
 logger = logging.getLogger(__name__)
 
@@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
 class MetaFieldRanker:
     """
     Ranks Documents based on the value of their specific meta field.
+
     The ranking can be performed in descending order or ascending order.
 
     Usage example:
@@ -43,27 +44,33 @@ class MetaFieldRanker:
         """
         Creates an instance of MetaFieldRanker.
 
-        :param meta_field: The name of the meta field to rank by.
-        :param weight: In range [0,1].
-                0 disables ranking by a meta field.
-                0.5 content and meta fields have the same impact for the ranking.
-                1 means ranking by a meta field only. The highest value comes first.
-        :param top_k: The maximum number of Documents you want the Ranker to return per query. If not provided, the
-                Ranker returns all documents it receives in the new ranking order.
-        :param ranking_mode: The mode used to combine the Retriever's and Ranker's scores.
-                Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
-                Use the 'score' mode only with Retrievers or Rankers that return a score in range [0,1].
-        :param sort_order: Whether to sort the meta field by ascending or descending order.
-                Possible values are `descending` (default) and `ascending`.
-        :param meta_value_type: Parse the meta value into the data type specified before sorting.
-                This will only work if all meta values stored under `meta_field` in the provided documents are strings.
-                For example, if we specified `meta_value_type="date"` then for the meta value `"date": "2015-02-01"`
-                we would parse the string into a datetime object and then sort the documents by date.
-                The available options are:
-                -'float' will parse the meta values into floats.
-                -'int' will parse the meta values into integers.
-                -'date' will parse the meta values into datetime objects.
-                -'None' (default) will do no parsing.
+        :param meta_field:
+            The name of the meta field to rank by.
+        :param weight:
+            In range [0,1].
+            0 disables ranking by a meta field.
+            0.5 ranking from previous component and based on meta field have the same weight.
+            1 ranking by a meta field only.
+        :param top_k:
+            The maximum number of Documents to return per query.
+            If not provided, the Ranker returns all documents it receives in the new ranking order.
+        :param ranking_mode:
+            The mode used to combine the Retriever's and Ranker's scores.
+            Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
+            Use the 'linear_score' mode only with Retrievers or Rankers that return a score in range [0,1].
+        :param sort_order:
+            Whether to sort the meta field by ascending or descending order.
+            Possible values are `descending` (default) and `ascending`.
+        :param meta_value_type:
+            Parse the meta value into the data type specified before sorting.
+            This will only work if all meta values stored under `meta_field` in the provided documents are strings.
+            For example, if we specified `meta_value_type="date"` then for the meta value `"date": "2015-02-01"`
+            we would parse the string into a datetime object and then sort the documents by date.
+            The available options are:
+            - 'float' will parse the meta values into floats.
+            - 'int' will parse the meta values into integers.
+            - 'date' will parse the meta values into datetime objects.
+            - 'None' (default) will do no parsing.
         """
 
         self.meta_field = meta_field
@@ -96,7 +103,7 @@ class MetaFieldRanker:
                 "Parameter <weight> must be in range [0,1] but is currently set to '%s'.\n'0' disables sorting by a "
                 "meta field, '0.5' assigns equal weight to the previous relevance scores and the meta field, and "
                 "'1' ranks by the meta field only.\nChange the <weight> parameter to a value in range 0 to 1 when "
-                "initializing the MetaFieldRanker." % self.weight
+                "initializing the MetaFieldRanker." % weight
             )
 
         if ranking_mode not in ["reciprocal_rank_fusion", "linear_score"]:
@@ -108,7 +115,8 @@ class MetaFieldRanker:
 
         if sort_order not in ["ascending", "descending"]:
             raise ValueError(
-                "The value of parameter <sort_order> must be 'ascending' or 'descending', but is currently set to '%s'.\n"
+                "The value of parameter <sort_order> must be 'ascending' or 'descending', "
+                "but is currently set to '%s'.\n"
                 "Change the <sort_order> value to 'ascending' or 'descending' when initializing the "
                 "MetaFieldRanker." % sort_order
             )
@@ -121,20 +129,6 @@ class MetaFieldRanker:
                 "MetaFieldRanker." % meta_value_type
             )
 
-    def to_dict(self) -> Dict[str, Any]:
-        """
-        Serialize object to a dictionary.
-        """
-        return default_to_dict(
-            self,
-            meta_field=self.meta_field,
-            weight=self.weight,
-            top_k=self.top_k,
-            ranking_mode=self.ranking_mode,
-            sort_order=self.sort_order,
-            meta_value_type=self.meta_value_type,
-        )
-
     @component.output_types(documents=List[Document])
     def run(
         self,
@@ -146,35 +140,52 @@ class MetaFieldRanker:
         meta_value_type: Optional[Literal["float", "int", "date"]] = None,
     ):
         """
-        Use this method to rank a list of Documents based on the selected meta field by:
+        Ranks a list of Documents based on the selected meta field by:
         1. Sorting the Documents by the meta field in descending or ascending order.
-        2. Merging the scores from the meta field with the scores from the previous component according to the strategy and weight provided.
+        2. Merging the rankings from the previous component and based on the meta field according to ranking mode and
+        weight.
         3. Returning the top-k documents.
 
-        :param documents: Documents to be ranked.
-        :param top_k: (optional) The number of Documents you want the Ranker to return.
-                If not provided, the top_k provided at initialization time is used.
-        :param weight: (optional) In range [0,1].
-                0 disables ranking by a meta field.
-                0.5 content and meta fields have the same impact for the ranking.
-                1 means ranking by a meta field only. The highest value comes first.
-                If not provided, the weight provided at initialization time is used.
-        :param ranking_mode: (optional) The mode used to combine the Retriever's and Ranker's scores.
-                Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
-                Use the 'score' mode only with Retrievers or Rankers that return a score in range [0,1].
-                If not provided, the ranking_mode provided at initialization time is used.
-        :param sort_order: Whether to sort the meta field by ascending or descending order.
-                Possible values are `descending` (default) and `ascending`.
-                If not provided, the sort_order provided at initialization time is used.
-        :param meta_value_type: Parse the meta value into the data type specified before sorting.
-                This will only work if all meta values stored under `meta_field` in the provided documents are strings.
-                For example, if we specified `meta_value_type="date"` then for the meta value `"date": "2015-02-01"`
-                we would parse the string into a datetime object and then sort the documents by date.
-                The available options are:
-                -'float' will parse the meta values into floats.
-                -'int' will parse the meta values into integers.
-                -'date' will parse the meta values into datetime objects.
-                -'None' (default) will do no parsing.
+        :param documents:
+            Documents to be ranked.
+        :param top_k:
+            The maximum number of Documents to return per query.
+            If not provided, the top_k provided at initialization time is used.
+        :param weight:
+            In range [0,1].
+            0 disables ranking by a meta field.
+            0.5 ranking from previous component and based on meta field have the same weight.
+            1 ranking by a meta field only.
+            If not provided, the weight provided at initialization time is used.
+        :param ranking_mode:
+            (optional) The mode used to combine the Retriever's and Ranker's scores.
+            Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
+            Use the 'score' mode only with Retrievers or Rankers that return a score in range [0,1].
+            If not provided, the ranking_mode provided at initialization time is used.
+        :param sort_order:
+            Whether to sort the meta field by ascending or descending order.
+            Possible values are `descending` (default) and `ascending`.
+            If not provided, the sort_order provided at initialization time is used.
+        :param meta_value_type:
+            Parse the meta value into the data type specified before sorting.
+            This will only work if all meta values stored under `meta_field` in the provided documents are strings.
+            For example, if we specified `meta_value_type="date"` then for the meta value `"date": "2015-02-01"`
+            we would parse the string into a datetime object and then sort the documents by date.
+            The available options are:
+            -'float' will parse the meta values into floats.
+            -'int' will parse the meta values into integers.
+            -'date' will parse the meta values into datetime objects.
+            -'None' (default) will do no parsing.
+        :returns:
+            A dictionary with the following keys:
+            - `documents`: List of Documents sorted by the specified meta field.
+
+        :raises ValueError:
+            If `top_k` is not > 0.
+            If `weight` is not in range [0,1].
+            If `ranking_mode` is not 'reciprocal_rank_fusion' or 'linear_score'.
+            If `sort_order` is not 'ascending' or 'descending'.
+            If `meta_value_type` is not 'float', 'int', 'date' or `None`.
         """
         if not documents:
             return {"documents": []}
@@ -239,7 +250,7 @@ class MetaFieldRanker:
         # Add the docs missing the meta_field back on the end
         sorted_by_meta = [doc for meta, doc in tuple_sorted_by_meta]
         sorted_documents = sorted_by_meta + docs_missing_meta_field
-        sorted_documents = self._merge_rankings(documents, sorted_documents)
+        sorted_documents = self._merge_rankings(documents, sorted_documents, weight)
         return {"documents": sorted_documents[:top_k]}
 
     def _parse_meta(
@@ -284,7 +295,9 @@ class MetaFieldRanker:
 
         return meta_values
 
-    def _merge_rankings(self, documents: List[Document], sorted_documents: List[Document]) -> List[Document]:
+    def _merge_rankings(
+        self, documents: List[Document], sorted_documents: List[Document], weight: float
+    ) -> List[Document]:
         """
         Merge the two different rankings for Documents sorted both by their content and by their meta field.
         """
@@ -292,8 +305,8 @@ class MetaFieldRanker:
 
         if self.ranking_mode == "reciprocal_rank_fusion":
             for i, (document, sorted_doc) in enumerate(zip(documents, sorted_documents)):
-                scores_map[document.id] += self._calculate_rrf(rank=i) * (1 - self.weight)
-                scores_map[sorted_doc.id] += self._calculate_rrf(rank=i) * self.weight
+                scores_map[document.id] += self._calculate_rrf(rank=i) * (1 - weight)
+                scores_map[sorted_doc.id] += self._calculate_rrf(rank=i) * weight
         elif self.ranking_mode == "linear_score":
             for i, (document, sorted_doc) in enumerate(zip(documents, sorted_documents)):
                 score = float(0)
@@ -308,8 +321,8 @@ class MetaFieldRanker:
                 else:
                     score = document.score
 
-                scores_map[document.id] += score * (1 - self.weight)
-                scores_map[sorted_doc.id] += self._calc_linear_score(rank=i, amount=len(sorted_documents)) * self.weight
+                scores_map[document.id] += score * (1 - weight)
+                scores_map[sorted_doc.id] += self._calc_linear_score(rank=i, amount=len(sorted_documents)) * weight
 
         for document in documents:
             document.score = scores_map[document.id]
@@ -330,8 +343,8 @@ class MetaFieldRanker:
         """
         Calculate the meta field score as a linear score between the greatest and the lowest score in the list.
         This linear scaling is useful for:
-          - Reducing the effect of outliers
-          - Creating scores that are meaningfully distributed in the range [0,1],
-             similar to scores coming from a Retriever or Ranker.
+        - Reducing the effect of outliers
+        - Creating scores that are meaningfully distributed in the range [0,1],
+        similar to scores coming from a Retriever or Ranker.
         """
         return (amount - rank) / amount
diff --git a/haystack/components/rankers/transformers_similarity.py b/haystack/components/rankers/transformers_similarity.py
index f69a1af8..af26fc8b 100644
--- a/haystack/components/rankers/transformers_similarity.py
+++ b/haystack/components/rankers/transformers_similarity.py
@@ -19,20 +19,21 @@ with LazyImport(message="Run 'pip install transformers[torch,sentencepiece]'") a
 class TransformersSimilarityRanker:
     """
     Ranks Documents based on their similarity to the query.
+
     It uses a pre-trained cross-encoder model (from the Hugging Face Hub) to embed the query and the Documents.
 
     Usage example:
-    ```
+    ```python
     from haystack import Document
     from haystack.components.rankers import TransformersSimilarityRanker
 
     ranker = TransformersSimilarityRanker()
     docs = [Document(content="Paris"), Document(content="Berlin")]
     query = "City in Germany"
-    output = ranker.run(query=query, documents=docs)
-    docs = output["documents"]
-    assert len(docs) == 2
-    assert docs[0].content == "Berlin"
+    ranker.warm_up()
+    result = ranker.run(query=query, documents=docs)
+    docs = result["documents"]
+    print(docs[0].content)
     ```
     """
 
@@ -54,30 +55,39 @@ class TransformersSimilarityRanker:
         """
         Creates an instance of TransformersSimilarityRanker.
 
-        :param model: The name or path of a pre-trained cross-encoder model
-            from the Hugging Face Hub.
-        :param device: The device on which the model is loaded. If `None`, the default device is automatically
-            selected.
-        :param token: The API token used to download private models from Hugging Face.
-            If this parameter is set to `True`, the token generated when running
-            `transformers-cli login` (stored in ~/.huggingface) is used.
-        :param top_k: The maximum number of Documents to return per query.
-        :param query_prefix: A string to add to the beginning of the query text before ranking.
-            Can be used to prepend the text with an instruction, as required by some reranking models,
-            such as bge.
-        :param document_prefix: A string to add to the beginning of each Document text before ranking.
-            Can be used to prepend the text with an instruction, as required by some embedding models,
-            such as bge.
-        :param meta_fields_to_embed: List of meta fields that should be embedded along with the Document content.
-        :param embedding_separator: Separator used to concatenate the meta fields to the Document content.
-        :param scale_score: Whether the raw logit predictions will be scaled using a Sigmoid activation function.
+        :param model:
+            The name or path of a pre-trained cross-encoder model from the Hugging Face Hub.
+        :param device:
+            The device on which the model is loaded. If `None`, the default device is automatically selected.
+        :param token:
+            The API token used to download private models from Hugging Face.
+        :param top_k:
+            The maximum number of Documents to return per query.
+        :param query_prefix:
+            A string to add to the beginning of the query text before ranking.
+            Can be used to prepend the text with an instruction, as required by some reranking models, such as bge.
+        :param document_prefix:
+            A string to add to the beginning of each Document text before ranking. Can be used to prepend the text with
+            an instruction, as required by some embedding models, such as bge.
+        :param meta_fields_to_embed:
+            List of meta fields that should be embedded along with the Document content.
+        :param embedding_separator:
+            Separator used to concatenate the meta fields to the Document content.
+        :param scale_score:
+            Whether the raw logit predictions will be scaled using a Sigmoid activation function.
             Set this to False if you do not want any scaling of the raw logit predictions.
-        :param calibration_factor: Factor used for calibrating probabilities calculated by
-            `sigmoid(logits * calibration_factor)`. This is only used if `scale_score` is set to True.
-        :param score_threshold: If provided only returns documents with a score above this threshold.
+        :param calibration_factor:
+            Factor used for calibrating probabilities calculated by `sigmoid(logits * calibration_factor)`.
+            This is only used if `scale_score` is set to True.
+        :param score_threshold:
+            If provided only returns documents with a score above this threshold.
         :param model_kwargs: Additional keyword arguments passed to `AutoModelForSequenceClassification.from_pretrained`
             when loading the model specified in `model`. For details on what kwargs you can pass,
             see the model's documentation.
+
+        :raises ValueError:
+            If `top_k` is not > 0.
+            If `scale_score` is True and `calibration_factor` is not provided.
         """
         torch_and_transformers_import.check()
 
@@ -115,7 +125,7 @@ class TransformersSimilarityRanker:
 
     def warm_up(self):
         """
-        Warm up the model and tokenizer used for scoring the Documents.
+        Initializes the component.
         """
         if self.model is None:
             self.model = AutoModelForSequenceClassification.from_pretrained(
@@ -128,7 +138,10 @@ class TransformersSimilarityRanker:
 
     def to_dict(self) -> Dict[str, Any]:
         """
-        Serialize this component to a dictionary.
+        Serializes the component to a dictionary.
+
+        :returns:
+            Dictionary with serialized data.
         """
         serialization_dict = default_to_dict(
             self,
@@ -152,7 +165,12 @@ class TransformersSimilarityRanker:
     @classmethod
     def from_dict(cls, data: Dict[str, Any]) -> "TransformersSimilarityRanker":
         """
-        Deserialize this component from a dictionary.
+        Deserializes the component from a dictionary.
+
+        :param data:
+            Dictionary to deserialize from.
+        :returns:
+            Deserialized component.
         """
         deserialize_secrets_inplace(data["init_parameters"], keys=["token"])
         init_params = data["init_parameters"]
@@ -175,15 +193,29 @@ class TransformersSimilarityRanker:
         """
         Returns a list of Documents ranked by their similarity to the given query.
 
-        :param query: Query string.
-        :param documents: List of Documents.
-        :param top_k: The maximum number of Documents you want the Ranker to return.
-        :param scale_score: Whether the raw logit predictions will be scaled using a Sigmoid activation function.
+        :param query:
+            Query string.
+        :param documents:
+            List of Documents.
+        :param top_k:
+            The maximum number of Documents you want the Ranker to return.
+        :param scale_score:
+            Whether the raw logit predictions will be scaled using a Sigmoid activation function.
             Set this to False if you do not want any scaling of the raw logit predictions.
-        :param calibration_factor: Factor used for calibrating probabilities calculated by
+        :param calibration_factor:
+            Factor used for calibrating probabilities calculated by
             `sigmoid(logits * calibration_factor)`. This is only used if `scale_score` is set to True.
-        :param score_threshold: If provided only returns documents with a score above this threshold.
-        :return: List of Documents sorted by their similarity to the query with the most similar Documents appearing first.
+        :param score_threshold:
+            If provided only returns documents with a score above this threshold.
+        :returns:
+            A dictionary with the following keys:
+            - `documents`: List of Documents most similar to the given query in descending order of similarity.
+
+        :raises ValueError:
+            If `top_k` is not > 0.
+            If `scale_score` is True and `calibration_factor` is not provided.
+        :raises ComponentError:
+            If the model is not loaded because `warm_up()` was not called before.
         """
         if not documents:
             return {"documents": []}
diff --git a/haystack/components/readers/extractive.py b/haystack/components/readers/extractive.py
index 724c6b81..37c29577 100644
--- a/haystack/components/readers/extractive.py
+++ b/haystack/components/readers/extractive.py
@@ -21,19 +21,29 @@ logger = logging.getLogger(__name__)
 @component
 class ExtractiveReader:
     """
-    A component that locates and extract answers to a given query from Documents. It's used for performing extractive
-    QA. The Reader assigns a score to every possible answer span independently of other answer spans.
+    Locates and extracts answers to a given query from Documents.
+
+    The ExtractiveReader component performs extractive question answering.
+    It assigns a score to every possible answer span independently of other answer spans.
     This fixes a common issue of other implementations which make comparisons across documents harder by normalizing
     each document's answers independently.
 
     Example usage:
     ```python
-    p = Pipeline()
-    p.add_component(instance=InMemoryBM25Retriever(document_store=InMemoryDocumentStore()), name="retriever")
-    p.add_component(instance=ExtractiveReader(), name="reader")
-    p.connect("retriever", "reader")
-    question = "Who lives in Berlin?"
-    p.run({"retriever": {"query": question}, "reader": {"query": question}})
+    from haystack import Document
+    from haystack.components.readers import ExtractiveReader
+
+    docs = [
+        Document(content="Python is a popular programming language"),
+        Document(content="python ist eine beliebte Programmiersprache"),
+    ]
+
+    reader = ExtractiveReader()
+    reader.warm_up()
+
+    question = "What is a popular programming language?"
+    result = reader.run(query=question, documents=docs)
+    assert "Python" in result["answers"][0].data
     ```
     """
 
@@ -54,37 +64,43 @@ class ExtractiveReader:
         model_kwargs: Optional[Dict[str, Any]] = None,
     ) -> None:
         """
-        Creates an ExtractiveReader
-        :param model: A Hugging Face transformers question answering model.
+        Creates an instance of ExtractiveReader.
+
+        :param model:
+            A Hugging Face transformers question answering model.
             Can either be a path to a folder containing the model files or an identifier for the Hugging Face hub.
-            Default: `'deepset/roberta-base-squad2-distilled'`
-        :param device: The device on which the model is loaded. If `None`, the default device is automatically
-            selected.
-        :param token: The API token used to download private models from Hugging Face.
-            If this parameter is set to `True`, then the token generated when running
-            `transformers-cli login` (stored in ~/.huggingface) is used.
-        :param top_k: Number of answers to return per query.
-            It is required even if score_threshold is set. Defaults to 20.
+        :param device:
+            The device on which the model is loaded. If `None`, the default device is automatically selected.
+        :param token:
+            The API token used to download private models from Hugging Face.
+        :param top_k:
+            Number of answers to return per query. It is required even if score_threshold is set.
             An additional answer with no text is returned if no_answer is set to True (default).
-        :param score_threshold: Returns only answers with the probability score above this threshold.
-        :param max_seq_length: Maximum number of tokens.
-            If a sequence exceeds it, the sequence is split.
-            Default: 384
-        :param stride: Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
-            Default: 128
-        :param max_batch_size: Maximum number of samples that are fed through the model at the same time.
-        :param answers_per_seq: Number of answer candidates to consider per sequence.
+        :param score_threshold:
+            Returns only answers with the probability score above this threshold.
+        :param max_seq_length:
+            Maximum number of tokens. If a sequence exceeds it, the sequence is split.
+        :param stride:
+            Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
+        :param max_batch_size:
+            Maximum number of samples that are fed through the model at the same time.
+        :param answers_per_seq:
+            Number of answer candidates to consider per sequence.
             This is relevant when a Document was split into multiple sequences because of max_seq_length.
-        :param no_answer: Whether to return an additional `no answer` with an empty text and a score representing the
+        :param no_answer:
+            Whether to return an additional `no answer` with an empty text and a score representing the
             probability that the other top_k answers are incorrect.
-        :param calibration_factor: Factor used for calibrating probabilities.
-        :param overlap_threshold: If set this will remove duplicate answers if they have an overlap larger than the
+        :param calibration_factor:
+            Factor used for calibrating probabilities.
+        :param overlap_threshold:
+            If set this will remove duplicate answers if they have an overlap larger than the
             supplied threshold. For example, for the answers "in the river in Maine" and "the river" we would remove
             one of these answers since the second answer has a 100% (1.0) overlap with the first answer.
             However, for the answers "the river in" and "in Maine" there is only a max overlap percentage of 25% so
             both of these answers could be kept if this variable is set to 0.24 or lower.
             If None is provided then all answers are kept.
-        :param model_kwargs: Additional keyword arguments passed to `AutoModelForQuestionAnswering.from_pretrained`
+        :param model_kwargs:
+            Additional keyword arguments passed to `AutoModelForQuestionAnswering.from_pretrained`
             when loading the model specified in `model`. For details on what kwargs you can pass,
             see the model's documentation.
         """
@@ -115,7 +131,10 @@ class ExtractiveReader:
 
     def to_dict(self) -> Dict[str, Any]:
         """
-        Serialize this component to a dictionary.
+        Serializes the component to a dictionary.
+
+        :returns:
+            Dictionary with serialized data.
         """
         serialization_dict = default_to_dict(
             self,
@@ -139,7 +158,12 @@ class ExtractiveReader:
     @classmethod
     def from_dict(cls, data: Dict[str, Any]) -> "ExtractiveReader":
         """
-        Deserialize this component from a dictionary.
+        Deserializes the component from a dictionary.
+
+        :param data:
+            Dictionary to deserialize from.
+        :returns:
+            Deserialized component.
         """
         init_params = data["init_parameters"]
         if init_params["device"] is not None:
@@ -150,7 +174,7 @@ class ExtractiveReader:
 
     def warm_up(self):
         """
-        Loads model and tokenizer
+        Initializes the component.
         """
         # Take the first device used by `accelerate`. Needed to pass inputs from the tokenizer to the correct device.
         if self.model is None:
@@ -175,7 +199,7 @@ class ExtractiveReader:
         self, queries: List[str], documents: List[Document], max_seq_length: int, query_ids: List[int], stride: int
     ) -> Tuple["torch.Tensor", "torch.Tensor", "torch.Tensor", List["Encoding"], List[int], List[int]]:
         """
-        Split and tokenize Documents and preserve structures by returning mappings to query and Document IDs.
+        Splits and tokenizes Documents and preserves structures by returning mappings to query and Document IDs.
         """
         texts = []
         document_ids = []
@@ -229,9 +253,10 @@ class ExtractiveReader:
         encodings: List["Encoding"],
     ) -> Tuple[List[List[int]], List[List[int]], "torch.Tensor"]:
         """
-        Turn start and end logits into probabilities for each answer span. Unlike most other
-        implementations, it doesn't normalize the scores in each split to make them easier to compare across different
-        splits. Returns the top k answer spans.
+        Turns start and end logits into probabilities for each answer span.
+
+        Unlike most other implementations, it doesn't normalize the scores in each split to make them easier to
+        compare across different splits. Returns the top k answer spans.
         """
         mask = sequence_ids == 1  # Only keep tokens from the context (should ignore special tokens)
         mask = torch.logical_and(mask, attention_mask == 1)  # Definitely remove special tokens
@@ -296,10 +321,11 @@ class ExtractiveReader:
         overlap_threshold: Optional[float],
     ) -> List[List[ExtractedAnswer]]:
         """
-        Reconstructs the nested structure that existed before flattening. Also computes a no answer score.
-        This score is different from most other implementations because it does not consider the no answer
-        logit introduced with SQuAD 2. Instead, it just computes the probability that the answer does not exist
-        in the top k or top p.
+        Reconstructs the nested structure that existed before flattening.
+
+        Also computes a no answer score. This score is different from most other implementations because it does not
+        consider the no answer logit introduced with SQuAD 2. Instead, it just computes the probability that the
+        answer does not exist in the top k or top p.
         """
         answers_without_query = []
         for document_id, start_candidates_, end_candidates_, probabilities_ in zip(
@@ -346,8 +372,9 @@ class ExtractiveReader:
         """
         Calculates the amount of overlap (in number of characters) between two answer offsets.
 
-        Stack overflow post explaining how to calculate overlap between two ranges:
-            https://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap/325964#325964
+        This Stack overflow
+        [post](https://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap/325964#325964)
+        explains how to calculate the overlap between two ranges.
         """
         # Check for overlap: (StartA <= EndB) and (StartB <= EndA)
         if answer1_start <= answer2_end and answer2_start <= answer1_end:
@@ -363,15 +390,18 @@ class ExtractiveReader:
         self, candidate_answer: ExtractedAnswer, current_answers: List[ExtractedAnswer], overlap_threshold: float
     ) -> bool:
         """
-        Determine if the answer should be kept based on how much it overlaps with previous answers.
+        Determines if the answer should be kept based on how much it overlaps with previous answers.
 
         NOTE: We might want to avoid throwing away answers that only have a few character (or word) overlap:
             - E.g. The answers "the river in" and "in Maine" from the context "I want to go to the river in Maine."
             might both want to be kept.
 
-        :param candidate_answer: Candidate answer that will be checked if it should be kept.
-        :param current_answers: Current list of answers that will be kept.
-        :param overlap_threshold: If the overlap between two answers is greater than this threshold then return False.
+        :param candidate_answer:
+            Candidate answer that will be checked if it should be kept.
+        :param current_answers:
+            Current list of answers that will be kept.
+        :param overlap_threshold:
+            If the overlap between two answers is greater than this threshold then return False.
         """
         keep = True
 
@@ -422,16 +452,20 @@ class ExtractiveReader:
         self, answers: List[ExtractedAnswer], overlap_threshold: Optional[float]
     ) -> List[ExtractedAnswer]:
         """
-        This de-duplicates overlapping Extractive Answers from the same document based on how much the spans of the
+        De-duplicates overlapping Extractive Answers from the same document based on how much the spans of the
         answers overlap.
 
-        :param answers: List of answers to be deduplicated.
-        :param overlap_threshold: If set this will remove duplicate answers if they have an overlap larger than the
+        :param answers:
+            List of answers to be deduplicated.
+        :param overlap_threshold:
+            If set this will remove duplicate answers if they have an overlap larger than the
             supplied threshold. For example, for the answers "in the river in Maine" and "the river" we would remove
             one of these answers since the second answer has a 100% (1.0) overlap with the first answer.
             However, for the answers "the river in" and "in Maine" there is only a max overlap percentage of 25% so
             both of these answers could be kept if this variable is set to 0.24 or lower.
             If None is provided then all answers are kept.
+        :returns:
+            List of deduplicated answers.
         """
         if overlap_threshold is None:
             return answers
@@ -466,30 +500,38 @@ class ExtractiveReader:
         """
         Locates and extracts answers from the given Documents using the given query.
 
-        :param query: Query string.
-        :param documents: List of Documents in which you want to search for an answer to the query.
-        :param top_k: The maximum number of answers to return.
+        :param query:
+            Query string.
+        :param documents:
+            List of Documents in which you want to search for an answer to the query.
+        :param top_k:
+            The maximum number of answers to return.
             An additional answer is returned if no_answer is set to True (default).
-        :param score_threshold: Returns only answers with the score above this threshold.
-        :param max_seq_length: Maximum number of tokens.
-            If a sequence exceeds it, the sequence is split.
-            Default: 384
-        :param stride: Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
-            Default: 128
-        :param max_batch_size: Maximum number of samples that are fed through the model at the same time.
-        :param answers_per_seq: Number of answer candidates to consider per sequence.
+        :param score_threshold:
+            Returns only answers with the score above this threshold.
+        :param max_seq_length:
+            Maximum number of tokens. If a sequence exceeds it, the sequence is split.
+        :param stride:
+            Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
+        :param max_batch_size:
+            Maximum number of samples that are fed through the model at the same time.
+        :param answers_per_seq:
+            Number of answer candidates to consider per sequence.
             This is relevant when a Document was split into multiple sequences because of max_seq_length.
-            Default: 20
-        :param no_answer: Whether to return no answer scores.
-            Default: True
-        :param overlap_threshold: If set this will remove duplicate answers if they have an overlap larger than the
+        :param no_answer:
+            Whether to return no answer scores.
+        :param overlap_threshold:
+            If set this will remove duplicate answers if they have an overlap larger than the
             supplied threshold. For example, for the answers "in the river in Maine" and "the river" we would remove
             one of these answers since the second answer has a 100% (1.0) overlap with the first answer.
             However, for the answers "the river in" and "in Maine" there is only a max overlap percentage of 25% so
             both of these answers could be kept if this variable is set to 0.24 or lower.
             If None is provided then all answers are kept.
-            Default: 0.01
-        :return: List of ExtractedAnswers sorted by (desc.) answer score.
+        :returns:
+            List of answers sorted by (desc.) answer score.
+
+        :raises ComponentError:
+            If the component was not warmed up by calling 'warm_up()' before.
         """
         queries = [query]  # Temporary solution until we have decided what batching should look like in v2
         nested_documents = [documents]
diff --git a/releasenotes/notes/fix-metafieldranker-weight-in-run-66ce13191e596214.yaml b/releasenotes/notes/fix-metafieldranker-weight-in-run-66ce13191e596214.yaml
new file mode 100644
index 00000000..e590bcc4
--- /dev/null
+++ b/releasenotes/notes/fix-metafieldranker-weight-in-run-66ce13191e596214.yaml
@@ -0,0 +1,4 @@
+---
+fixes:
+  - |
+    Fix a bug in the `MetaFieldRanker` where the `weight` parameter passed to the `run` method was not being used.


Test patch:
diff --git a/test/components/rankers/test_metafield.py b/test/components/rankers/test_metafield.py
index d729c55b..9514407e 100644
--- a/test/components/rankers/test_metafield.py
+++ b/test/components/rankers/test_metafield.py
@@ -1,48 +1,12 @@
-import pytest
 import logging
 
+import pytest
+
 from haystack import Document
 from haystack.components.rankers.meta_field import MetaFieldRanker
 
 
 class TestMetaFieldRanker:
-    def test_to_dict(self):
-        component = MetaFieldRanker(meta_field="rating")
-        data = component.to_dict()
-        assert data == {
-            "type": "haystack.components.rankers.meta_field.MetaFieldRanker",
-            "init_parameters": {
-                "meta_field": "rating",
-                "weight": 1.0,
-                "top_k": None,
-                "ranking_mode": "reciprocal_rank_fusion",
-                "sort_order": "descending",
-                "meta_value_type": None,
-            },
-        }
-
-    def test_to_dict_with_custom_init_parameters(self):
-        component = MetaFieldRanker(
-            meta_field="rating",
-            weight=0.5,
-            top_k=5,
-            ranking_mode="linear_score",
-            sort_order="ascending",
-            meta_value_type="date",
-        )
-        data = component.to_dict()
-        assert data == {
-            "type": "haystack.components.rankers.meta_field.MetaFieldRanker",
-            "init_parameters": {
-                "meta_field": "rating",
-                "weight": 0.5,
-                "top_k": 5,
-                "ranking_mode": "linear_score",
-                "sort_order": "ascending",
-                "meta_value_type": "date",
-            },
-        }
-
     @pytest.mark.parametrize("meta_field_values, expected_first_value", [([1.3, 0.7, 2.1], 2.1), ([1, 5, 8], 8)])
     def test_run(self, meta_field_values, expected_first_value):
         """
@@ -79,6 +43,16 @@ class TestMetaFieldRanker:
         sorted_scores = sorted([doc.meta["rating"] for doc in docs_after], reverse=True)
         assert [doc.meta["rating"] for doc in docs_after] == sorted_scores
 
+    def test_run_with_weight_equal_to_1_passed_in_run_method(self):
+        ranker = MetaFieldRanker(meta_field="rating", weight=0.0)
+        docs_before = [Document(content="abc", meta={"rating": value}) for value in [1.1, 0.5, 2.3]]
+        output = ranker.run(documents=docs_before, weight=1.0)
+        docs_after = output["documents"]
+
+        assert len(docs_after) == 3
+        sorted_scores = sorted([doc.meta["rating"] for doc in docs_after], reverse=True)
+        assert [doc.meta["rating"] for doc in docs_after] == sorted_scores
+
     def test_sort_order_ascending(self):
         ranker = MetaFieldRanker(meta_field="rating", weight=1.0, sort_order="ascending")
         docs_before = [Document(content="abc", meta={"rating": value}) for value in [1.1, 0.5, 2.3]]