Skip to content

fix(descriptors): convert Series to list in semantic_similarity_scoring - #1904

Open
RK0297 wants to merge 1 commit into
evidentlyai:mainfrom
RK0297:fix/1888-semantic-similarity-series
Open

fix(descriptors): convert Series to list in semantic_similarity_scoring#1904
RK0297 wants to merge 1 commit into
evidentlyai:mainfrom
RK0297:fix/1888-semantic-similarity-series

Conversation

@RK0297

@RK0297 RK0297 commented Jul 25, 2026

Copy link
Copy Markdown

This PR complements #1889 by fixing the second call site where a pandas.Series was passed directly into model.encode() in semantic_similarity_scoring (src/evidently/descriptors/_context_relevance.py).

Newer sentence-transformers versions (5.6.1+) no longer coerce pandas.Series objects, causing a ValueError: Unsupported input type: Series.

Changes

  • Convert question.data.fillna("") and context_rows[context_column].fillna("") to Python list via .tolist() before calling model.encode().
  • Add unit test in ests/descriptors/test_context_relevance.py with mocked SentenceTransformer.

Relates to #1888.

Copilot AI review requested due to automatic review settings July 25, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a runtime incompatibility in semantic_similarity_scoring where pandas.Series inputs were passed directly into SentenceTransformer.encode(), which newer sentence-transformers versions reject. It also adds a regression test to ensure encoding inputs are converted to plain Python lists.

Changes:

  • Convert question.data.fillna("") and exploded context values to list via .tolist() before calling model.encode().
  • Add a unit test verifying both encode() call sites receive list arguments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/evidently/descriptors/_context_relevance.py Converts filled Series inputs to Python lists before SentenceTransformer.encode() to avoid Unsupported input type: Series.
tests/descriptors/test_context_relevance.py Adds a regression test covering the two encode() call sites and asserting list conversion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/descriptors/test_context_relevance.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants