BERT:如何在BioBERT中使用bert-as-service?

时间:2019-09-22 13:21:15

标签: python-3.x nlp bert-language-model

bioBERT抛出下面提到的错误:

但是我可以使用以下语句运行BERT的其他BERT版本uncased_L-12_H-768_A-12sciBERT

bert-serving-start -model_dir C:\Users\xyz\Desktop\data\dataset\uncased_L-12_H-768_A-12 -num_worker=1

sciBERT

bert-serving-start -model_dir C:\Users\xyz\Desktop\data\dataset\bert_models\scibert_scivocab_uncased -num_worker=1

但相同的语句不适用于bioBERT

bioBERT

bert-serving-start -model_dir C:\Users\xyz\Desktop\data\dataset\bert_models\biobert_v1.1_pubmed -num_worker=1

错误

               ARG   VALUE
         ckpt_name = bert_model.ckpt
       config_name = bert_config.json
              cors = *
               cpu = False
        device_map = []
     do_lower_case = True
fixed_embed_length = False
                fp16 = False
 gpu_memory_fraction = 0.5
       graph_tmp_dir = None
    http_max_connect = 10
           http_port = None
        mask_cls_sep = False
      max_batch_size = 256
         max_seq_len = 25
           model_dir = C:\Users\xyz\Desktop\data\dataset\bert_models\biobert_v1.1_pubmed
    no_special_token = False
          num_worker = 1
       pooling_layer = [-2]
    pooling_strategy = REDUCE_MEAN
                port = 5555
            port_out = 5556
       prefetch_size = 10
 priority_batch_size = 16
show_tokens_to_client = False
     tuned_model_dir = None
             verbose = False
                 xla = False

I:[35mVENTILATOR[0m:freeze, optimize and export graph, could take a while...
WARNING: Logging before flag parsing goes to stderr.
W0922 18:38:28.060485  2868 deprecation_wrapper.py:119] From c:\programdata\anaconda3\envs\bert_x\lib\site-packages\bert_serving\server\helper.py:184: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

W0922 18:38:28.062525  2868 deprecation_wrapper.py:119] From c:\programdata\anaconda3\envs\bert_x\lib\site-packages\bert_serving\server\helper.py:184: The name tf.logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead.

I:[36mGRAPHOPT[0m:model config: C:\Users\xyz\Desktop\data\dataset\bert_models\biobert_v1.1_pubmed\bert_config.json
I:[36mGRAPHOPT[0m:checkpoint: C:\Users\xyz\Desktop\data\dataset\bert_models\biobert_v1.1_pubmed\bert_model.ckpt
E:[36mGRAPHOPT[0m:fail to optimize the graph!
Traceback (most recent call last):
  File "c:\programdata\anaconda3\envs\bert_x\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\envs\bert_x\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\envs\bert_x\Scripts\bert-serving-start.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\envs\bert_x\lib\site-packages\bert_serving\server\cli\__init__.py", line 4, in main
    with BertServer(get_run_args()) as server:
  File "c:\programdata\anaconda3\envs\bert_x\lib\site-packages\bert_serving\server\__init__.py", line 71, in __init__
    self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,))
TypeError: cannot unpack non-iterable NoneType object

1 个答案:

答案 0 :(得分:1)

我将BioBert文件重命名为与原始BERT文件相同,并且可以正常工作。