deepset-ai / deepset-ai/haystack-core-integrations

Falsy run() overrides are silently ignored in SentenceTransformersSimilarityRanker

Open
#3,854 0 comments 1 reaction 1 assignee View on GitHub

@bogdankostic is already working on this.

Since Aug 30, 2026.

P2
Dominant language
Python
Stars
203
Forks
332
Avg merge
2d 4h
Merged PRs (30d)
80

Description

Describe the bug
run() resolves its overrides with or:

top_k = top_k or self.top_k
scale_score = scale_score or self.scale_score
score_threshold = score_threshold or self.score_threshold

or falls back on any falsy value, not just None, so valid falsy arguments are silently replaced by the init values, although the docstring says "If set, overrides the value set at initialization":

  • run(scale_score=False) is ignored: with the default scale_score=True, False or True is True
  • run(score_threshold=0.0) is replaced by the init value, or by no filtering at all
  • run(top_k=0) silently uses the init top_k instead of raising the documented ValueError

To Reproduce

ranker = SentenceTransformersSimilarityRanker()   # scale_score=True by default
ranker.run(query=query, documents=docs, scale_score=False)
# the cross encoder still runs with the Sigmoid activation

Describe your environment (please complete the following information):

  • OS: Ubuntu 24.04 LTS
  • Haystack version: 3.0.0
  • Integration version: current main

Additional context
#3745 fixed the same or pattern for top_k in the fastembed rankers.
Happy to open a PR with the same fix and regression tests.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.