Training a Chatbot on Alter NLU

Tanya Thakur
Kontiki AI
Published in
5 min readApr 17, 2019

The target audience for this post is developers who are looking for an open source platform meant for training or building AI-based conversational agents.

In this post, I will be covering how you can build a simple dataset for your e-commerce chatbot and will point out those smartly handled pain points by our engineers which will make your dataset robust and complete.

Building no keyword Intents (Intents with no entities):

The intents like “greet” and “exit” are the generic intents every bot should handle. Besides these intents, build other intents you plan to include in your chatbot. Like, I have included “ongoing_offers.

This intent will hold all the user queries asking about the current sales, vouchers in our e-commerce chatbot.

Remember to train the dataset with expressions which contain words like — sales, vouchers, etc, as these words will keep the “ongoing_offers” intent unique from other non-keyword intents.

Fig 1 : ongoing_offers intent example

Building Entities:

The e-commerce chatbot should be trained to handle queries like:

User says : I want to buy apple mobile worth 60K

So, I plan to create 3 entities that will extract the:

  • brand
  • product-type and
  • price

from the user query.

For each entity I add the ‘Reference Value’ and their synonyms. Like a user can write ‘loui vuitton’ as ‘LV’ or ‘Louis Vuitton’.

Fig 2 : Synonyms — Add here all the words you expect the user to say.

Similarly, create values and synonyms for the other fields.

Building Intents with Entities:

For queries as stated in the above section, dataset should have an intent that will store all the possible user queries from which the bot should be extracting the entities (like “search-product in this case). As stated in the image below.

Fig 3 : search-product intent holding training phrases with entities.

For the developers ease we have built the console in such a manner that each ‘Selected Value’ can be linked to a ‘Reference Value’ of your choice.

Like in the images below, you can see in the intent section:

Selected Value : 60k, 2k both have same ‘Reference Value’ i.e price-range

Fig 4 : The Intent Section

In the entity section, every price-range example is defined in the same “Reference Value”

Fig 5 : The Entity Section

If you change the ‘Reference Value’ in the entity section the same will be reflected dynamically in the intent section, and vice versa.

Analysing the loopholes in the dataset: The Report Section

Once you are done building the dataset, move to the Report Section which will analyse your dataset for all intents and entities in real-time and notify the errors and warnings that need to be addressed for the accuracy of the chatbot’s response.

Once you have rectified all the errors, you will be able to download the dataset JSON in both — the Alter NLU or the RASA format.

Fig 6 : Alter NLU allows you to download JSON in 2 formats — the Alter NLU & the RASA format

If you are using RASA NLU, you can quickly create the dataset using Alter NLU Console and Download it in RASA NLU format. We have updated our console for hassle free data creation which is less prone to mistakes.

Alter NLU Updates : v1.0.0-beta

Intent Model

We have used Convolutional Neural Networks (CNN) based model to capture the intent. Further, the use of custom validation algorithm and matthews correlation coefficient as accuracy metric makes the intent model robust.

The user has to train the sentence for one of the synonyms and the remaining are handled by our console code.

Entity Model

In this version we have replaced the previous Flashtext and FuzzyWuzzy based entity extraction method with a CRF based Entity Recognition model.

Build Your Bot:

Go to Git Repository from the link below:

https://github.com/Kontikilabs/alter-nlu/tree/v1.0.0-beta

Next, go through the README.MD file and start executing the steps as mentioned.

Below is an example along with a detailed explanation of the benefits of using this new pipeline.

Fig 7 : Output JSON

Elaboration of the above chatbot response:

  1. According to the context of the user query, the model successfully recognises the search product intent along with the confidence score.
  2. This model handles out-of-vocabulary words to some extent.
    The term ‘out-of-vocabulary words’ refers to those words which are not present in the training data of the chatbot.
    For example, If you take a look at the example above, the parsed_value “799k” is not present in the training data used to train the “ecomm-bot” whose entity has been recognised accurately as “price”.
  3. The CRF model was able to recognise the entity accurately, because it considers the sentence structure of the user query.
  4. If you’re familiar with other bot frameworks, then you might not have come across a key like “parsed_value”. The main goal to add this key in the response is to assist developers to directly use the “parsed_value” if needed.
    In the example above, the developer might need the exact value of entities such as “price” that is in the user query for further usage. In this case it’s “799k”.
  5. Also, if you’re an existing user of Alter NLU it needs to be pointed out that the “category” key in the response has been renamed to “name”.

GIVE IT A SPIN!

We’d love to hear all about your experience using Alter NLU. Critique is welcome too! We hope that using Alter NLU helps you create more effective and intelligent chatbots.

Sign up on the console.

Visit our website.

For any further query, drop me an email on tanya[at]kontikilabs[dot]com.

--

--

Tanya Thakur
Kontiki AI

Developer Evangelist & Engineer | Community and Content Lead @kontikilabs