Error while training Transformer [Part 1, Lecture 4]

Hi!
While following along with Lecture 4 of Part 1 of the course, I created my separate notebook to follow along, and make some changes. When I followed all the steps and went on to train the Transformer, it should be a ValueError, showing the following error:

ValueError: The model did not return a loss from the inputs, only the following keys: logits. For reference, the inputs it received are input_ids,token_type_ids,attention_mask.

How do I resolve this error?

For more information about my code, here is my notebook for this lesson: https://www.kaggle.com/code/utkmal/starting-with-nlp-using-transformers-library

Hello @utkrsh

Looks like your notebook is private on Kaggle which means we can’t see what is inside of this notebook. You can change visibility from ‘Settings’ section of your notebook.

Would be happy if I can see and help with your problem.

Hi @murodbek , sorry didn’t realise that the notebook was private. You can view the notebook now.

Hey there!
Thank you for expressing interest in solving my problem, but I’ve debugged the issue now.

I had not renamed my score column to labels because of which the transformer had no ground truth value, and hence was unable to return any loss function value.

2 Likes

Happy that you can solve the issue!