Fix MovieLens dataset incompatibility with SentenceTransformers =5.x#10668
Open
drivanov wants to merge 4 commits intopyg-team:masterfrom
Open
Fix MovieLens dataset incompatibility with SentenceTransformers =5.x#10668drivanov wants to merge 4 commits intopyg-team:masterfrom
drivanov wants to merge 4 commits intopyg-team:masterfrom
Conversation
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10668 +/- ##
==========================================
- Coverage 86.11% 84.18% -1.93%
==========================================
Files 496 510 +14
Lines 33655 36022 +2367
==========================================
+ Hits 28981 30325 +1344
- Misses 4674 5697 +1023 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a runtime error in the
MovieLensdataset when used with newer versions of sentence-transformers (≥5.x).The issue arises from passing a NumPy array (df['title'].values) to
SentenceTransformer.encode(), which leads to incorrect modality inference and raises:Root Cause
Recent versions of SentenceTransformers` introduced modality-aware input handling.
When a NumPy array is passed:
the library may misinterpret the input as a non-text modality (e.g., audio), instead of text.
However, encode() expects a List[str] for text inputs.
Fix
Convert the input to an explicit list of strings before encoding: