Skip to content

docs: clarify that word_count_threshold counts whitespace-separated words, not tokens - #13549

Merged
anakin87 merged 2 commits into
deepset-ai:mainfrom
Smilewithoutfalling:docs/clarify-word-count-threshold-units
Nov 4, 2026
Merged

anakin87 merged 2 commits into
deepset-ai:mainfrom
Smilewithoutfalling:docs/clarify-word-count-threshold-units

Conversation

@Smilewithoutfalling

Copy link
Copy Markdown
Contributor

What

Documentation-only change to LostInTheMiddleRanker: the docs now spell out what word_count_threshold actually counts. No behaviour change.

Why

word_count_threshold is computed with str.split(), so it budgets whitespace-separated chunks, not model tokens. Users reasonably read "words" as a proxy for the downstream context window, but a URL, a hash, or a code expression counts as one word no matter how many tokens a tokenizer splits it into, and code-heavy or non-Latin text needs noticeably more tokens per word than English prose. A threshold sized for a model's context window can therefore still overflow it.

@julian-risch offered exactly this follow-up in #11351:

If you have a suggestion how to improve the docstring to make this limitation more clear, feel free to open a PR.

Changes

  • __init__: the paragraph describing the threshold now states the counting unit.
  • __init__ and run(): :param word_count_threshold: explain str.split(), what counts as a single word, and that the value is an approximate budget rather than a context-window guarantee.
  • Adds a release note.

Verification

  • python -m py_compile on the modified file passes.
  • No line exceeds the repository's line-length = 120.
  • The diff touches docstrings only; no executable statement changes.

No tests added: no executable code changed.

Refs #11351

…ords

`word_count_threshold` in LostInTheMiddleRanker is counted with str.split(),
so it is a budget of whitespace-separated chunks rather than of model tokens.
Spell that out in the class and parameter docs, and note that a value sized
for a model context window can still overflow it for code-heavy or non-Latin
text. No behaviour change.
@Smilewithoutfalling
Smilewithoutfalling requested a review from a team as a code owner November 4, 2026 01:13
@Smilewithoutfalling
Smilewithoutfalling requested review from anakin87 and removed request for a team November 4, 2026 01:13
@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@Smilewithoutfalling is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/rankers
  lost_in_the_middle.py
Project Total  

This report was generated by python-coverage-comment-action

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

I pushed a small improvement/simplification

@anakin87
anakin87 enabled auto-merge (squash) November 4, 2026 09:33
@anakin87
anakin87 merged commit 5b01b16 into deepset-ai:main Nov 4, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants