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
1
启动rasa_nlu的后台服务:

python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml –path models
1
打开一个新的terminal,我们现在就可以使用curl命令获取结果了, 尝试下面命令均不成功:

curl -XPOST localhost:5000/parse -d ‘{“q”:”我发烧了该吃什么药?”, “project”: “rasa_nlu_test”, “model”: “models\default\model_20210617-142700”}’ | python -mjson.tool
1
curl -XPOST localhost:5000/parse -d ‘{“q”:”我发烧了该吃什么药?”, “project”: “”, “model”: “models\default\model_20210617-142700”}’ | python -mjson.tool
1
curl -XPOST localhost:5000/parse -d ‘{“q”:”我发烧了该吃什么药?”, “model”: “models\default\model_20210617-142700”}’ | python -mjson.tool
1
curl -XPOST localhost:5000/parse -d ‘{“q”:”我发烧了该吃什么药?”}’ | python -mjson.tool
1
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=你好
1
报错:

尝试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
1
2
3
4
重新装这四个的最小匹配版本

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
————————————————
版权声明:本文为CSDN博主「Silber 甜」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42639575/article/details/117988319

Share