最近在做一个问答系统,大概思路是先将问题encode为一个向量,然后在问题库中进行比较,选取最接近的问题,将其答案返回给客户端
模型中主要的部分在于基于BERT模型,需要将问题先embedding,用到了xiaohan博士的bert as service项目,这个项目目前可以直接pip install bert-serving-service 安装,在win10上可以正常使用,在结合aiohttp作为服务端后需要将其放在服务器上
目前环境配置如下,
Description: Ubuntu 17.10
Python 3.6.3 (default, Oct 3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.import tensorflow as tf
tf.version
'1.8.0'但是发现git clone项目后报错bert-serving-start: command not found...
发现没有bert-serving-start 这个命令,于是搜一下...
发现这个命令在/home/liujiefei/.local/bin/bert-serving-start 这个地方 很奇怪
然后继续执行命令,
发现tf版本要求1.10,这里只有1.8,所以再升级一下,结束并查看
注意一般情况下可以直接bert-serving-start -model_dir /home/liujiefei/pythonworkspace/06bertserver/02bertapp/chinese_L-12_H-768_A-12 -num_worker=4 启动服务
但是有时候需要用python3来启动服务
python3 bert-serving-start -model_dir /home/liujiefei/pythonworkspace/06bertserver/02bertapp/chinese_L-12_H-768_A-12 -num_worker=4
到这里,我的问题以经解决了,xiaohan的github上的issus没有出现这种情况,看到有人在centos上这样解决的,不知道是怎么处理的
这个项目最初就是mac开发的,后来为了兼容windows操作系统,现在开发到bert-serving-service bert-serving-client直接pip安装就可以在win10运行,可能是ubuntu上出的问题吧,
python start-bert-as-service.py -model_dir /scratch2/NAACL2018/test/english_L-12_H-768_A-12/ -num_worker=4
/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters