Commit c472755
Raise clear error for
* Raise clear error for problem_type="single_label_classification" with num_labels=1
This combination is mathematically degenerate: applying cross-entropy loss to a
single logit always yields zero loss, so training silently accomplishes nothing.
Validate the combination in PreTrainedConfig.__post_init__ so users get a clear
error at config construction with a pointer to the correct setup (num_labels=2
for binary classification, or problem_type="regression" for a single-output
regression head).
Closes huggingface#45479
* Update src/transformers/configuration_utils.py
* Update tests/utils/test_configuration_utils.py
* Update src/transformers/configuration_utils.py
---------
Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>problem_type="single_label_classification" with num_labels=1 (huggingface#45611)1 parent 678e871 commit c472755
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
268 | 275 | | |
269 | 276 | | |
270 | 277 | | |
| |||
0 commit comments