To Top
首页 > 常用平台 > 正文

bert as service

标签:bert as service


目录

https://github.com/hanxiao/bert-as-service

官网:https://bert-as-service.readthedocs.io/en/latest/

基本使用

安装:

pip install -U bert-serving-server bert-serving-client

要求:

  • server的py要>=3.5,tf要>=1.10
  • client可以是py2或者py3

另外需要把预训练好的模型下下来~

启动server

$workspace/bin/python3.6 \
        $workspace/bin/bert-serving-start \
        -model_dir=$workspace/../chinese_L-12_H-768_A-12/ \
        -num_worker=4

启动client

from bert_serving.client import BertClient
remote_ip = 'xx.xx.xx.xx'
bc = BertClient(ip=remote_ip)  
print(bc.encode(['First do it', 'then do it right', 'then do it better']))

原创文章,转载请注明出处!
本文链接:http://daiwk.github.io/posts/platform-bert-as-service.html
上篇: Pointer Networks和组合优化
下篇: drn

comment here..