zjunlp / DeepKE

[EMNLP 2022] An Open Toolkit for Knowledge Graph Extraction and Construction
http://deepke.zjukg.cn/
MIT License
3.55k stars 684 forks source link

Cnschema自带的关系抽取模型报错 #116

Closed HojaMuerta closed 2 years ago

HojaMuerta commented 2 years ago

Traceback (most recent call last): File "D:/MyProject/python/DeepKE-main/example/re/standard/predict.py", line 120, in main model.load(cfg.fp, device=device) File "D:\MyProject\python\DeepKE-main\src\deepke\relation_extraction\standard\models\BasicModule.py", line 19, in load self.load_state_dict(torch.load(path, map_location=device)) File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\torch\nn\modules\module.py", line 1482, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(RuntimeError: Error(s) in loading state_dict for PCNN: Missing key(s) in state_dict: "embedding.wordEmbed.weight", "embedding.entityPosEmbed.weight", "embedding.attribute_keyPosEmbed.weight", "embedding.layer_norm.weight", "embedding.layer_norm.bias", "cnn.convs.0.weight", "cnn.convs.1.weight", "cnn.convs.2.weight", "cnn.activations.prelu.weight", "fc1.weight", "fc1.bias", "fc2.weight", "fc2.bias". Unexpected key(s) in state_dict: "bert.embeddings.position_ids", "bert.embeddings.word_embeddings.weight", "bert.embeddings.position_embeddings.weight", "bert.embeddings.token_type_embeddings.weight", "bert.embeddings.LayerNorm.weight", "bert.embeddings.LayerNorm.bias", "bert.encoder.layer.0.attention.self.query.weight", "bert.encoder.layer.0.attention.self.query.bias", "bert.encoder.layer.0.attention.self.key.weight", "bert.encoder.layer.0.attention.self.key.bias", "bert.encoder.layer.0.attention.self.value.weight", "bert.encoder.layer.0.attention.self.value.bias", "bert.encoder.layer.0.attention.output.dense.weight", "bert.encoder.layer.0.attention.output.dense.bias", "bert.encoder.layer.0.attention.output.LayerNorm.weight", "bert.encoder.layer.0.attention.output.LayerNorm.bias", "bert.encoder.layer.0.intermediate.dense.weight", "bert.encoder.layer.0.intermediate.dense.bias", "bert.encoder.layer.0.output.dense.weight", "bert.encoder.layer.0.output.dense.bias", "bert.encoder.layer.0.output.LayerNorm.weight", "bert.encoder.layer.0.output.LayerNorm.bias", "bert.pooler.dense.weight", "bert.pooler.dense.bias", "bilstm.rnn.weight_ih_l0", "bilstm.rnn.weight_hh_l0", "bilstm.rnn.bias_ih_l0", "bilstm.rnn.bias_hh_l0", "bilstm.rnn.weight_ih_l0_reverse", "bilstm.rnn.weight_hh_l0_reverse", "bilstm.rnn.bias_ih_l0_reverse", "bilstm.rnn.bias_hh_l0_reverse", "fc.weight", "fc.bias". Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.进程已结束,退出代码1

HojaMuerta commented 2 years ago

我的torch是1.10.0的,会是这个关系吗

tlk1997 commented 2 years ago

感谢提issue,还需要修改conf文件夹中config.yaml中model为lm,后续会修改readme

HojaMuerta commented 2 years ago

感谢提issue,还需要修改conf文件夹中config.yaml中model为lm,后续会修改readme

感谢回复,又出现了新的问题,抽取关系不准确,同时有新的报错,不知道是否是报错部分影响结果

HojaMuerta commented 2 years ago

感谢提issue,还需要修改conf文件夹中config.yaml中model为lm,后续会修改readme

[2022-06-10 13:12:05,774][main][INFO] - "男人的爱" 和 "人生长路" 在句中关系为:"毕业院校",置信度为0.99。Traceback (most recent call last): File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra_internal\utils.py", line 198, in run_and_report return func() File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra_internal\utils.py", line 347, in lambda: hydra.run( File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra_internal\hydra.py", line 107, in run return run_job( File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra\core\utils.py", line 127, in run_job ret.return_value = task_function(task_cfg) File "D:/MyProject/python/DeepKE-main/example/re/standard/predict.py", line 153, in main plt.bar(x, height) File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\matplotlib\pyplot.py", line 2620, in bar return gca().bar( File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\matplotlib__init.py", line 1352, in inner return func(ax, *map(sanitize_sequence, args), **kwargs) File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\matplotlib\axes_axes.py", line 2304, in bar x, height, width, y, linewidth, hatch = np.broadcast_arrays( File "<__array_function internals>", line 180, in broadcast_arrays File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\numpy\lib\stride_tricks.py", line 539, in broadcast_arrays shape = _broadcast_shape(args) File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\numpy\lib\stride_tricks.py", line 421, in _broadcast_shape b = np.broadcast(args[:32])ValueError: shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 0 with shape (11,) and arg 1 with shape (51,).During handling of the above exception, another exception occurred:Traceback (most recent call last): File "D:/MyProject/python/DeepKE-main/example/re/standard/predict.py", line 163, in main() File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra\main.py", line 32, in decorated_main _run_hydra( File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra_internal\utils.py", line 346, in _run_hydra run_and_report( File "F:\Anaconda3\envs\DeepKE-main\lib\site-packages\hydra_internal\utils.py", line 237, in run_and_report assert mdl is not NoneAssertionError进程已结束,退出代码1

tlk1997 commented 2 years ago

新的报错应该是跟predict_plot这个参数设置为FALSE即可,型训练时效果不错,预测效果不佳模的问题我们正在处理中

HojaMuerta commented 2 years ago

新的报错应该是跟predict_plot有关设置为FALSE即可,模型效果的这个问题我们正在处理中

好的,谢谢回复!

HojaMuerta commented 2 years ago

新的报错应该是跟predict_plot这个参数设置为FALSE即可,型训练时效果不错,预测效果不佳模的问题我们正在处理中

请问结果不对这个是模型的问题吗,有可替换的模型吗

tlk1997 commented 2 years ago

提供的两个模型在训练时都能达到很好的效果,具体是什么问题也还在找

zxlzr commented 2 years ago

非常抱歉,关系抽取模型有bug,我们会在下周更新模型

tlk1997 commented 2 years ago

您好,模型已更新,预测时候需要添加上实体抽取中的实体类型,这样预测更加准确

HojaMuerta commented 2 years ago

您好,模型已更新,预测时候需要添加上实体抽取中的实体类型,这样预测更加准确

我已经重新下载了模型,但是预测结果仍然为"毕业院校"

tlk1997 commented 2 years ago

您好,模型已更新,预测时候需要添加上实体抽取中的实体类型,这样预测更加准确

我已经重新下载了模型,但是预测结果仍然为"毕业院校"

用的是哪个例子

HojaMuerta commented 2 years ago

您好,模型已更新,预测时候需要添加上实体抽取中的实体类型,这样预测更加准确

我已经重新下载了模型,但是预测结果仍然为"毕业院校"

用的是哪个例子

Redme预设的专辑那个例子,切换其他的也一样

tlk1997 commented 2 years ago

这个例子用bert-chinese-wwm没有错啊,实体类型也需要给