Source: Deep Learning on Medium
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.
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:
- product-type and
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’.
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.
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
In the entity section, every price-range example is defined in the same “Reference Value”
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.
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
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.
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:
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.
Elaboration of the above chatbot response:
- According to the context of the user query, the model successfully recognises the search product intent along with the confidence score.
- 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”.
- The CRF model was able to recognise the entity accurately, because it considers the sentence structure of the user query.
- 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”.
- 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”.