A serving service for bert-multitask-learning
pip install bert-multitask-server
pip install bert-multitask-client
-
Train and export model.
A typical trained checkpoint dir looks like below.
bert_serving_ckpt/ ├── *_label_encoder.pkl ├── bert_config.json ├── export_model ├── params.json └── vocab.txt
-
Start server using CLI
bert-multitask-serving-start -model_dir ~/CWS_NER_POS_ckpt/ -num_worker=4 -problem "CWS|NER|POS"
-
Use Client to Get Prediction
from bert_serving.client import BertClient bc = BertClient() bc.encode(['我爱北京天安门'])
一个部署Bert多任务学习的服务
pip install bert-multitask-server
pip install bert-multitask-client
-
训练模型并导出模型.
导出后的模型目录应该有以下文件
bert_serving_ckpt/ ├── *_label_encoder.pkl ├── bert_config.json ├── export_model ├── params.json └── vocab.txt
-
用CLI启动服务
bert-multitask-serving-start -model_dir models/ -num_worker=4 -problem "fake_problem"
-
用客户端获取预测结果
from bert_serving.client import BertClient bc = BertClient() bc.encode(['我爱北京天安门'])