Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ def __post_init__(self, **kwargs):
# Keys are always strings in JSON so convert ids to int
self.id2label = {int(key): value for key, value in self.id2label.items()}

if self.problem_type == "single_label_classification" and self.num_labels == 1:
raise ValueError(
'`problem_type="single_label_classification"` requires `num_labels > 1`. For binary '
'classification use `num_labels=2`, or use `problem_type="regression"` for a '
"single-output regression head."
)
Comment thread
Rocketknight1 marked this conversation as resolved.

# BC for rotary embeddings. We will pop out legacy keys from kwargs and rename to new format
if hasattr(self, "rope_parameters"):
kwargs = self.convert_rope_params_to_dict(**kwargs)
Expand Down
Loading