What’s hot in Rasa 2.0?

Tram Ho

Since its launch, Rasa has always been in the top of the most popular chatbot frameworks because of its efficiency and ease of customization. Following the success of previous versions, last October the development team released a new version: Rasa Open Source 2.0 with some major changes to make it more user-friendly. as the configurability expands to the experienced user.

In this article I will install and compare to see if Rasa 2 has something new compared to version 1.x

What’s new in Rasa 2.0?

File organization

First, I will create a conda virtual environment and install Rasa 2.0 on it:

Initialize Rasa: rasa init

Below is a picture comparing the original directory of Rasa 1 (left) and Rasa 2 (right). As can be seen from Rasa 2.0, the action.py file is no longer outside of the root directory but is moved into a separate action folder.


Change the training data format from markdown (.md) to YAML (.yml)

Rasa 1 ( nlu.md )Rasa 2 (nlu.yml)
Rasa 1 ( stories.md )Rasa 2 (stories.yml)

In addition to the visual impression that the new version looks more user-friendly, this change in training data format also brings benefits:

  • Ability to support custom metadata in training data. Key metadata consists of any key – value data pairs to provide additional information for an intent or an example, this data can be accessed by components in the pipeline. As in the example below, the sentiment metadata can be used in a custom component to analyze sentiment analysis in the pipeline.
  • Ability to support media formats for the response selector. In the previous version, the response selector (retrieval actions, the model selected a response in the list of responses for the available intents, used for chitchat questions, FAQs) is an experimental feature with some limitations such as sentences. response can only be in text form. In the new version, this has become an official feature and fully supported, you can issue responses by buttons, images, etc. as well as test again with Rasa X.
  • Ability to split a long file into smaller modules


Rasa 1.x provides an unfeaturized slot type to define slots that have no effect on conversation flow. In Rasa 2, this slot type is removed and we can do the same thing by defining slot type as text and setting flag influence_conversation = false .

Introduce RulePolicy (rules.yml)

In Rasa, the chatbot’s response will be decided by a set of dialogue management policies, usually consisting of about 5-6 policies with different priority levels. These policies are essentially divided into two categories:

  • Rule-based: if a certain condition is met => chatbot will perform an action. Examples: MappingPolicy, FallbackPolicy, FormPolicy, Two Stage Fallback Policy, etc.
  • Machine learning-based: based on conversation context and user behavior => predict next action. For example: TED policy, Memoization policy, etc.

In Rasa 2.0, the above two types of policies were separated, the above rule-based policies were put into one and collectively called RulePolicy, responsible for the form, intent-action mapping and fallback logic. We use a new format called Rule snippets to define rules for chatbot in the rules.yml file as follows:

For the rest of the cases where machine learning is needed, such as when defining a conversation thread, or when a “learning” bot is needed to make predictions about the conversations not encountered in training, they are still defined in the stories.yml file stories.yml


Besides integrating into RulePolicy, Forms has become a basic feature of the Rasa Open Source library instead of the Rasa SDK (custom actions) as before. So we can declare and define slot mapping rules right in the domain file. This change is quite logical and also easier for users, especially those who are new to Rasa. Reading the code below we can easily understand immediately what slots this form needs and where it comes from, and what conditions should be satisfied. Users also don’t need to know python code to create a form with basic features.

The required slots of the form can be extracted from entities such as: entity (from_entity), the content of the user’s message (from_text), or filled with certain values ​​when the intent conditions (from_intent) are met. , intent activates the form (from_trigger_intent).

Also, on a more advanced level, we can still use custom actions when we need to validate the value of the slots or when the default slot mapping methods don’t suit our needs.

Details can be found at: https://rasa.com/docs/rasa/forms

Configuration suggestion

After we have prepared the training data and define rules, stories, actions, we can begin to “train” the chatbot:

rasa train

Another highlight of Rasa 2 is that it will automatically recommend a pipelne and policies in the config.yml file if you haven’t already set it up. This is very suitable for new users who do not know about components as well as policies. And for more experienced users, they can customize them to better suit their needs.

Experimental features: MultiProjectImporter

With this feature, Rasa allows us to train a new model by combining many small projects. For example you can develop a chatbot to chitchat with users, another chatbot to say hello, and so on. then combine them together when training.

During training, Rasa will import all the necessary files from the subprojects, combined together to train a single bot. This process is done automatically during training and the user will not need to create any additional files. Note that Rasa will use the policies and pipeline configured in the root directory of the big project, the configs of each subproject will be ignored.

Details can be found at: https://rasa.com/docs/rasa/training-data-importers#multiprojectimporter-experimental


Basically, through some initial approaches, I found that version 2.0 of Rasa has a clearer layer of lang, easier to use for newcomers who have not experienced. Even people who don’t know much code can still instinctively read and create a simple chatbot.

But not only that, the new version also includes many features and components that advanced users can explore and customize, advanced to suit your needs (metadata, retrieval action, and some features. testing as project importer, etc.)

Regarding the effectiveness, in the scope of this article, I have not had the opportunity to test and compare, if I have the opportunity, I will review this content in the next articles.

In addition, if you are using version 1.x and want to switch to 2.0 for testing, you can follow the instructions at: https://blog.rasa.com/migrating-your-rasa-1-x -assistant-to-rasa-2-0 / . In addition to some parts that must be converted by hand, Rasa provides tools for converting. Wish you have a happy experience!


Share the news now

Source : Viblo