From 7f48b4336b11e731a089c10d18fd931a9aafe805 Mon Sep 17 00:00:00 2001 From: simpleqt <89645338+simpleqt@users.noreply.github.com> Date: Sun, 23 Aug 2026 20:59:55 +0800 Subject: [PATCH 1/3] fix: recursive_splitter validation message and docstring accuracy - recursive_splitter only rejects negative split_overlap (0 is the default), but the error said 'must be greater than zero'; document_splitter/hierarchical_document_splitter already word this check as 'must be greater than or equal to 0' - recursive_splitter split_overlap is measured in split_units (word/char/token), not always characters - answer_joiner sort_by_score docstring said 'documents' (copy-paste from DocumentJoiner); it sorts answers - answer_joiner _concatenate docstring claimed it sorts by score; it only flattens (sorting happens in run() and only when sort_by_score) - meta_field ranker run() docstring referenced a nonexistent 'score' mode; valid values are reciprocal_rank_fusion and linear_score --- haystack/components/joiners/answer_joiner.py | 6 +++--- haystack/components/preprocessors/recursive_splitter.py | 4 ++-- haystack/components/rankers/meta_field.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/haystack/components/joiners/answer_joiner.py b/haystack/components/joiners/answer_joiner.py index 95148e1f02b..575a4a36945 100644 --- a/haystack/components/joiners/answer_joiner.py +++ b/haystack/components/joiners/answer_joiner.py @@ -96,8 +96,8 @@ def __init__( :param top_k: The maximum number of Answers to return. Must be `None` or greater than 0. :param sort_by_score: - If `True`, sorts the documents by score in descending order. - If a document has no score, it is handled as if its score is -infinity. + If `True`, sorts the answers by score in descending order. + If an answer has no score, it is handled as if its score is -infinity. :raises ValueError: If `top_k` is not `None` and is less than or equal to 0. @@ -154,7 +154,7 @@ def run(self, answers: Variadic[list[AnswerType]], top_k: int | None = None) -> def _concatenate(self, answer_lists: list[list[AnswerType]]) -> list[AnswerType]: """ - Concatenate multiple lists of Answers, flattening them into a single list and sorting by score. + Concatenate multiple lists of Answers, flattening them into a single list. :param answer_lists: List of lists of Answers to be flattened. """ diff --git a/haystack/components/preprocessors/recursive_splitter.py b/haystack/components/preprocessors/recursive_splitter.py index 30de09b2ca6..b96f639624c 100644 --- a/haystack/components/preprocessors/recursive_splitter.py +++ b/haystack/components/preprocessors/recursive_splitter.py @@ -70,7 +70,7 @@ def __init__( :param split_length: The maximum length of each chunk by default in words, but can be in characters or tokens. See the `split_units` parameter. - :param split_overlap: The number of characters to overlap between consecutive chunks. + :param split_overlap: The number of overlapping units (words, characters, or tokens, per `split_unit`) between consecutive chunks. :param split_unit: The unit of the split_length parameter. It can be either "word", "char", or "token". If "token" is selected, the text will be split into tokens using the tiktoken tokenizer (o200k_base). :param separators: An optional list of separator strings to use for splitting the text. The string @@ -113,7 +113,7 @@ def _check_params(self) -> None: if self.split_length < 1: raise ValueError("Split length must be at least 1 character.") if self.split_overlap < 0: - raise ValueError("Overlap must be greater than zero.") + raise ValueError("split_overlap must be greater than or equal to 0.") if self.split_overlap >= self.split_length: raise ValueError("Overlap cannot be greater than or equal to the chunk size.") if not all(isinstance(separator, str) for separator in self.separators): diff --git a/haystack/components/rankers/meta_field.py b/haystack/components/rankers/meta_field.py index e66552832ff..3f3ccf3d238 100644 --- a/haystack/components/rankers/meta_field.py +++ b/haystack/components/rankers/meta_field.py @@ -195,7 +195,7 @@ def run( :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]. + Use the 'linear_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. From f26587a3eb47b1e4935a4d7ad730c6535be96bb0 Mon Sep 17 00:00:00 2001 From: simpleqt <89645338+simpleqt@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:28:52 +0800 Subject: [PATCH 2/3] chore: fix ruff line length; add release notes fragment The CI format check flagged one over-long docstring line, and the reno check requires a release notes file for every PR. --- haystack/components/preprocessors/recursive_splitter.py | 3 ++- .../fix-splitter-message-docstrings-490155c7796d449f.yaml | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml diff --git a/haystack/components/preprocessors/recursive_splitter.py b/haystack/components/preprocessors/recursive_splitter.py index b96f639624c..4ed18bd529a 100644 --- a/haystack/components/preprocessors/recursive_splitter.py +++ b/haystack/components/preprocessors/recursive_splitter.py @@ -70,7 +70,8 @@ def __init__( :param split_length: The maximum length of each chunk by default in words, but can be in characters or tokens. See the `split_units` parameter. - :param split_overlap: The number of overlapping units (words, characters, or tokens, per `split_unit`) between consecutive chunks. + :param split_overlap: The number of overlapping units (words, characters, or tokens, per + `split_unit`) between consecutive chunks. :param split_unit: The unit of the split_length parameter. It can be either "word", "char", or "token". If "token" is selected, the text will be split into tokens using the tiktoken tokenizer (o200k_base). :param separators: An optional list of separator strings to use for splitting the text. The string diff --git a/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml b/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml new file mode 100644 index 00000000000..12be54eda1f --- /dev/null +++ b/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml @@ -0,0 +1,7 @@ +fixes: + - | + Correct the `split_overlap` validation message in `RecursiveDocumentSplitter` (0 is the + default and only negative values are rejected) and clarify that overlap is measured in + `split_units`. Also fix stale docstrings in `AnswerJoiner` (documented parameters the + methods do not take, and claimed sorting that only happens for answers) and the + `meta_field` ranker (referenced a nonexistent `score` mode). From 500ad6fa9f4e0cd3202f5fe48a549849ae7d8ffd Mon Sep 17 00:00:00 2001 From: simpleqt <89645338+simpleqt@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:33:55 +0800 Subject: [PATCH 3/3] chore: use reST double backticks in the release notes fragment --- .../fix-splitter-message-docstrings-490155c7796d449f.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml b/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml index 12be54eda1f..1235ad5a6fe 100644 --- a/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml +++ b/releasenotes/notes/fix-splitter-message-docstrings-490155c7796d449f.yaml @@ -1,7 +1,7 @@ fixes: - | - Correct the `split_overlap` validation message in `RecursiveDocumentSplitter` (0 is the + Correct the ``split_overlap`` validation message in ``RecursiveDocumentSplitter`` (0 is the default and only negative values are rejected) and clarify that overlap is measured in - `split_units`. Also fix stale docstrings in `AnswerJoiner` (documented parameters the + ``split_units``. Also fix stale docstrings in ``AnswerJoiner`` (documented parameters the methods do not take, and claimed sorting that only happens for answers) and the - `meta_field` ranker (referenced a nonexistent `score` mode). + ``meta_field`` ranker (referenced a nonexistent ``score`` mode).