美文网首页
安装rasa

安装rasa

作者: 不爱吃饭的小孩怎么办 | 来源:发表于2019-11-18 10:42 被阅读0次

官方推荐安装方式(安装rasa和rasa X):
建议先建立nlp单独的空间:conda create -n nlp python=3.6

pip install rasa-x --extra-index-url https://pypi.rasa.com/simple

如果您不想使用Rasa X,请改为运行

pip install rasa

======================
执行rasa init 完成项目初始化

(nlp) spring@ubuntu18:~/rasa-x/test$ rasa init
Welcome to Rasa! 🤖

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.
Now let's start! 👇🏽

? Please enter a path where the project will be created [default: current direct
ory] .                                                                          
Created project directory at '/home/spring/rasa-x/test'.
Finished creating project structure.
Training an initial model...
Training Core model...
2019-11-18 10:59:24 INFO     absl  - Entry Point [tensor2tensor.envs.tic_tac_toe_env:TicTacToeEnv] registered with id [T2TEnv-TicTacToeEnv-v0]
Processed Story Blocks: 100%|█████| 5/5 [00:00<00:00, 6078.70it/s, # trackers=1]
Processed Story Blocks: 100%|█████| 5/5 [00:00<00:00, 2239.83it/s, # trackers=5]
Processed Story Blocks: 100%|█████| 5/5 [00:00<00:00, 563.08it/s, # trackers=20]
Processed Story Blocks: 100%|█████| 5/5 [00:00<00:00, 384.06it/s, # trackers=24]
Processed trackers: 100%|█████████| 5/5 [00:00<00:00, 3928.72it/s, # actions=16]
Processed actions: 16it [00:00, 16178.61it/s, # examples=16]
Processed trackers: 100%|████| 231/231 [00:00<00:00, 1629.75it/s, # actions=126]
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
masking (Masking)            (None, 5, 21)             0         
_________________________________________________________________
lstm (LSTM)                  (None, 32)                6912      
_________________________________________________________________
dense (Dense)                (None, 14)                462       
_________________________________________________________________
activation (Activation)      (None, 14)                0         
=================================================================
Total params: 7,374
Trainable params: 7,374
Non-trainable params: 0
_________________________________________________________________
2019-11-18 10:59:25 INFO     rasa.core.policies.keras_policy  - Fitting model with 126 total samples and a validation split of 0.1
Train on 126 samples
Epoch 1/100
126/126 [==============================] - 0s 2ms/sample - loss: 2.6342 - acc: 0.0873
Epoch 2/100
126/126 [==============================] - 0s 85us/sample - loss: 2.5590 - acc: 0.2460
Epoch 3/100
126/126 [==============================] - 0s 79us/sample - loss: 2.5047 - acc: 0.3333
Epoch 4/100
此处省略N行......
Epoch 98/100
126/126 [==============================] - 0s 82us/sample - loss: 0.3694 - acc: 0.9683
Epoch 99/100
126/126 [==============================] - 0s 77us/sample - loss: 0.3377 - acc: 0.9921
Epoch 100/100
126/126 [==============================] - 0s 81us/sample - loss: 0.3711 - acc: 0.9603
2019-11-18 10:59:27 INFO     rasa.core.policies.keras_policy  - Done fitting keras policy model
2019-11-18 10:59:27 INFO     rasa.core.agent  - Persisted model to '/tmp/tmpp8hdx00z/core'
Core model training completed.
Training NLU model...
2019-11-18 10:59:27 INFO     rasa.nlu.training_data.training_data  - Training data stats: 
    - intent examples: 43 (7 distinct intents)
    - Found intents: 'mood_unhappy', 'deny', 'mood_great', 'greet', 'affirm', 'bot_challenge', 'goodbye'
    - Number of response examples: 0 (0 distinct response)
    - entity examples: 0 (0 distinct entities)
    - found entities: 

2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component WhitespaceTokenizer
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component RegexFeaturizer
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component CRFEntityExtractor
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component EntitySynonymMapper
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component CountVectorsFeaturizer
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component CountVectorsFeaturizer
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:27 INFO     rasa.nlu.model  - Starting to train component EmbeddingIntentClassifier
Epochs: 100%|█████████| 300/300 [00:01<00:00, 151.53it/s, loss=0.489, acc=1.000]
2019-11-18 10:59:30 INFO     rasa.utils.train_utils  - Finished training embedding policy, train loss=0.489, train accuracy=1.000
2019-11-18 10:59:30 INFO     rasa.nlu.model  - Finished training component.
2019-11-18 10:59:30 INFO     rasa.nlu.model  - Successfully saved model into '/tmp/tmpp8hdx00z/nlu'
NLU model training completed.
Your Rasa model is trained and saved at '/home/spring/rasa-x/test/models/20191118-105922.tar.gz'.
? Do you want to speak to the trained assistant on the command line? 🤖  Yes    
2019-11-18 11:00:07 INFO     root  - Connecting to channel 'cmdline' which was specified by the '--connector' argument. Any other channels will be ignored. To connect to all given channels, omit the '--connector' argument.
2019-11-18 11:00:07 INFO     root  - Starting Rasa server on http://localhost:5005

Bot loaded. Type a message and press enter (use '/stop' to exit): 
Your input ->                                                                   
I am a bot, powered by Rasa.
Your input ->  hello                                                            
Hey! How are you?
Your input ->  fine thank you                                                   
Great, carry on!
Your input ->  what's the weather today                                         
Hey! How are you?
Your input ->  are you kidding?                                                 
Great, carry on!
Your input ->  你在说什么                                                       
Bye
Your input ->  test                                                             
Bye
Your input ->  go                                                               
I am a bot, powered by Rasa.
Your input ->  rasa                                                             
Hey! How are you?
Your input ->  go                                                               
Great, carry on!
Your input ->  what's the balance of my account                                 
Bye
Your input ->  stop                                                             
Hey! How are you?
Your input ->  /stop                                                            
2019-11-18 11:01:36 INFO     root  - Killing Sanic server now.

一个空白项目会有以下文件:

init.py 一个帮助python找到你动作的空文件
actions.py 自定义操作的代码
config.yml '' 配置NLU和Core型号
credentials.yml 连接其他服务的详细信息
data/nlu.md '
' 你的NLU训练数据
data/stories.md '' 你的故事
domain.yml '
' 你助手的域名
endpoints.yml 连接到fb messenger等频道的详细信息
models/<timestamp>.tar.gz 你的初始模型

如何理解这些文件,已经如何调试,请查看
https://blog.csdn.net/daiyuxiong/article/details/102687457

下面链接写的比较详细
https://www.cnblogs.com/huangqihui/p/10978837.html

如何训练?
1.先进入nlp环境,并且进入到项目目录:
2.source activate nlp
3.rasa train

如何测试?
rasa shell
rasa test

相关文章

网友评论

      本文标题:安装rasa

      本文链接:https://www.haomeiwen.com/subject/vjkvictx.html