BERT:如何在 BioBERT 中使用 bert-as-service?
Posted
技术标签:
【中文标题】BERT:如何在 BioBERT 中使用 bert-as-service?【英文标题】:BERT: How to use bert-as-service with BioBERT? 【发布时间】:2020-01-22 18:24:35 【问题描述】:bioBERT
正在抛出下面提到的错误:
但我可以使用以下语句运行其他 BERT 版本 uncased_L-12_H-768_A-12
和 sciBERT
的 BERT:
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】:我将 BioBert 文件重命名为与原始 BERT 文件相同,并且可以正常工作。
【讨论】:
谢谢你,我最近想通了以上是关于BERT:如何在 BioBERT 中使用 bert-as-service?的主要内容,如果未能解决你的问题,请参考以下文章