Cyberbolt / Cemotion

A Chinese NLP library based on BERT for sentiment analysis and general-purpose Chinese word segmentation. | 基于 BERT 的中文 NLP 库,用于中文情感倾向分析、通用领域中文分词。
MIT License
187 stars 22 forks source link

RuntimeError: Error(s) in loading state_dict for SentimentClassifier: #5

Closed Vincent0102 closed 1 year ago

Vincent0102 commented 1 year ago

我更新了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".

jkjk1996 commented 1 year ago

strict=False

Cyberbolt commented 1 year ago

创建一个全新的虚拟环境,重新 pip install cemotion 后试试?

WhItEG-bit commented 1 year ago

根据报错信息: 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

Cyberbolt commented 1 year ago

根据报错信息: 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

已更新,感谢测试!