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.
Describe the bug
run()resolves its overrides withor:orfalls back on any falsy value, not justNone, 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 ValueErrorTo Reproduce
Describe your environment (please complete the following information):
mainAdditional context
#3745 fixed the same
orpattern fortop_kin the fastembed rankers.Happy to open a PR with the same fix and regression tests.