Skip to content

Commit

Permalink
updated error message
Browse files Browse the repository at this point in the history
  • Loading branch information
JINO-ROHIT committed Dec 10, 2024
1 parent 5a40f63 commit 03db339
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sentence_transformers/cross_encoder/CrossEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ def rank(
'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.")
raise ValueError(
"CrossEncoder.rank() only works for models with num_labels=1. "
"Consider using CrossEncoder.predict() with input pairs instead."
)
query_doc_pairs = [[query, doc] for doc in documents]
scores = self.predict(
sentences=query_doc_pairs,
Expand Down

0 comments on commit 03db339

Please sign in to comment.