window安装bert-as-service

本文介绍了如何通过Anaconda3安装、使用TensorFlow和BERT Serving,下载预训练模型chinese_L-12_H-768_A-12,并详细步骤演示了模型启动、测试及编码操作。

一:Anaconda3安装

下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

选择anaconda 3.5.2 对应的python版本是python3.6
依次安装,问题Baidu

二:安装

pip install --user tensorflow==1.10.0	-i http://pypi.douban.com/simple --trusted-host pypi.douban.com

pip install bert-serving-server -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

pip install bert-serving-client -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

三:下载chinese_L-12_H-768_A-12.zip

1种:

链接: https://pan.baidu.com/s/1CdyHz-Tv3l_72ZjR3Sv8PQ 提取码: ambr

2种:

https://storage.googleapis.com/bert_models/2018_11_03/chinese_L-12_H-768_A-12.zip
外网速度快

四:启动

cd E:/bert 
解压 chinese_L-12_H-768_A-12.zip

bert-serving-start -model_dir chinese_L-12_H-768_A-12/ -num_worker=1

五:测试

python
from bert_serving.client import BertClient
bc = BertClient(ip='localhost',check_version=False,port=5555, port_out=5556, check_length=False,timeout=10000)
bc.encode(['我爱你', '你爱我'])

六:结果

array([[ 0.37820056,  0.112949  , -0.21374373, ..., -0.15088102,
         0.23272948, -0.47062612],
       [ 0.3381107 ,  0.06517199, -0.15245143, ..., -0.16170141,
         0.01764984, -0.34359008]], dtype=float32)
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值