zjunlp / DeepKE

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

cannot import name 'process_long_input' from 'deepke.relation_extraction.document.module' #89

Closed caocb123 closed 2 years ago

caocb123 commented 2 years ago

问题一: 运行example/ner/standard/下的run.py,报错: Traceback (most recent call last): File "run.py", line 20, in from deepke.name_entity_re.standard import File "/home/ubuntu/anaconda3/envs/deepke/lib/python3.8/site-packages/deepke/init.py", line 2, in from .relation_extraction import File "/home/ubuntu/anaconda3/envs/deepke/lib/python3.8/site-packages/deepke/relation_extraction/init.py", line 2, in from .document import File "/home/ubuntu/anaconda3/envs/deepke/lib/python3.8/site-packages/deepke/relation_extraction/document/init.py", line 1, in from .model import File "/home/ubuntu/anaconda3/envs/deepke/lib/python3.8/site-packages/deepke/relation_extraction/document/model.py", line 7, in from .module import AttentionUNet, process_long_input ImportError: cannot import name 'process_long_input' from 'deepke.relation_extraction.document.module' (/home/ubuntu/anaconda3/envs/deepke/lib/python3.8/site-packages/deepke/relation_extraction/document/module.py) 问题:process_long_input没找到,是我缺少什么模块或者模块版本对不上吗?

问题二: 运行example/ner/standard/下的run.py时提示缺少"allennlp"模块, 于是pip install allennlp,默认下载了2.9版本的,提示与torch1.5不兼容, 再于是pip install allennlp==1.1,完成后依旧提示与torch1.5不兼容, 再再于是pip install allennlp==1.0,完成不提示与torch1.5不兼容了,但是提示“deepke 0.2.66 requires transformers==3.4.0, but you have transformers 2.11.0 which is incompatible.”, 于是pip install transformers==3.4.0把transformers换回3.4.0,但是提示“allennlp 1.0.0 requires transformers<2.12,>=2.9, but you have transformers 3.4.0 which is incompatible.”, 问题:allennlp不能同时兼容torch1.5和transformers3.4.0对项目的运行有没有影响?如果有影响,求告知哪个版本可以兼容,感谢。

caocb123 commented 2 years ago

我把deepke版本降到0.2.61之后不再报问题一的错了,但是运行run.py,出现Epoch: 0%| | 0/1 [00:00<?, ?it/sKilledtion: 0%| | 0/652 [00:00<?, ?it/s]之后就会跳回输入栏,反复尝试了很多次都是这样

tlk1997 commented 2 years ago

感谢使用deepke。如果通过pip install deepke遇到问题,建议通过python setup.py install的方式进行安装

caocb123 commented 2 years ago

感谢回复。我按照您的建议,改用python setup.py install的方式进行安装,这次安装过程确实一路畅通没有报错,但是运行ner的run.py仍然出了问题,具体情况是: [2022-02-18 16:04:02,231][pytorch_transformers.modeling_utils][INFO] - loading weights file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese-pytorch_model.bin from cache at /home/ubuntu/.cache/torch/pytorch_transformers/b1b5e295889f2d0979ede9a78ad9cb5dc6a0e25ab7f9417b315f0a2c22f4683d.929717ca66a3ba9eb9ec2f85973c6398c54c38a4faa464636a491d7a705f7eb6 [2022-02-18 16:04:05,120][pytorch_transformers.modeling_utils][INFO] - Weights of TrainNer not initialized from pretrained model: ['classifier.weight', 'classifier.bias'] [2022-02-18 16:04:05,120][pytorch_transformers.modeling_utils][INFO] - Weights from pretrained model not used in TrainNer: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias'] Epoch: 0%| | 0/1 [00:00<?, ?it/sKilledtion: 0%| | 0/652 [00:00<?, ?it/s] (deepke01) ubuntu@ubuntu-virtual-machine:~/DeepKE/example/ner/standard$

如上:进度条没有增长,直接跳回了指令输入栏,checkpoints下没有输出任何结果,我不知道是哪里出了问题。

tlk1997 commented 2 years ago

如果使用gpu训练的话,是不是没有安装torch的另外两个包

pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html