Skip to content
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

raises ValueError when num_label !=1 when using Crossencoder.rank() #3126

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

JINO-ROHIT
Copy link
Contributor

Raises ValueError when num_label !=1 when using Crossencoder.rank()

Fixes #3124

Who can review?
@tomaarsen

@@ -527,6 +527,8 @@ def rank(
'score': -5.082967,
'text': "The 'Harry Potter' series, which consists of seven fantasy novels written by British author J.K. Rowling, is among the most popular and critically acclaimed books of the modern era."}]
"""
if self.config.num_labels != 1:
raise ValueError("CrossEncoder.rank() only works for models with num_labels=1.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!
What do you think, should we maybe also refer people to CrossEncoder.predict()?
Something like:

Suggested change
raise ValueError("CrossEncoder.rank() only works for models with num_labels=1.")
raise ValueError(
"CrossEncoder.rank() only works for models with num_labels=1. "
"Consider using CrossEncoder.predict() with input pairs instead."
)

Otherwise people might just stop using Sentence Transformers altogether when CrossEncoder.rank fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true

@tomaarsen
Copy link
Collaborator

I like it! Well done - I appreciate it.

  • Tom Aarsen

@tomaarsen tomaarsen merged commit afdf692 into UKPLab:master Dec 12, 2024
9 checks passed
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.

CrossEncoder .rank condition error in CrossEncoder.py
2 participants