Error when loading ‘model.pkl.gz’

When loading model from ‘model.pkl.gz’ as below:
model.init_from_file(‘model.pkl.gz’, weights_only=True)
I got an error:
“IndexError: list index out of range”

Could you please point out what is the issue? Is it an issue with previous line 'model = TransformerLM(mode=‘eval’)"? But my TransformerLM function passed the unit test. Here’s my Lab ID: cjxhtjarwacp.

Thanks in advance!

Hi @texcindy99,

This means that you are referencing some index somewhere which doesn’t exist, or at least not when you are trying to load the model. One possible reason, you changed some code somewhere which shouldn’t have changed. I’d recommend to get a fresh copy of the notebook, copy/paste your solutions in it and try again.

If after doing that the error still remains, let me know.


Thanks for your reply. I refreshed the notebook per instructions but still got the same error as in the snapshot.

I had this same problem as described by @texcindy99. Passed the first 8 tests, then this strange error when loading the model from file.

I refreshed my notebook and carefully redid every test function. I also deleted the copy of ‘model.pkl.gz’ to get a fresh copy of the model file, just in case maybe the version I had was corrupted somehow.

Refreshing as above did work.

Would love to hear if anyone else ran into this and what the cause could have been ?

I am having the same problem. I tried refreshing the model but I am still getting the same error. Has library version with which the model was generated changed recently?

I experience similar issue and have tried fresh notebook and also delete model.pkl.gz for forcing a new model file. Still same issue, anyone can help on this?

And my lab id is: ovspawlvijcs


Hi @raveeshu_pahuja & @Hu_Qing,

Do you still need help with this ?


I already pass this when resubmit. Not know the root cause but I’m unblocked.