用 RASA 实现 RASA Bot 后端。 能够回答关于 RASA 的问题,以及一些例子。
欢迎大家多提 RASA 相关的问题,或者想看的示例,我会补充在这里。
前端地址: 这里
- [2021-08-04] 增加 onnx + 量化(用于提高特征提取的速度)的
feature提取组件 # 一些注意事项 - [2021-06-24] 增加知图谱的接入(放在GRAPH分支了)
- [2021-06-01] 增加
文本纠错 pipeline(由于demo较慢,默认未开启,如何开启?) - [2021-05-20]
AlbertFeaturizer(在dev分支) - [2021-05-13] 增加按钮 demo
- [2021-05-11] 支持查看
BTC行情 - [2021-05-08] 支持
吸猫\狗\狐狸。支持 根据图片搜索动漫出处。 - [2021-05-06] 支持
找饭店demo。 - [2021-04-13] 实现追问demo,实现细节。
请参见: 问题列举
分词使用的 bert, 自定义了 tokenizers
由于使用了 bert_chinese, 所以 需要下载 bert_chinese 模型。
并放到 pre_models 文件夹中,重命名为 tf_model.h5
命令执行:
curl -L https://www.flyai.com/m/bert-base-chinese-tf_model.h5 -o pre_models/tf_model.h5
rasa trainrun.py # 相当于运行 rasa run
train.py # == rasa train
run_action_server.py # == rasa run actions
load_model.py # 直接加载并运行模型,与 server 无关。(需要先训练好一个模型)
back_translation.py # 回译脚本
# 使用方式
python back_translation.py 需要回译的文本config 更改为:
- name: compoments.nlu.featurizer.lm_featurizer.OnnxLanguageModelFeaturizer
cache_dir: ./tmp
model_name: bert
model_weights: pre_models
onnx: false # 是否开启 onnx
quantize: true # 是否使用量化下载 torch 的模型
curl -L https://www.flyai.com/m/bert-base-chinese-pytorch_model.bin -o pre_models/pytorch_model.binpip install torch==1.9.0 transformers==4.8.2 onnx==1.9.0 onnxruntime==1.8.0 onnxruntime-tools==1.7.0 psutil==5.8.0- 速度能提升多少, 可以参考这篇文章
- 量化后 速度有额外提升,但是效果可能会变差,需要根据语料调整
- 如何测试效果并查看结果
rasa train nlu && rasa test nlu
cat results/intent_errors.json- 为什么没有用
tensorflow用来做onnx尝试多次,都失败了,暂时未找到解决办法(输入的纬度不匹配),如果有人成功了,可以告诉我!!感谢!!!🙏
git clone https://github.com/Dustyposa/rasa_ch_faq.git
cd rasa_ch_faqpip install -r requirements.txt
curl -L https://www.flyai.com/m/bert-base-chinese-tf_model.h5 -o pre_models/tf_model.h5
rasa trainps: 注意 python 版本 37+
rasa train需要开两个 shell/iterm
第一个:
rasa shell第二个:
rasa run actions然后就可以在第一个 shell 窗口对话了
这个是干啥的?如果第一个你已经会了,我们加点前端展示的,效果参看这里
git clone -#-depth 1 https://github.com/Dustyposa/rasa_bot_front
cd rasa_bot_front参照文档
同样是两个 shell/iterm,第一个命令稍有不同:
rasa run --cors "*"第二个:
rasa run actions



