# Troubleshoot KeyError: loss

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413%3E%5C
**Category:** Beginners\
**Created:** [January 12, 2023, 2:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413 "2023-01-12T02:38:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeyworks](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/honeyworks/32/13230_2.png) [@honeyworks](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhoneyworks)%5C
**Post date:** [January 12, 2023, 2:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413%2F1 "2023-01-12T02:38:21Z")

</div>

I get the KeyError: loss when running trainer.train()

Here’s what my dataset looks like:  
 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/1/1145784ee5ee64265b131918db3fc7a58004cc87.png)

That’s a dataframe, which I convert to a dataset for the trainer.

Fine-tuning distilgpt2. I noticed the model doesn’t take “lables” as a param. Did I configure it right.

Any guidance on where to look is much appreciated.

Thank you!

---

<div class="post-metadata">

**Author:** ![honeyworks](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/honeyworks/32/13230_2.png) [@honeyworks](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhoneyworks)%5C
**Post date:** [January 12, 2023, 2:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413%2F2 "2023-01-12T02:39:56Z")

</div>

![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/ddc47b4604f21d4386a8b53e370c750c8ffddc25.png)  
This could be why it’s not computing a loss, I just don’t know what to change.

---

<div class="post-metadata">

**Author:** ![honeyworks](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/honeyworks/32/13230_2.png) [@honeyworks](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhoneyworks)%5C
**Post date:** [January 12, 2023, 2:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413%2F3 "2023-01-12T02:41:00Z")

</div>

![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/a/a4604a64263a25a4c7751acc83fa7d1676c5aa70.png)

---

<div class="post-metadata">

**Author:** ![honeyworks](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/honeyworks/32/13230_2.png) [@honeyworks](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhoneyworks)%5C
**Post date:** [January 12, 2023, 2:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftroubleshoot-keyerror-loss%2F29413%2F4 "2023-01-12T02:41:24Z")

</div>

![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/a/a1a9147ced677f2452dedb13b7c2c6209fda682c.png)
