openai / gpt-2-output-dataset

Dataset of GPT-2 outputs for research in detection, biases, and more
MIT License
1.94k stars 549 forks source link

RunTimeError: Error(s) in loading state_dict for RobertaForSequenceClassification even after transformer==2.9.1 #35

Open Marvy101 opened 1 year ago

Marvy101 commented 1 year ago

I get the following error after trying to run

pip install -r requirements.txt
python -m detector.server detector-base.pt

Error:

RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification:
        Missing key(s) in state_dict: "roberta.embeddings.position_ids".
        Unexpected key(s) in state_dict: "roberta.pooler.dense.weight", "roberta.pooler.dense.bias"

I have tried transformers==2.9.1 in requirements.txt, still receiving the same error.

Thanks for your help.

hugoroussel commented 1 year ago

Having the same error too :)

Marvy101 commented 1 year ago

Having the same error too :)

Hey, still waiting on a solution and trying different things.

You wanna have a discussion about AI, and the future?

ps3-app commented 1 year ago

Having the same issues, RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification: Missing key(s) in state_dict: "roberta.embeddings.position_ids". Unexpected key(s) in state_dict: "roberta.pooler.dense.weight", "roberta.pooler.dense.bias"

do you have the solution for it yet?

AmirFone commented 1 year ago

I am having the exact same issue.

AmirFone commented 1 year ago

was anyone able to resolve this issue yet?

hugoroussel commented 1 year ago

No luck on my side :( I think it might be related to #36 (running on macs M1). Also tried running it via docker without luck too.

AryanGold commented 1 year ago

I confirm that set transformers==2.9.1 resolve issue. I try it in isolated Docker container and rebuilding container from scratch, for to be sure that all packages reinstalled.

hugoroussel commented 1 year ago

@AryanGold can you give informations about you current setup (OS etc)?

AryanGold commented 1 year ago

My Host: Ubuntu 20.04, Docker version 20.10.22

I think important to run this repository in isolated Docker container or Python Virtual Environment. Also if you change some version in requirements.txt then need reinstall all pip packages without any cache etc.

I also attache sample of my Docker file. Docker_sample.zip

varenc commented 1 year ago

I also ran into the same error and using transformers==2.9.1 fixed it. If you're not using a proper environment, like we all should be, then you can probably fix the problem just by doing pip uninstall transformers and then pip install transformers==2.9.1 but WMMV.

manueltarouca commented 1 year ago

Make sure that your python version is 3.7.3 and the following package is transformers==2.9.1.

SachinGanesh commented 1 year ago

replace

self.model.load_state_dict(data['model_state_dict'])

with

self.model.load_state_dict(data['model_state_dict'], strict=False)