RASA NLU Chi安装
1 RASA NLU简介
自然语言理解(NLU)系统是问答系统、聊天机器人等更高级应用的基石。基本的NLU工具,包括实体识别和意图识别两个任务。
2 准备
2.1 环境说明
1 操作系统 centos 6.5 64 bit
$ rpm -q centos-release
centos-release-6-5.el6.centos.11.2.x86_64
$ lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
2 python版本 3.7.0
$ python3 -V
Python 3.7.0
3 需要的包信息
pip3 list >> ~/piplist.txt
more piplist.txt
|
Package |
Version |
|
—————— |
——— |
|
attrs |
19.3.0 |
|
Automat |
0.8.0 |
|
boto3 |
1.10.28 |
|
botocore |
1.13.28 |
|
certifi |
2019.6.16 |
|
characteristic |
14.3.0 |
|
chardet |
3.0.4 |
|
Click |
7.0 |
|
cloudpickle |
1.2.2 |
|
colorama |
0.4.1 |
|
coloredlogs |
10.0 |
|
constantly |
15.1.0 |
|
cycler |
0.10.0 |
|
Cython |
0.29.14 |
|
docutils |
0.15.2 |
|
future |
0.18.2 |
|
gevent |
1.4.0 |
|
greenlet |
0.4.15 |
|
humanfriendly |
4.18 |
|
hyperlink |
19.0.0 |
|
idna |
2.8 |
|
importlib-metadata |
0.23 |
|
incremental |
17.5.0 |
|
jieba |
0.39 |
|
jmespath |
0.9.4 |
|
joblib |
0.14.0 |
|
jsonschema |
3.2.0 |
|
kiwisolver |
1.1.0 |
|
klein |
19.6.0 |
|
matplotlib |
3.1.2 |
|
mitie |
0.7.36 |
|
more-itertools |
7.2.0 |
|
neobolt |
1.7.13 |
|
neotime |
1.7.4 |
|
numpy |
1.14.3 |
|
packaging |
19.2 |
|
pathlib |
1.0.1 |
|
pip |
10.0.1 |
|
prompt-toolkit |
2.0.9 |
|
py2neo |
4.3.0 |
|
pyahocorasick |
1.4.0 |
|
Pygments |
2.3.1 |
|
PyHamcrest |
1.9.0 |
|
pyparsing |
2.4.5 |
|
pyrsistent |
0.15.6 |
|
python-dateutil |
2.8.0 |
|
pytz |
2019.2 |
|
PyYAML |
5.1.2 |
|
rasa-nlu |
0.12.2 |
|
requests |
2.22.0 |
|
s3transfer |
0.2.1 |
|
scikit-learn |
0.19.2 |
|
scipy |
1.3.3 |
|
setuptools |
39.0.1 |
|
simplejson |
3.17.0 |
|
six |
1.12.0 |
|
sklearn |
0.0 |
|
tqdm |
4.39.0 |
|
Tubes |
0.2.0 |
|
Twisted |
19.10.0 |
|
typing |
3.7.4.1 |
|
urllib3 |
1.24.3 |
|
wcwidth |
0.1.7 |
|
Werkzeug |
0.16.0 |
|
zipp |
0.6.0 |
|
zope.interface |
4.7.1 |
注:
1 也可以通过该项目里的requirements.txt按照需要的包
pip3 install -r requirements.txt
2 建议按照国内的源结合包版本号安装,如:
sudo pip3 install numpy==1.14.3 -i http://mirrors.aliyun.com/pypi/simple/ –trusted-host mirrors.aliyun.com
sudo pip3 install scikit-learn==0.19.2 -i http://mirrors.aliyun.com/pypi/simple/ –trusted-host mirrors.aliyun.com
3 有部分包不是本项目必需的,比如py2neo、neobolt 、neotime等。
3 安装
3.1 下载软件
Github上下载rasa_nlu_chi
下载地址 https://github.com/crownpku/rasa_nlu_chi
或者:
git clone https://github.com/crownpku/rasa_nlu_chi.git
3.2 安装
1 将下载好的压缩文件解压到指定目录下.这里是当前用户主目录的workdata下。
unzip Rasa_NLU_Chi-master.zip
2 进入解压的目录进行安装
cd Rasa_NLU_Chi-master
sudo python3 setup.py install
3.4 安装问题
1启动服务时报错,见红色部分:
python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml –path models
ImportError: cannot import name ‘ssl’ from ‘urllib3.util.ssl_’ (/usr/local/python3/lib/python3.7/site-packages/urllib3-1.23-py3.7.egg/urllib3/util/ssl_.py)
原因是python3编译时未支持ssl,这里需要额外安装ssl并重新编译python3,如下是ssl安装部分
wget http://www.openssl.org/source/openssl-1.1.0e.tar.gz
tar -zxvf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e
sudo ./config shared zlib –prefix=/usr/local/openssl
sudo make
sudo make install
#查看openssl版本
/usr/bin/openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
#建立软链接
ln -s openssl ssl
2源码编译python3
找到python3源码分别对文件Setup.dist、Setup打开ssl方面的注释。这里python3源文件需要按自己的情况修改。
vi ~/software/Python-3.7.0/Modules/Setup.dist
vi ~/software/Python-3.7.0/Modules/Setup
命令行模式下输入:
:set number
直接跳转到209行,打开一下四行注释,见下:
:210

