Scratching the Surface of Chatbot Machine Learning
In this article I am going moderate geek mode to take a look at what machine learning is and give you some examples of how we use it to create your super-smart chatbots.
Exploring machine learning algorithms
There are many types of machine learning algorithm powering our natural language chatbots. Most belong to a category of machine learning called supervised learning. Geeks would say the chatbot gets a sample of labeled data and uses that data to make predictions on subsequent unlabelled data. For the not-as-geeky, it 'learns' by example.
At the moment, there are really only two primary machine learning models used, generative and selective models.
- Generative models estimate probability.
- Selective models assess similarity.
Generative models can seem much more natural; they have a better chance at creating arbitrary answers and can respond with answers that have incorrect grammar and syntax.
Selective models are more restricted in the breadth of conversation as they can only use topics given to it in training, but as it uses predefined answers, they always have good grammar and syntax, well, unless the human messes up!
In a very big nutshell, both machine learning models take context and input, generative models decide for themselves and create an answer, whereas selective models pick the best response from a pre-defined set of potential answers.
Applying machine learning to chatbots
Dean, this is boring, what has it got to do with chatbots?
Well, hold on to your hats, one of those two machine learning models and their algorithms power pretty much all of what a good chatbot does (unless it is one of those simple Facebook Messenger button-based script things - yukk).
Let’s take a walk down chatbot machine learning lane.
The obvious one to start with is in the chatbot 'understanding' what the human is talking about. Natural Language Understanding (NLU) is part of the Natural Language Processing (NLP) technology tree and deals with language comprehension and analysing semantics.
Conversation models are just like I talked about above; they are either generative or selective. We either train the chatbot what to reply for itself or give the chatbot a language matrix and let it pick the best response. Both have their pros and cons and work best for different situations.
Within the conversational aspect of the chatbot, we also use machine learning models to pull out entities and concepts from user input.
Entities are words a user says within a sentence that the chatbot can store and use to tune a response or relate to later (things like places, emails, names, and companies).
Concepts are a bit fluffier; they are the ideas, topics, and premises of conversations. We use them to keep the bot talking within the correct context and improve the accuracy and relevance of its responses.
Overlooked chatbot machine learning algorithms
Let's explore some of the lesser known or hardly ever mentioned machine learning algorithms that power our chatbots.
'How do you feel today?'
Sentiment analysis is one of the most often overlooked features a chatbot can have. Machine learning models enable us to analyse the input from a user and label it with some form of sentiment.
A basic representation of sentiment analysis
It could be word labels such as positive and negative, or it could be score such as “98% positive”. Most often, we tend to report both. This analysis tends to be most useful in our customer service product, as it gives real-time feedback on user input. This makes training easier and faster, and gives the human a heads-up if an angry customer is coming their way!
'Psst! Something may be wrong'
An emerging machine learning use case for chatbots is in anomaly detection; this enables the chatbot to spot when something has changed and alert the user or chatbot owner.
An example might be in a personal health assistant chatbot. Let’s imagine I have been telling the chatbot my blood pressure every day for the last two months, one day the chatbot might ping me a note giving me insight, or warning, that something may be wrong as it has detected trends or higher-than-normal input.
Another example might be for your banking chatbot which has spotted a rather large payment going out of your account that doesn’t usually happen at this time of the month.
'Alexa, tell me more about chatbots'
Another rapidly emerging example is in speech recognition and the ability to transcribe audio to text and text to audio.
Not all chatbots ‘do’ voice, but, as Amazon, Google and others continue the development of smart speakers and home assistants, we are going to be hearing a lot more about it. We, for instance, have been building Alexa chatbots for several years now.
Interesting side note: as far as I am aware, as much research goes into what the machine learning algorithms should not to listen to as it does in what to listen to. Filtering out background noise, music and smoothing input play a huge part.
'I think you'll love this'
Finally, a bit like anomaly detection, my final chatbot machine learning technique is in prediction.
The key here is the ability for the chatbot to provide unprompted, unique and personalised insight based solely on the data the user gives it. The more the chatbot learns about a user, the more likely it is to be able to make powerful recommendations.
In commerce, this might be the ability for a chatbot to recommend the right product based on previous purchase history, gender or context. In healthcare, it could be the ability for a chatbot to make lifestyle recommendations based on wearable tracking data and user input (learn more about chatbots in healthcare & pharma).
So, there we have it. There are some insights into how we use machine learning in chatbots and the added benefits those algorithms bring.
See how much more goes on behind the scenes in a good chatbot?