deepset-ai / deepset-ai/haystack-core-integrations
Falsy run() overrides are silently ignored in SentenceTransformersSimilarityRanker
Open
@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 defaultscale_score=True,False or TrueisTruerun(score_threshold=0.0)is replaced by the init value, or by no filtering at allrun(top_k=0)silently uses the inittop_kinstead 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.