Skip to content

Commit c87cfd6

Browse files
committed
Better error message when inputs are empty
1 parent e9fa7cd commit c87cfd6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/transformers/trainer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,11 @@ def _prepare_inputs(self, inputs: Dict[str, Union[torch.Tensor, Any]]) -> Dict[s
19341934
handling potential state.
19351935
"""
19361936
inputs = self._prepare_input(inputs)
1937+
if len(inputs) == 0:
1938+
raise ValueError(
1939+
"The batch received was empty, your model won't be able to train on it. Double-check that your "
1940+
f"training dataset contains keys expected by the model: {','.join(self._signature_columns)}."
1941+
)
19371942
if self.args.past_index >= 0 and self._past is not None:
19381943
inputs["mems"] = self._past
19391944

0 commit comments

Comments
 (0)