-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: ensure sentence_transformers_similarity score is a float to not np.float #9665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ent serialization issues
Pull Request Test Coverage Report for Build 16703692448Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
Overall, it's good.
I left some minor comments to address...
releasenotes/notes/fix-SentenceTransformersSimilarityRanker-score-float-a1988363b01dfc32.yaml
Outdated
Show resolved
Hide resolved
test/components/rankers/test_sentence_transformers_similarity.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks again!
Related Issues
Documents
with numpy score #9664Proposed Changes:
The SentenceTransformersSimilarityRanker CrossEncoder model was returning score as a numpy.float32 without casting to float, which can cause JSON serialization issues in downstream integrations.
Explicitly cast the score to a standard Python float before assigning it to Document.score.
How did you test it?
Added a unit test to verify that Document.score is always a Python float.
Ran all existing unit tests with hatch run test:unit to ensure no regressions.
Notes for the reviewer
The change is minimal but important for serialization compatibility.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.