:q!
#回到python3源文件目录
cd ~/software/Python-3.7.0
sudo ./configure –prefix=/usr/local/python3 –with-ssl
sudo make
sudo make install
3如果出现共享库找不到的错误,可以通过软连接的方式解决,然后再重新进行python3的源码编译、安装。
error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
如果出现下图,则证明ssl安装成功

4 Rasa_NLU能正常启动服务,但报如下错误
0.19.2亦可。
|
包名 |
版本号 |
|
numpy |
1.14.3 |
|
scikit-learn |
0.19.2 |
|
scipy |
1.3.3 |
4 使用
1 训练MITIE模型
这里直接使用项目里已经训练好的模型文件,下载地址见下:
链接:https://pan.baidu.com/s/1kNENvlHLYWZIddmtWJ7Pdg 密码:p4vx
2 构建意图识别和实体识别的训练数据。这里使用项目里的,位置见项目主文件下的:
data/examples/rasa/demo-rasa_zh.json
3 训练Rasa NLU模型。这会在Rasa NLU主目录的model文件下生成模型相关的文件
sudo python3 -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml –path models
4 启动后台Rasa NLU服务
python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml –path models
5 访问验证
#查看服务状态以及项目信息
sudo curl ‘http://localhost:5000/status’

#请求并返回意图识别
$ sudo curl -XPOST localhost:5000/parse -d ‘{“q”:”我发烧了该吃什药?”, “project”: “default”, “model”: “model_-“}’ | python3 -mjson.tool

sudo curl -XPOST localhost:5000/parse -d ‘{“q”:”哪家的湘菜好吃?”, “project”: “default”, “model”: “model_-“}’ | python3 -mjson.tool

5 参考
1 ssl安装配置:
centos6-openssl1.1.0e安装_dodowolf_51CTO博客
CentOS6.5 安装openssl_weixin_的博客-CSDN博客
2 share package缺少
解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误 – 我是一个NLPer哦啦啦 – 博客园
3 openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误
解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误 – 我是一个NLPer哦啦啦 – 博客园
4 Rasa NLU 安装、使用
RASA_NLU 入门_bailixuance的博客-CSDN博客
搭建一个中文rasa-nlu踩过的坑_Lorenly的博客-CSDN博客
Rasa 安装过程中的坑_u0的博客-CSDN博客_python 安装rasa
用Rasa NLU构建自己的中文NLU系统
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/231932.html原文链接:https://javaforall.net
