A beginners’ guide to Rasa Open Source
Let’s start with the basics:
Rasa Open Source is a framework for Natural Language Understanding (NLU), dialogue management, and integrations. Rasa also provides RasaX, which is a toolset (GUI) to improve a bot created with Rasa.
This is a continuously growing framework for the development of dialogue systems and no wonder there is the need for some help when you start working with Rasa. I got your back though! Here is a comprehensive cheatsheet for all the main commands and functionalities you need!
What you need to know
Files
domain.yml → the “universe” of the bot, i.e., it has a list of all the intents, responses, custom actions, slots, and forms. Don’t forget that every time you add a new intent or entity you have to also add it in your domain
data/nlu.yml → the training data for the natural language understanding component. You add your intents with annotated entities if any, as well as synonyms.
data/stories.yml → the training data for the core-dialogue management component. You add sample dialogue flows, in order for your bot to learn how to interact with users after recognizing the intent
data/rules.yml → part of the training data for the core-dialogue management component. You add snippets of conversations that should always follow the same flow
config.yml → the configuration has the pipeline of the bot, it has all the training information and the policies that should be followed
endpoints.yml → details for connecting to channels
credentials.yml → details for connecting to other services. Rasa already has written services, e.g., Facebook, Slack, so if you want to use them you just comment out the lines
actions/actions.py → the custom actions are your code, where you can call APIs, connect with database, validate slots, etc.
tests/ → the end-to-end tests of rasa. All files in this folder have to start with test_conversation to be considered for the testing
models/ → where your models are stored. Once you train a model this folder is automatically created
results/ → where the results of your tests are stored. Once you test a model this folder is automatically created and the files are automatically updated after every test
Trending Bot Articles:
2. Automated vs Live Chats: What will the Future of Customer Service Look Like?
4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?
Conversation Driven Development (CDD)
Rasa promotes Conversation-Driven Development. In other words, Rasa developers believe that real-world data and conversations make dialogue systems better. The steps are simple:
1. Share your assistant with users as soon as possible
2. Review conversations on a regular basis
3. Annotate messages and use them as NLU training data
4. Test that your assistant always behaves as you expect
5. Track when your assistant fails and measure its performance over time
6. Fix how your assistant handles unsuccessful conversations
CDD is part of the philosophy of Rasa, so there are many functionalities (especially through RasaX) that enable us to adopt users’ data (of course in compliance with GDPR) as training material.
Important commands
rasa init
initializes new rasa project
rasa train
trains a model of the data you provide, according to the parameters, policies, and custom components you have chosen at the configuration.
rasa train nlu
trains only the nlu model
rasa shell
creates a “shell” where you can speak with your bot
rasa shell --debug
creates a “shell” where you can speak with your bot AND debug (meaning that you will see what is happening behind the bot, and detect where errors are happening)
rasa shell nlu
creates a “shell” only for the nlu data (the intent and entity recognition)
rasa run
runs a new server with the trained model. A custom-coded client is needed in order to speak with the bot when rasa run is used.
rasa run actions
runs the actions server. It is used every time you want to speak with the bot (e.g. rasa shell, rasa interactive)
rasa test
automatically tests everything in the folder “tests”, beginning with test_conversations
rasa test -s <tests/test_conversations_specific.yml>
automatically tests the specific file you identify, which must start with tests/test_converstations
rasa test core
automatically tests the core data, meaning the stories
rasa test nlu
automatically tests the nlu data
rasa test --cross-validation
cross-validation, which automatically creates multiple train/test splits of the data, making the testing more effective
rasa interactive -m models/{name_of_model.tar.gz}
opens an interactive shell, whereby speaking with the bot you can add training data to the system. In particular, through this interactive shell, you check whether the intent/entity classification and responses of your bot are correct, and if they aren’t you can correct them. You add the flag -m in order to define which model you want to use for this interactive shell
rasa data validate
verifies that no mistakes or major inconsistencies appear in your domain, NLU data, or story data
rasa --version
shows what version of rasa (and rasa-SDK) you are using
rasa visualize
visualizes the stories
rasa -h
shows all the available commands
Read the documentation for more information and if you face a specific problem take a look at the forum! There are great tutorials at Rasa’s Youtube channel as well as courses for all levels at Udemy.
At the Institute for Language and Speech Processing of the Athena Research Center, we use Rasa to create Theano, the Greek-speaking conversational agent for COVID-19. For Rasa -and all things in life- practice makes perfect; so after more than a year of developing Theano with Rasa, our team has learned how to take full advantage of Rasa’s utilities. You can take a look at our GitLab Repository, to have an image of what a developing project with this framework looks like.
Don’t forget to give us your 👏 !
The Ultimate Rasa Cheatsheet was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.