The Rasa Masterclass Handbook: Episode 1

The Rasa Masterclass is a weekly video series that takes viewers through the process of building an AI assistant, all the way from idea to production. Hosted by Head of Developer Relations Justina Petraityte, each episode focuses on a key concept of building sophisticated AI assistants with Rasa and applies those learnings to a hands-on project. At the end of the series, viewers will have built a fully-functioning AI assistant that can locate medical facilities in US cities.

To supplement the video content, we’ll be releasing blog posts to summarize each episode. You can follow along with these posts as you watch to reinforce your understanding, or you can use them as a quick reference. We’ll also include links to additional resources you can use to help you along your journey.

Introduction

In Episode 1 of the Rasa Masterclass, we do four things:

  1. Define what a contextual assistant is
  2. Identify the components of Rasa
  3. Install Rasa
  4. Create a Rasa starter project

What are contextual assistants?

At Rasa, we use the concept of 5 Levels of Assistants to describe the capabilities of AI assistants and show how the technology has evolved over time.

Briefly, these are the definitions:

Level 1: Notification Assistants

  • Capable of sending simple notifications, like a text message, push notification, or WhatsApp message.

Level 2: FAQ Assistants

  • Can answer simple questions, like FAQs.
  • The most common type of assistant today
  • Often constructed around a set of rules or a state machine.

Level 3: Contextual Assistants

  • Able to understand the context of the conversation, i.e.  what the user has said previously and when/where/how they said it.
  • Capable of understanding and responding to different and unexpected inputs
  • Can learn from previous conversations and improve in accuracy over time
  • Buildable today with Rasa

Level 4: Personalised Assistants

  • The next generation of AI assistants, that will get to know you better over time
  • Theoretical only

Level 5: Autonomous Organization of Assistants

  • AI assistants that know every customer personally
  • Capable of running large parts of a company’s operations—from lead generation to sales, HR, or finance.
  • Long-term vision for the industry

In the Rasa Masterclass, we’ll be focused on building Level 3 assistants, using Rasa’s machine learning-based approach, which uses data from real conversations to improve accuracy over time.

Exploring Rasa

Rasa has three major components that work together to create contextual assistants:

Rasa NLU

Rasa NLU is like the “ear” of your assistant—it helps your assistant understand what’s being said. Rasa NLU takes user input in the form of unstructured human language and extracts structured data in the form of intents and entities.

  • Intents are labels that represent the goal, or meaning, of a user’s specific input. For example, the message ‘Hello’ could have the label ‘greet’ because the meaning of this message is a greeting.
  • Entities are important keywords that an assistant should take note of. For example, the message ‘My name is Juste’ has the name ‘Juste’ in it. An assistant should extract the name and remember it throughout the conversation to keep the interaction natural. Entity extraction is achieved by training a named entity recognition model to identify and extract the entities (in this example, names) for unstructured user messages.

Rasa Core

Core is Rasa’s dialogue management component. It decides how an assistant should respond based on 1) the state of the conversation and 2) the context. Rasa Core learns by observing patterns in conversational data between users and an assistant.

Rasa X

Rasa X is a toolset for developers to build, improve and deploy contextual assistants with the Rasa framework. You can use Rasa X to:

  • View and annotate conversations
  • Get feedback from testers
  • Version and manage models

With Rasa X, you can share your assistant with real users and collect the conversations they have with the assistant, allowing you to improve your assistant without interrupting the assistant running in production.

Getting Started

The fastest way to begin building an AI assistant with Rasa is on the command line, with a few simple steps:

Installing Rasa

You can install both Rasa (NLU and Core) and Rasa X with a single command:

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

For detailed step-by-step instructions on installing Rasa, along with system requirements and dependencies, see the Installation Guide.

Creating the starter project

Next, we can create the Rasa example starter project, called moodbot.

  • Open a terminal and run the command rasa init.
  • This command creates a new Rasa project in a local directory, which you will specify by providing the directory name.
  • Once the directory is initialised, Rasa will automatically populate it with the project files and example training data, and it will train the NLU and dialogue models.
  • By default, rasa init trains a simple assistant called moodbot which will ask you how you feel, and if you are unhappy it will try to cheer you up by sending you a picture of a cute tiger cub.

Interacting with moodbot

  • You can use moodbot immediately.
  • In your terminal, type Hi.
  • The assistant responds with, Hey, how are you.
  • If you reply that you are a bit sad, moodbot understands that you are unhappy and will send you a picture to cheer you up.

The rasa init function is a great way to test how a Rasa-powered assistant works. You can also use moodbot as a boilerplate project for for building your own custom assistant.

Next Steps

Now that we’ve laid the foundation by establishing what contextual assistants are, identifying the components of Rasa, and creating a starter project, we’ll build on that knowledge in the next episode: Creating the NLU Training Data.

To be notified when new episodes are available, be sure to subscribe to the Rasa YouTube channel!

Additional Resources