Interactive Learning

Interactive Learning

This page shows how to use interactive learning on the command line.

In interactive learning mode, you provide feedback to your bot while you talk to it. This is a powerful way to explore what your bot can do, and the easiest way to fix any mistakes it makes. One advantage of machine learning-based dialogue is that when your bot doesn’t know how to do something yet, you can just teach it! Some people call this Software 2.0.

Note

Rasa X provides a UI for interactive learning, and you can use any user conversation as a starting point. See Talking to Your Assistant in the Rasa X docs.

Running Interactive Learning

Run the following command to start interactive learning:

rasa run actions --actions actions&

rasa interactive \
  -m models/20190515-135859.tar.gz \
  --endpoints endpoints.yml

The first command starts the action server (see Custom Actions).

The second command starts interactive learning mode.

In interactive mode, Rasa will ask you to confirm every prediction made by NLU and Core before proceeding.

Bot loaded. Type a message and press enter (use '/stop' to exit).

? Next user input:  hello

? Is the NLU classification for 'hello' with intent 'hello' correct?  Yes

------
Chat History

#    Bot                        You
────────────────────────────────────────────
 1    action_listen
────────────────────────────────────────────
 2                                    hello
                         intent: hello 1.00
------

? The bot wants to run 'utter_greet', correct?  (Y/n)

The chat history and slot values are printed to the screen, which should be all the information your need to decide what the correct next action is.

Providing feedback on errors

For this example we are going to use the concertbot example, so make sure you have the domain & data for it. You can download the data from our github repo.

If you ask /search_concerts, the bot should suggest action_search_concerts and then action_listen. Now let’s enter /compare_reviews as the next user message.

------
Chat History

#    Bot                                           You
───────────────────────────────────────────────────────────────
 1    action_listen
───────────────────────────────────────────────────────────────
 2                                            /search_concerts
                                  intent: search_concerts 1.00
───────────────────────────────────────────────────────────────
 3    action_search_concerts 0.72
      action_listen 0.78
───────────────────────────────────────────────────────────────
 4                                            /compare_reviews
                                  intent: compare_reviews 1.00

Current slots:
  concerts: None, venues: None
------
? The bot wants to run 'action_show_concert_reviews', correct?  No

Now we type n, because it chose the wrong action, and we get a new prompt asking for the correct one. The bot will provide you with exit options. You can write your newly-created stories and NLU data to files. You can also go back a step if you made a mistake when providing feedback.

Visualization of conversations

During the interactive learning, Rasa will plot the current conversation and a few similar conversations from the training data to help you keep track of where you are.

You can view the visualization at http://localhost:5005/visualization.html as soon as you’ve started interactive learning.

Interactive Learning with Forms

If you’re using a FormAction, there are some additional things to keep in mind when using interactive learning.

The form: prefix

The form logic is described by your FormAction class, and not by the stories. The machine learning policies should not have to learn this behavior.

* request_restaurant
    - restaurant_form
    - form{"name": "restaurant_form"}
    - slot{"requested_slot": "cuisine"}
* form: inform{"cuisine": "mexican"}
    - slot{"cuisine": "mexican"}
    - form: restaurant_form
    - slot{"cuisine": "mexican"}
    - slot{"requested_slot": "num_people"}
* form: inform{"number": "2"}
    - form: restaurant_form
    - slot{"num_people": "2"}
    - form{"name": null}
    - slot{"requested_slot": null}
    - utter_slots_values

Input validation

Every time the user responds with something other than the requested slot or any of the required slots, you will be asked whether you want the form action to try and extract a slot from the user’s message when returning to the form.