/Rasa-Chatbot

Chatbot Dev

Primary LanguagePython

Chatbot DD

1. Create NLU data

1.1 Edit data in dataset/data.yaml 1.2 Export data with command

python scripts/export_data.py

1.3 Edit data/stories.yml (optional)

2. Train rasa (NLU & Core)

2.1 Train with fasttext pipeline (recommended)

rasa train --config config/fasttext.yml

2.2 Train with other pipline

rasa train --config {config_file}

2.3 Train nlu only

rasa train nlu --config {config_file}

2.4 Test your assistant

rasa shell
# or
rasa shell nlu

3. Evaluate NLU

Example: 5 folds CV

rasa test nlu --config config/fasttext.yml --cross-validation --runs 5 --fold 5 --out results/fasttext

or run all configs, see test_models.bat

rasa test nlu --config config/custom.yml --cross-validation --runs 5 --fold 5 --out results/vectorcount
rasa test nlu --config config/fasttext.yml --cross-validation --runs 5 --fold 5 --out results/fasttext
rasa test nlu --config config/bert.yml --cross-validation --runs 5 --fold 5 --out results/bert
rasa test nlu --config config/phobert_base.yml --cross-validation --runs 5 --fold 5 --out results/phobert_base
rasa test nlu --config config/phobert_large.yml --cross-validation --runs 5 --fold 5 --out results/phobert_large

Prettify and display test result from results/ folder

python eval.py

# Sample output
------
Model               |Acc       |Precision      |Recall 
------------------------------------------------------------
fasttext            |     0.869|          0.871|   0.89     
vectorcount         |     0.833|          0.856|  0.819     
bert                |      0.77|           0.81|  0.781     
phobert_base        |     0.705|          0.754|  0.681     
phobert_large       |      0.63|          0.603|  0.612 

3. Install rasa x local mode

3.1 Upgrade pip

pip install --upgrade pip

3.2 Install rasa x

pip3 install rasa-x==0.39.3 --extra-index-url https://pypi.rasa.com/simple --use-deprecated=legacy-resolver

4. Deploy rasa x

  • Required trained model with {config_file} before
rasa x --config {config_file}

# Sample output
Starting Rasa X in local mode... >
...
The server is running at http://localhost:5002/login?username=me&password=xxxxxxxxx

This should open a browser tab to http://localhost:5002 and login automatically

5. Share rasa x

  • Install ngrok, run and command
ngrok http 5002

# Sample output
Session Status                online
Session Expires               7 hours, 59 minutes
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4041
Forwarding                    http://831897ef2f98.ngrok.io -> http://localhost:5002
Forwarding                    https://831897ef2f98.ngrok.io -> http://localhost:5002