1. 首先确保Python >= 3.5 with Tensorflow >= 1.10
检查Tensorflow的版本:
python
import tensorflow as tf
tf.__version__
2. 下载bert-serving-start 这个命令的service和client:
pip install --upgrade pip
pip install bert-serving-server==1.6.0 # server
pip install bert-serving-client==1.6.0 # client, independent of `bert-serving-server`
3.下载一个Pre-trained BERT Model,再启动一个BERT服务
下载地址: https://github.com/hanxiao/bert-as-service
下载的压缩文件进行解压,可以看到文件里有五个文件,其中bert_model.ckpt开头的文件是负责模型变量载入的,而vocab.txt是训练时中文文本采用的字典,最后bert_config.json是BERT在训练时,可选调整的一些参数。
bert-serving-start -model_dir /tmp/english_L-1