RuntimeError: Error(s) in loading state_dict for SentimentClassifier:
Closed this issue · 4 comments
我更新了cemotin 2.0.3,torch 2.0.1
运行
from cemotion import Cemotion
c = Cemotion()
报错:RuntimeError: Error(s) in loading state_dict for SentimentClassifier:
Unexpected key(s) in state_dict: "bert.bert.embeddings.position_ids".
strict=False
创建一个全新的虚拟环境,重新 pip install cemotion 后试试?
根据报错信息:
Unexpected key(s) in state_dict: "bert.bert.embeddings.position_ids".
我查了下发现是包transformers的版本问题,用pip install cemotion后根据requireme.txt会自动下载满足要求的最新的包,也就是transformers 4.31.4版本,然后我重装为4.24.0版本就能正常运行了;
建议好兄弟直接设定transformers ==4.24.0
根据报错信息: Unexpected key(s) in state_dict: "bert.bert.embeddings.position_ids". 我查了下发现是包transformers的版本问题,用pip install cemotion后根据requireme.txt会自动下载满足要求的最新的包,也就是transformers 4.31.4版本,然后我重装为4.24.0版本就能正常运行了; 建议好兄弟直接设定transformers ==4.24.0
已更新,感谢测试!