DeepKE icon indicating copy to clipboard operation
DeepKE copied to clipboard

在re中使用lm模型运行predict.py报错

Open GitHubwwZ opened this issue 3 years ago • 1 comments

Describe the bug

A clear and concise description of what the bug is. Traceback (most recent call last): File "e:/ZWW/bishe/preprocess/DeepKE-main/example/re/standard/predict.py", line 142, in main y_pred = model(x) File "C:\ProgramData\Miniconda3\envs\deepke\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(*input, **kwargs) File "e:\zww\bishe\preprocess\deepke-main\src\deepke\relation_extraction\standard\models\LM.py", line 22, in forward a = self.bert(word, attention_mask=mask) File "C:\ProgramData\Miniconda3\envs\deepke\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(*input, **kwargs) File "C:\ProgramData\Miniconda3\envs\deepke\lib\site-packages\transformers\modeling_bert.py", line 830, in forward File "C:\ProgramData\Miniconda3\envs\deepke\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(*input, **kwargs) File "C:\ProgramData\Miniconda3\envs\deepke\lib\site-packages\transformers\modeling_bert.py", line 201, in forward embeddings = inputs_embeds + position_embeddings + token_type_embeddings RuntimeError: The size of tensor a (649) must match the size of tensor b (512) at non-singleton dimension 1

Environment (please complete the following information):

  • OS: [window]
  • Python Version [e.g. 3.8]

Additional context

predict.py示例可以正常运行,但是换用自己的数据就会报错,代码和deepke都是最近新下载的。

GitHubwwZ avatar Jan 16 '23 00:01 GitHubwwZ

应该是你用的句子过长了,字数在512以内

tlk1997 avatar Jan 16 '23 04:01 tlk1997