huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.25k stars 26.84k forks source link

GPT2 minicons surprisal: IndexError: index out of range in self #28807

Closed joyce9936 closed 9 months ago

joyce9936 commented 9 months ago

System Info

I am trying to calculating surprisal value by feeding in a txt file with about 5000 sentences. But there is a error message I encounter: IndexError: index out of range in self Can anyone help with this issue?

Thank you!

Who can help?

No response

Information

Tasks

Reproduction

Here is the code:

Screenshot 2024-01-31 at 9 35 06 PM

Here is the error message:

Screenshot 2024-01-31 at 9 34 13 PM

Expected behavior

I would like to have the surprisal value for each word for the whole text file.

ArthurZucker commented 9 months ago

Sorry but this seems unrelated to transformers and rather related to the scorer library.