RASA NLU Chi安装
1 RASA NLU簡介... 2
2 準備... 2
2.1 環境說明... 2
3 安裝... 4
3.1 下載軟件... 4
3.2 安裝... 4
3.4 安裝問題... 5
4 使用... 6
5 參考... 8
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?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能正常啟動服務,但報如下錯誤
“error”: “bad input shape (1, 5)”
這是因為scikit-learn版本較高,安裝0.19.1即可。這里驗證
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_20191127-232941"}' | python3 -mjson.tool
sudo curl -XPOST localhost:5000/parse -d '{"q":"哪家的湘菜好吃?", "project": "default", "model": "model_20191127-232941"}' | python3 -mjson.tool
5?參考
1 ssl安裝配置:
centos6-openssl1.1.0e安裝_dodowolf_51CTO博客
CentOS6.5 安裝openssl_weixin_33862041的博客-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 安裝過程中的坑_u011244708的博客-CSDN博客_python 安裝rasa
用Rasa NLU構建自己的中文NLU系統
總結
以上是生活随笔為你收集整理的RASA NLU Chi安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行卡流水多少算异常
- 下一篇: 微粒贷多久评估一次