Chatbots are one type of AI assistants, to build a chatbot, NLU is one of key components, NLU stands for Natural Language Understanding. Understanding the user input correctly is the foundation of giving out correct response.
The Challenge
The challenge is quite simple, given 2 CSV files below build a NLU model with highest accuracy
- training set: 20 pairs of questions and answers, each mapped to a question ID
- test set: 20 rephrased questions and their corresponding question ID
The Research
After research, we found that the following vendors are available for building NLU and pros and cons listed below
Google Dialogflow: create FAQ chatbot with Dialogflow (video)
- pros:
- ease of use: its knowledge connector feature (launched August 2019, in beta status as of August 2020) enables automatic entity extraction and intent creation, no need of manual creation of entities and intents which saves time and can get us straight to model testing and improvement phase
- cons:
- cloud based, unable to own the full IP rights
- the model's accuracy depends on whether input questions are distinct enough from each other, if two questions are too similar to each other, the NLU model may give wrong result, e.g. Eg. Q1-Do you allow pets? Q2 - Are kids allowed? And user asks - Are pets allowed and it matches with Q2
- cannot train the model on individual question
- cons:
- cloud based, unable to own the full IP rights
- difficult to use: requires manual definition of intents
- pros
- open source, user owns full IP rights
- cons
- need to build from scratch and need more effort than cloud-based solutions
The Conclusion
Due to time constraint of this challenge (only a few hours), we went ahead with knowledge connector offered by Google's Dialogflow and built a model on cloud. Google Dialogflow automatically creates Service Account to access the Dialogflow Agent (NLU model), but its token expires every hour or so, we manually refreshed token and created a Python program to iteratively feed test questions to Dialogflow Agent and compared its output answer to correct answer and got 70% accuracy rate.