zjunlp / DeepKE

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

关于快速上手的re部分模型部署问题 #287

Closed debrisvector closed 1 year ago

debrisvector commented 1 year ago

您好,我根据快速上手re的部分下载模型DeepKE(RE), RoBERTa-wwm-ext, Chinese,根据报错提示将re模型的下载内容置入\example\re\standard\data下,这里checkpoints应该选择快速部署中的内容还是根据lm.yaml中选择bert-base-chinese?此时仍旧不能成功部署,记录如下

cwd: C:\Users\LR\Desktop\DeepKE-main\DeepKE-main\example\re\standard preprocess: true data_path: data/origin out_path: data/out chinese_split: true replace_entity_with_type: true replace_entity_with_scope: true min_freq: 3 pos_limit: 30 seed: 1 use_gpu: true gpu_id: 0 epoch: 50 batch_size: 32 learning_rate: 0.0003 lr_factor: 0.7 lr_patience: 3 weight_decay: 0.001 early_stopping_patience: 6 train_log: true log_interval: 10 show_plot: false only_comparison_plot: false plot_utils: matplot predict_plot: false use_multi_gpu: false gpu_ids: 0,1 vocab_size: ??? word_dim: 60 pos_size: 62 pos_dim: 10 dim_strategy: sum num_relations: 51 fp: C:/Users/LR/Desktop/DeepKE-main/DeepKE-main/example/re/standard/checkpoints/2019-12-03_17-35-30/cnn_epoch21.pth model_name: lm lm_file: bert-base-chinese num_hidden_layers: 1 type_rnn: LSTM input_size: 768 hidden_size: 100 num_layers: 1 dropout: 0.3 bidirectional: true last_layer_hn: true

是否使用范例[y/n],退出请输入: exit .... C:\Users\LR.conda\envs\deepke\lib\site-packages\omegaconf\basecontainer.py:225: UserWarning: cfg.pretty() is deprecated and will be removed in a future version. Use OmegaConf.to_yaml(cfg)

warnings.warn( y [2023-06-08 14:13:56,170][deepke.relation_extraction.standard.tools.preprocess][INFO] - use bert tokenizer... Traceback (most recent call last): File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen self._prepare_proxy(conn) File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\connectionpool.py", line 996, in _prepare_proxy conn.connect() File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\connection.py", line 369, in connect self.sock = conn = self._connect_tls_proxy(hostname, conn) File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\connection.py", line 504, in _connect_tls_proxy socket = ssl_wrapsocket( File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\util\ssl.py", line 453, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_intls) File "C:\Users\LR.conda\envs\deepke\lib\site-packages\urllib3\util\ssl.py", line 495, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock) File "C:\Users\LR.conda\envs\deepke\lib\ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "C:\Users\LR.conda\envs\deepke\lib\ssl.py", line 1040, in _create self.do_handshake() File "C:\Users\LR.conda\envs\deepke\lib\ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1131)

During handling of the above exception, another exception occurred:

请问是我下载的模型放置位置不对么,或者是checkpoints的内容有误么

xxupiano commented 1 year ago

fp: C:/Users/LR/Desktop/DeepKE-main/DeepKE-main/example/re/standard/checkpoints/2019-12-03_17-35-30/cnn_epoch21.pth 根据报错你应该使用的win,但是fp的路径格式是linux

debrisvector commented 1 year ago

fp: C​​:/Users/LR/Desktop/DeepKE-main/DeepKE-main/example/re/standard/checkpoints/2019-12-03_17-35-30/cnn_epoch21.pth 根据报告错误你应该使用的win,但是fp路径格式是 linux 您好,关于第一个问题那我还是想问下 1 \example\re\standard\checkpoint的模型应该是选用bert-base-chinese是否正确。 2 下载的RE文件夹下的内容是否应该放置在\example\re\standard\data。 第二个问题是 关于fp我比较困惑的是原文中“修改 predict.yaml中的参数fp为下载文件的路径”的意思,该fp路径是指什么的路径,是指我下载的re模型放置位置的路径么? 在后续调试时我发现也出现了类似No such file or directory: 'C:/Users/LR/Desktop/DeepKE-main/DeepKE-main/example/re/standard/checkpoints/2019-12-03_17-35-30/cnn_epoch21.pth'的报错。那么是因为我fp路径设置问题还是指我需要创建这么一个文件

