Hello, I am trying to fine-tune a mT5 based model for reading comprehension task in Farsi.
whenever I run trainer.train() cell in google colab, I get the follong error:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Traceback (most recent call last) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py:3802 in get_loc โ
โ โ
โ 3799 โ โ โ โ ) โ
โ 3800 โ โ โ casted_key = self._maybe_cast_indexer(key) โ
โ 3801 โ โ โ try: โ
โ โฑ 3802 โ โ โ โ return self._engine.get_loc(casted_key) โ
โ 3803 โ โ โ except KeyError as err: โ
โ 3804 โ โ โ โ raise KeyError(key) from err โ
โ 3805 โ โ โ except TypeError: โ
โ โ
โ in pandas._libs.index.IndexEngine.get_loc:138 โ
โ โ
โ in pandas._libs.index.IndexEngine.get_loc:165 โ
โ โ
โ in pandas._libs.hashtable.PyObjectHashTable.get_item:5745 โ
โ โ
โ in pandas._libs.hashtable.PyObjectHashTable.get_item:5753 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
KeyError: 203
The above exception was the direct cause of the following exception:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Traceback (most recent call last) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ in <cell line: 1>:1 โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:1645 in train โ
โ โ
โ 1642 โ โ inner_training_loop = find_executable_batch_size( โ
โ 1643 โ โ โ self._inner_training_loop, self._train_batch_size, args.auto_find_batch_size โ
โ 1644 โ โ ) โ
โ โฑ 1645 โ โ return inner_training_loop( โ
โ 1646 โ โ โ args=args, โ
โ 1647 โ โ โ resume_from_checkpoint=resume_from_checkpoint, โ
โ 1648 โ โ โ trial=trial, โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:1916 in _inner_training_loop โ
โ โ
โ 1913 โ โ โ โ rng_to_sync = True โ
โ 1914 โ โ โ โ
โ 1915 โ โ โ step = -1 โ
โ โฑ 1916 โ โ โ for step, inputs in enumerate(epoch_iterator): โ
โ 1917 โ โ โ โ total_batched_samples += 1 โ
โ 1918 โ โ โ โ if rng_to_sync: โ
โ 1919 โ โ โ โ โ self._load_rng_state(resume_from_checkpoint) โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py:633 in next โ
โ โ
โ 630 โ โ โ if self._sampler_iter is None: โ
โ 631 โ โ โ โ # TODO(Bug in dataloader iterator found by mypy ยท Issue #76750 ยท pytorch/pytorch ยท GitHub) โ
โ 632 โ โ โ โ self._reset() # type: ignore[call-arg] โ
โ โฑ 633 โ โ โ data = self._next_data() โ
โ 634 โ โ โ self._num_yielded += 1 โ
โ 635 โ โ โ if self._dataset_kind == _DatasetKind.Iterable and \ โ
โ 636 โ โ โ โ โ self._IterableDataset_len_called is not None and \ โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py:677 in _next_data โ
โ โ
โ 674 โ โ
โ 675 โ def _next_data(self): โ
โ 676 โ โ index = self._next_index() # may raise StopIteration โ
โ โฑ 677 โ โ data = self._dataset_fetcher.fetch(index) # may raise StopIteration โ
โ 678 โ โ if self._pin_memory: โ
โ 679 โ โ โ data = _utils.pin_memory.pin_memory(data, self._pin_memory_device) โ
โ 680 โ โ return data โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py:51 in fetch โ
โ โ
โ 48 โ โ โ if hasattr(self.dataset, โgetitemsโ) and self.dataset.getitems: โ
โ 49 โ โ โ โ data = self.dataset.getitems(possibly_batched_index) โ
โ 50 โ โ โ else: โ
โ โฑ 51 โ โ โ โ data = [self.dataset[idx] for idx in possibly_batched_index] โ
โ 52 โ โ else: โ
โ 53 โ โ โ data = self.dataset[possibly_batched_index] โ
โ 54 โ โ return self.collate_fn(data) โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py:51 in โ
โ โ
โ 48 โ โ โ if hasattr(self.dataset, โgetitemsโ) and self.dataset.getitems: โ
โ 49 โ โ โ โ data = self.dataset.getitems(possibly_batched_index) โ
โ 50 โ โ โ else: โ
โ โฑ 51 โ โ โ โ data = [self.dataset[idx] for idx in possibly_batched_index] โ
โ 52 โ โ else: โ
โ 53 โ โ โ data = self.dataset[possibly_batched_index] โ
โ 54 โ โ return self.collate_fn(data) โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/pandas/core/frame.py:3807 in getitem โ
โ โ
โ 3804 โ โ if is_single_key: โ
โ 3805 โ โ โ if self.columns.nlevels > 1: โ
โ 3806 โ โ โ โ return self._getitem_multilevel(key) โ
โ โฑ 3807 โ โ โ indexer = self.columns.get_loc(key) โ
โ 3808 โ โ โ if is_integer(indexer): โ
โ 3809 โ โ โ โ indexer = [indexer] โ
โ 3810 โ โ else: โ
โ โ
โ /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py:3804 in get_loc โ
โ โ
โ 3801 โ โ โ try: โ
โ 3802 โ โ โ โ return self._engine.get_loc(casted_key) โ
โ 3803 โ โ โ except KeyError as err: โ
โ โฑ 3804 โ โ โ โ raise KeyError(key) from err โ
โ 3805 โ โ โ except TypeError: โ
โ 3806 โ โ โ โ # If we have a listlike key, _check_indexing_error will raise โ
โ 3807 โ โ โ โ # InvalidIndexError. Otherwise we fall through and re-raise โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
KeyError: 203
Here it is my code:
Function that returns an untrained model to be trained
def model_init():
return AutoModelForSeq2SeqLM.from_pretrained(model_dir)
trainer = Seq2SeqTrainer(
model_init=model_init,
args=args,
train_dataset=train_df,
eval_dataset=eval_df,
data_collator=data_collator,
tokenizer=tokenizer,
compute_metrics=compute_metrics
)
---------------------- the Next Cell ---------------------------------
Start TensorBoard before training to monitor it in progress
%load_ext tensorboard
%tensorboard --logdir โ/content/gdrive/MyDrive/parsinlu/runsโ
---------------------- the Next Cell ---------------------------------
trainer.train()
I would appreciate if anybody could help me.