Stories Flashcards
What are stories?
Rasa stories are a form of training data used to train the Rasa’s dialogue management models.
A story is a representation of a conversation between a user and an AI assistant, converted into a specific format where user inputs are expressed as corresponding intents (and entities where necessary) while the responses of an assistant are expressed as corresponding action names.
A training example for the Rasa Core dialogue system is called a story.
What is the format of stories?
Here’s an example of a dialogue in the Rasa story format: """ ## greet + location/price + cuisine + num people * greet - action_ask_howcanhelp * inform{"location": "rome", "price": "cheap"} - action_on_it - action_ask_cuisine * inform{"cuisine": "spanish"} - action_ask_numpeople * inform{"people": "six"} - action_ack_dosearch """
What makes up a story?
- A story starts with a name preceded by two hashes ## story_03248462. You can call the story anything you like, but it can be very useful for debugging to give them descriptive names!
- The end of a story is denoted by a newline, and then a new story starts again with ##.
- Messages sent by the user are shown as lines starting with * in the format intent{“entity1”: “value”, “entity2”: “value”}.
- Actions executed by the bot are shown as lines starting with - and contain the name of the action.
- Events returned by an action are on lines immediately after that action. For example, if an action returns a SlotSet event, this is shown as slot{“slot_name”: “value”}.
What kind of actions are used in stories?
While writing stories, you will encounter two types of actions: utterances and custom actions.
Utterances are hardcoded messages that a bot can respond with.
Custom actions, on the other hand, involve custom code being executed.
How to define custom actions in a story?
For custom actions, the action name is the string you choose to return from the name method of the custom action class.
Although there is no restriction on naming your custom actions (unlike utterances), the best practice here is to prefix the name with action_.
How do you define slot events?
Slot Events
Slot events are written as - slot{“slot_name”: “value”}.
If this slot is set inside a custom action, it is written on the line immediately following the custom action event.
If your custom action resets a slot value to None, the corresponding event for that would be -slot{“slot_name”: null}.
How to write Form events?
Form Events
There are three kinds of events that need to be kept in mind while dealing with forms in stories.
- A form action event (e.g. - restaurant_form) is used in the beginning when first starting a form, and also while resuming the form action when the form is already active.
- A form activation event (e.g. - form{“name”: “restaurant_form”}) is used right after the first form action event.
- A form deactivation event (e.g. - form{“name”: null}), which is used to deactivate the form.