https://smazee.com/uploads/blog/Understanding-the-Basics-of-Rasa---Open-source-conversational-AI.png https://smazee.com/blog/basics-of-rasa

Understanding the Basics of Rasa - Open source conversational AI

Rasa Open Source is a machine learning framework to automate text and voice-based assistants.

Building contextual assistants & chat bots that really help customers is hard. Rasa provides infrastructure & tools necessary for high-performing, resilient, proprietary contextual assistants that work. With Rasa, all developers can create better text- and voice-based assistants.

Why Rasa?

The main advantage of RASA NLU over those stacks is that you have access to the entire Python processing pipeline and can extend it with your complex custom logic. RASA NLU offers infrastructure capabilities such as model persistence or HTTP access that are required on conversational solutions in the real world.

Who use Rasa NLU?

and many more companies

Rasa Dialogflow
Requires installation of multiple components No installation, get started immediately
Requires technical knowledge Easy to use, non-techies can also build bots
Open-source, code available in GitHub Closed system
No interface provided, write JSON or markdown files Web-based interface for building bots
No hosting provided (at least in the free version) Data is hosted on the cloud
Host it on your server Can’t be hosted on your servers or on-premise
No out of box integration Out of box integration with Google Assistant, Slack, Messenger, Skype etc

Rasa Chatbot

Image Source: Spaceo

Cons of Rasa

  • Although for low traffic volumes, the service is free, if the volumes increase, you need to move to a paid plan.
  • Rasa isn’t for beginners. You need a prior knowledge in chat-bot and NLP.
  • Fine control over dialogue processing will not be available to the programmer.
  • spaCy is one of Rasa’s default pipelines for processing user inputs, uses a lot of computer memory. Depending on the server configuration, spaCy could slow down other processes.

Image Source: SlideShare

Elements of RASA:

  1. Natural Language Understanding (NLU)
  2. Natural Language Generation (NLG)
  3. Dialogue Management

1. Natural Language Understanding (NLU)

Rasa NLU is a kind of natural language understanding module. It comprises loosely coupled modules combining a number of natural language processing and machine learning libraries in a consistent API.

What NLU actually do?

  1. Convert text to Vectors and classify the intent.

Rasa Chatbot

  1. Extraction of entities (If any)

For this process NLU convert the incoming text to tokens using Tokenizer and then

Part of speech tagger: A part-of-speech tagger, or POS-tagger, processes a sequence of words, and attaches a part of speech tag to each word.

Chunker: One of the main goals of chunking is to group into what are known as "noun phrases." These are phrases of one or more words that contain a noun, maybe some descriptive words, maybe a verb, and maybe something like an adverb. The idea is to group nouns with the words that are in relation to them

Rasa Chatbot Smazee

After chunker the entity is recognized and extracted.

Rasa Chatbot Smazee

2. Natural Language Generation (NLG)

Natural Language Generation is a subdivision of Artificial Intelligence that aims to reduce communicative gaps between machines and humans. The technology, typically accepts input in non-linguistic format and turn it into human understandable formats like reports, documents, text messages etc.

3. Dialogue Management

Why Dialogue Handling with Rasa Core?

• No more state machines! • Reinforcement Learning: too much data. reward functions_. • Need a simple solution for everyone

How it works?

By extracting intent and entities from input text, those data are mess up with the previous state to get the new action. Those new actions are updated to the state and produce the output as well as used for next input.

Rasa Chatbot


How to Install Rasa:

Prerequisites:

  1. Python 3
  2. Visual studio 14.0.0+ (not VS Code)

Install rasa using pip (If you don't have pip installed follow this blog to install it)

pip install rasa

Once it got installed, rasa CLI is enabled.

Init Project using

rasa init

Inside your project folder (Empty folder), command prompt

It will ask the following questions,

  1. Please enter a path where the project will be created [default: current directory]- Specify path or press enter for default
  2. Do you want to train an initial model?- For beginners, yes(recommended), It takes some time to train the model.
  3. Do you want to speak to the trained assistant on the command line?- No(Recommended), If you want to see how rasa chatbot work, you can press yes.

If you want to skip these question, add — no-prompt

rasa init --no-prompt

By this process, some files are created in your specified directory, which is explained in upcoming blogs.

This creates the following files:

  1. init.py: This is an empty python file that helps to find your actions.
  2. actions.py: You can customize your action code in this python file.
  3. config.yml (*): This file is used for the configuration of your NLU and Core models. This file has enough details like language, pipeline, epochs detail of NLU, and protocols for cores.
  4. credentials.yml: This has the details for connecting to other services. This contains the credential details.
  5. data/nlu.md (*): This file contain the intent name and intent for the NLU, you start writing intent from here.
  6. data/stories.md (*): This file contains the story of your bot. This is the bridge between intent and the response
  7. domain.yml (*): This contains the intent list, response, action, slots, and form list. This is the domain of your bot.
  8. endpoints.yml: This file have the details for connecting to channels like FB messenger.
  9. models/.tar.gz: This is the model trained by rasa.
  10. (optional) data/responses.md(*): You can create a response file separately in the data folder.

The most important files are marked with a ‘*’.


Train and Review bot:

After you create your own bot, you have to train it, by the following code

rasa train

It will create a new model in the models folder. And you can test it in two different ways:

  1. Using shell
rasa shell

This will create an interface to chat with your bot.

  1. Using postman/curl

First, run the following command

rasa run -m models --enable-api --log-file out.log

which create localhost in which you can interact using curl

curl localhost:5005/model/parse -d '{"text":"hello"}

List of other API's provided

route METHOD Usage
/conversations//messages POST add_message
/conversations//tracker/events POST append_events
/webhooks/rest GET custom_webhook_RestInput.health
/webhooks/rest/webhook POST custom_webhook_RestInput.receive
/model/test/intents POST evaluate_intents
/model/test/stories POST evaluate_stories
/conversations//execute POST execute_action
/domain GET get_domain
/ GET hello
/model PUT load_model
/model/parse POST parse
/conversations//predict POST predict
/conversations//tracker/events PUT replace_events
/conversations//story GET retrieve_story
/conversations//tracker GET retrieve_tracker
/status GET status
/model/predict POST tracker_predict
/model/train POST train
/conversations//trigger_intent POST trigger_intent
/model DELETE unload_model
/version GET version

In this topic, we came across

  1. What is Rasa
  2. Pros and Cons
  3. Elements of Rasa
  4. How to install it
  5. What are the files it contains and how to test it

Next Article : Architecture and creating a bot using Rasa

By on
rasa conversational AI basics of rasa pros and cons of rasa rasa vs dialogflow
Smazee https://smazee.com/uploads/blog/Understanding-the-Basics-of-Rasa---Open-source-conversational-AI.png

Read also

  1. How a great website will help improve business?
  2. A complete guide to Sass
  3. Learn React Basics in 10 mins