xxupiano commented 1 year ago

第一个问题

  1. 根据您的提问,您正在使用开箱即用模型 RoBERTa-wwm-ext进行predict,是RoBERTa,没有理解“应该选用”的意思是?您已经选用了RoBERTa
  2. “下载的RE文件夹”是指开箱即用模型 RoBERTa-wwm-ext吗?随便放在哪里都可以,fp指定就可以

第二个问题 fp指定的是re模型放置位置的路径 您目前的fp路径是linux格式,用的/,但是您目前使用的是windows,需要改用\分割路径

debrisvector commented 1 year ago

第一个问题

  1. 根据您的提问,您正在使用开箱即用模型 RoBERTa-wwm-ext进行predict,是RoBERTa,没有理解“应该选用”的意思是?您已经选用了RoBERTa
  2. “下载的RE文件夹”是指开箱即用模型 RoBERTa-wwm-ext吗?随便放在哪里都可以,fp指定就可以

第二个问题 fp指定的是re模型放置位置的路径 您目前的fp路径是linux格式,用的/,但是您目前使用的是windows,需要改用\分割路径

谢谢,上面的内容我理解意思了,所以我将DeepKE(RE), RoBERTa-wwm-ext, Chinese的下载内容解压为re放置于\standard\RE下,如图所示 image 这时我将我的predict.yaml中的fp改为 fp: 'C:\Users\LR\Desktop\DeepKE-main\DeepKE-main\example\re\standard\RE' 或 fp: 'C:\Users\LR\Desktop\DeepKE-main\DeepKE-main\example\re\standard\RE\checkpoints\2019-12-03_17-35-30\cnn_epoch21.pth' 均会在

[2023-06-08 18:49:08,043][__main__][INFO] - model name: lm
[2023-06-08 18:49:08,043][__main__][INFO] - 
 LM(
  (bert): BertModel(
    (embeddings): BertEmbeddings(
      (word_embeddings): Embedding(21128, 768, padding_idx=0)
      (position_embeddings): Embedding(512, 768)
      (token_type_embeddings): Embedding(2, 768)
      (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
      (dropout): Dropout(p=0.1, inplace=False)
    )
    (encoder): BertEncoder(
      (layer): ModuleList(
        (0): BertLayer(
          (attention): BertAttention(
            (self): BertSelfAttention(
              (query): Linear(in_features=768, out_features=768, bias=True)
              (key): Linear(in_features=768, out_features=768, bias=True)
              (value): Linear(in_features=768, out_features=768, bias=True)
              (dropout): Dropout(p=0.1, inplace=False)
            )
            (output): BertSelfOutput(
              (dense): Linear(in_features=768, out_features=768, bias=True)
              (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
              (dropout): Dropout(p=0.1, inplace=False)
            )
          )
          (intermediate): BertIntermediate(
            (dense): Linear(in_features=768, out_features=3072, bias=True)
            (intermediate_act_fn): GELUActivation()
          )
          (output): BertOutput(
            (dense): Linear(in_features=3072, out_features=768, bias=True)
            (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
            (dropout): Dropout(p=0.1, inplace=False)
          )
        )
      )
    )
    (pooler): BertPooler(
      (dense): Linear(in_features=768, out_features=768, bias=True)
      (activation): Tanh()
    )
  )
  (bilstm): RNN(
    (rnn): LSTM(768, 50, batch_first=True, dropout=0.3, bidirectional=True)
  )
  (fc): Linear(in_features=100, out_features=51, bias=True)
  (dropout): Dropout(p=0.3, inplace=False)

成功后报出 PermissionError: [Errno 13] Permission denied: 'C:\\Users\\LR\\Desktop\\DeepKE-main\\DeepKE-main\\example\\re\\standard\\RE' 或者是 FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\LR\\Desktop\\DeepKE-main\\DeepKE-main\\example\\re\\standard\\RE\\checkpoints\\2019-12-03_17-35-30\\cnn_epoch21.pth' 请问下是否是哪里对开箱即用的RE的配置不正确。谢谢了

xxupiano commented 1 year ago

模型是re_bert.pth或re_robert.pth

debrisvector commented 1 year ago

谢谢!