Build a basic chat bot using RASA open source machine learning framework
1.What is RASA (and its core components)
RASA open source is and open source conversational AI platform. You can use it to create chat bots and assistants and also connect them to third party applications using a set of APIs.
Above is an overview of the RASA platform which comprises of the RASA pro (built on top of RASA open source with additional enterprise grade features for scalability and security) and RASA X/Enterprise (low code user interface).
The RASA open source architecture comprises of two primary components : the Natural Language Understanding (NLU), and dialogue management.
NLU handles intent classification, entity extraction and response retrieval, whereas dialogue management component decides the next action in a conversation based on the context.
2.How does it work (main concepts)
2.1 Training Data
RASA uses YAML as a unified and extendable way to manage all training data, including NLU data, stories and rules.
2.1.1 NLU training data(nlu.yml) stores structured information about user messages.
2.1.2 Stories(stories.yml) are a type of training data used to train your assistant's dialogue management model.
2.1.3 Rules(rules.yml) training data are similar to stories which describe short pieces of conversations that should always follow the same path.
2.2 Domain(domain.yml)
The domain specifies the intents, entities, slots, responses, forms and actions your assistant should know about. It also defines a configuration for conversation sessions.
2.3 Config(config.yml)
It defines the components and policies that your model will use to make predictions based on user input.
2.4 Actions
After each user message, the model will predict an action that the assistant should perform next. You can use different types of actions like responses, custom actions, forms, default actions and slot validation actions.
2.5 Tracker Stores
The assistant's conversations are stored within a tracker store. By default it uses InMemoryTrackerStore, but you can also create your custom tracker store using mySql, mongo, redis.
2.6 Model Storage
You can load or store your trained model locally on your disk (default), on a server or on the cloud.
2.7 Lock Stores
Lock Stores is a ticket lock mechanism that ensures that incoming messages for a given conversation ID are processed in the right order. It uses InMemoryLockStore by default but you can also use RedisLockStore and other custom lock store.
3.Creating your own RASA chat bot
3.1 Setup and installation
Install rasa : pip install rasa
Create a virtual environment in your repository : python -m venv venv
initialise the repository : rasa init
This is how the initial folder structure looks like.
3.2 Modify the training data and train the model
In order to build your own chat bot you need to make changes to these files:
domain.yml, nlu.yml, rules.yml and stories.yml
Once you are done making modifications to the training data:
train the model using : rasa train
3.3 Run the trained model
start the rasa shell to interact with the chat bot using : rasa shell
4.Integrating with external applications
You can use the HTTP API to interact with a running RASA server. With the API, you can train models, send messages, run tests and more.
5.Conclusion
RASA platform comes bundled up with all the tools and features needed to build great conversational experiences. Companies around the world are adopting it to transform customer experiences, and increase productivity.