rasa_nlu_chi 测试不成功 “error“: “y should be a 1d array, got an array of shape (1, 5) instead.

rasa_nlu_chi原始git链接:
https://github.com/crownpku/rasa_nlu_chi

rasa_nlu_chi实现博客链接

实现过程中有问题解决方法的博客:
https://ptorch.com/news/243.html

大牛写的rasa-UI链接:
https://github.com/paschmann/rasa-ui
UI安装教程:
https://blog.csdn.net/u011244708/article/details/82924823?spm=1001.2014.3001.5501
UI与nlu_chi整合问题:
https://ask.csdn.net/questions/3370686

问题贴:
https://github.com/crownpku/Rasa_NLU_Chi/issues


训练Rasa NLU的模型

python -m rasa_nlu.train -c sample_configs/config_jieba_mitie_sklearn.yml --data data/examples/rasa/demo-rasa_zh.json --path models

启动rasa_nlu的后台服务:

python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml --path models

打开一个新的terminal,我们现在就可以使用curl命令获取结果了, 尝试下面命令均不成功:

curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "project": "rasa_nlu_test", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "project": "", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "model": "models\default\model_20210617-142700"}' | python -mjson.tool
curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?"}' | python -mjson.tool

curl -XPOST localhost:5000/parse -d ‘{“q”:“我发烧了该吃什么药?”, “model”: “models\default\model_20210617-111551”}’ | python -mjson.tool

E:\1rasa\code\Rasa_NLU_Chi\Rasa_NLU_Chi-master\models\default\model_20210617-111551

测试命令始终报错
在这里插入图片描述
更换测试方式:
打开浏览器,地址中输入

http://localhost:5000/parse?q=你好

报错:
在这里插入图片描述

尝试scikit-learn降级:
https://github.com/RasaHQ/rasa/issues/1436

报错:

rasa 2.5.0 requires networkx<2.6,>=2.4, but you have networkx 2.1 which is incompatible.
rasa 2.5.0 requires packaging<21.0,>=20.0, but you have packaging 17.1 which is incompatible.
rasa 2.5.0 requires pykwalify<1.9,>=1.7, but you have pykwalify 1.6.0 which is incompatible.
rasa 2.5.0 requires scikit-learn<0.25,>=0.22, but

重新装这四个的最小匹配版本

rasa-nlu 0.14.4

rasa 2.5.0 requires cloudpickle<1.7,>=1.2, but you have cloudpickle 0.6.1 which is incompatible.
rasa 2.5.0 requires jsonschema<3.3,>=3.2, but you have jsonschema 2.6.0 which is incompatible.
rasa 2.5.0 requires matplotlib<3.4,>=3.1, but you have matplotlib 2.2.5 which is incompatible.
rasa 2.5.0 requires packaging<21.0,>=20.0, but you have packaging 18.0 which is incompatible.
rasa 2.5.0 requires ruamel.yaml<0.17.0,>=0.16.5, but you have ruamel-yaml 0.15.100 which is incompatible.
rasa 2.5.0 requires scikit-learn<0.25,>=0.22,

问题贴:按照教程发送请求后,返回"error": “y should be a 1d array, got an array of shape (1, 5) instead.”

实测成功!!热泪!!

找到sklearn_intent_classifier.py
C:\Users\Administrator\Desktop\Rasa_NLU_Chi\rasa_nlu\classifiers\sklearn_intent_classifier.py
return self.le.inverse_transform(y) 修改为 return
self.le.inverse_transform(np.squeeze(y))

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

问题:curl测试仍然不成功
尝试方法1

可以参考train.py ,def create_argument_parser():
parser.add_argument(’–project’, python -m rasa_nlu.train -c
sample_configs/config_jieba_mitie_sklearn.yml --data
data/examples/rasa/demo-rasa_zh.json --path rasa_nlu_test --project
rasa_nlu_test

不成功,待续……

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值