Natural language processing for chatbots

Visualizing and Modifying Rasa NLU JSON Data

Less than 500 views Posted On Aug. 28, 2020

Prerequisite: Creating Rasa NLU Data for Model in JSON Format

In this tutorial we are going to see, how can we use a tool to create the data used for training our chatbot model. 

We’ll make use of a tool called Rasa NLU trainer to visualize our training data. This tool will help us in annotating the data as well. If you have ever worked with the Dialogflow interface, you must be knowing that it was so easy to define entities, their names, and the types. We are going to do the same using an open-source tool.

Rasa NLU trainer is a very nice and handy tool to edit our training data right from our browser itself.

Handling JSON data is tricky and also can lead to errors. With this tool, we can easily add more examples to our training data or edit the existing ones.

It saves a lot of time from manually annotating the data.

rasa-nlu-trainer is a javascript based tool, so we would need to install node.js to run this tool on our system. 

 

 
Downloading Node.js

Go to https://www.npmjs.com/get-npm and download node.js. 2. Install the package on your system as guided on the website.

Once installed, go to a fresh terminal/command-line interface on your system, and type “npm” to see if it works.

Once you have successfully installed the tool, run the following command to install rasa-nlu-trainer:

npm install -g rasa-nlu-trainer

Let’s go to our data folder that we created earlier in our terminal and run the following command:

rasa-nlu-trainer

Typing this command will crank up a local server on a port depending on your system and open it in the default browser.

Suppose that our data for rasa chatbot training looks something like this:

{
    "rasa_nlu_data": {
         "common_examples": [
             {
                 "text": "Hello",
                 "intent": "greeting",
                 "entities": []
             },
             {
                 "text": "What would you like to have?",
                 "intent": "get_food_order",
                 "entities": []
             },
             {
                 "text": "I'd like to order a pizza",
                 "intent": "get_food_order",
                 "entities": []
             },
             {
                 "text": "Do you have something in Italian?",
                 "intent": "get_order_query"
             }
         ],
         "regex_features": [],
         "entity_synonyms": []
    }
}

 

 

Once, we run our trainer tool, it will look like something shown in the figure below:

Rasa NLU Trainer JavaScript Tool

As we can see, all of our existing data from chatbot_data.json is picked by this amazing tool for us to delete or edit and we can also add new examples from here and it will keep on extending the chatbot_data.json file.

We can more training examples to our chatbot data very easily using this tool.

The more examples we add, the better it is for the model to be trained and provide better accuracy.

After adding more examples. If we look at the chatbot_data.json file now, it will have more examples automatically added to it.

You may go ahead and verify your chatbot_data.json file to see if you have all your added examples from the rasa-nlu-trainer UI tool.

Share this tutorial with someone who needs it

What are your thoughts?