# Issue in using trainer class for Finetuning GPT-2

**URL:** <https://discuss.huggingface.co/t/issue-in-using-trainer-class-for-finetuning-gpt-2/2155>\
**Category:** Models\
**Created:** [November 21, 2020, 12:39pm UTC](https://discuss.huggingface.co/t/issue-in-using-trainer-class-for-finetuning-gpt-2/2155 "2020-11-21T12:39:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/parth/32/401_2.png) [@Parth](https://discuss.huggingface.co/u/Parth)\
**Post date:** [November 21, 2020, 12:39pm UTC](https://discuss.huggingface.co/t/issue-in-using-trainer-class-for-finetuning-gpt-2/2155/1 "2020-11-21T12:39:11Z")

</div>

While using trainer class to finetune gpt-2 on Hindi dataset. It’s outputting the following error

While using trainer class to finetune gpt-2 on Hindi dataset. It’s outputting the following error

```auto
TypeError Traceback (most recent call last)
<ipython-input-44-3435b262f1ae> in <module>()
----> 1 trainer.train()

5 frames
/usr/local/lib/python3.6/dist-packages/transformers/data/datasets/language_modeling.py in __getitem__ (self, i)
     99 
    100 def __getitem__ (self, i) -> torch.Tensor:
--> 101 return torch.tensor(self.examples[i], dtype=torch.long)
    102 
    103 

TypeError: an integer is required (got type NoneType)

```

Here is the link: [https://colab.research.google.com/drive/1um5UeY9hasmjPNcR1WkBe2uDDFhLUBrX?usp=sharing](https://colab.research.google.com/drive/1um5UeY9hasmjPNcR1WkBe2uDDFhLUBrX?usp=sharing)

---

<div class="post-metadata">

**Author:** ![Parth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/parth/32/401_2.png) [@Parth](https://discuss.huggingface.co/u/Parth)\
**Post date:** [November 23, 2020, 11:37am UTC](https://discuss.huggingface.co/t/issue-in-using-trainer-class-for-finetuning-gpt-2/2155/2 "2020-11-23T11:37:35Z")

</div>

@valhalla, Hey can you suggest something about what might be the problem. I am using trainer class on Hindi trained GPT-2. I have also shared the Colab.
