Skip to content

Commit

Permalink
Add valid columns check in _remove_unused_columns method (#31466)
Browse files Browse the repository at this point in the history
* Add valid columns checking in _remove_unused_columns method

huggingface/datasets#6973 (comment)
huggingface/datasets#6535
https://discuss.huggingface.co/t/indexerror-invalid-key-16-is-out-of-bounds-for-size-0/14298/25

* Update modeling_mixtral.py

* Update modeling_mixtral.py

* Update modeling_mixtral.py
  • Loading branch information
arthasking123 authored Jun 19, 2024
1 parent 547b558 commit 0ed3ffc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,12 @@ def _remove_unused_columns(self, dataset: "datasets.Dataset", description: Optio
)

columns = [k for k in signature_columns if k in dataset.column_names]
if len(columns) == 0:
raise ValueError(
"No columns in the dataset match the model's forward method signature. "
f"The following columns have been ignored: [{', '.join(ignored_columns)}]. "
"Please check the dataset and model. You may need to set `remove_unused_columns=False` in `TrainingArguments`."
)

if version.parse(datasets.__version__) < version.parse("1.4.0"):
dataset.set_format(
Expand Down

0 comments on commit 0ed3ffc

Please sign in to comment.