This article was written by gk_.
Understanding how chatbots work is important. A fundamental piece of machinery inside a chat-bot is the text classifier. Let’s look at the inner workings of an artificial neural network (ANN) for text classification.
We’ll use 2 layers of neurons (1 hidden layer) and a “bag of words” approach to organizing our training data. Text classification comes in 3 flavors: pattern matching, algorithms, neural nets. While the algorithmic approach using Multinomial Naive Bayes is surprisingly effective, it suffers from 3 fundamental flaws:
Join 30,000+ people who read the weekly Machine Learnings newsletter to understand how AI will impact the way they work and live.
As with its ‘Naive’ counterpart, this classifier isn’t attempting to understand the meaning of a sentence, it’s trying to classify it. In fact so called “AI chat-bots” do not understand language, but that’s another story.
If you are new to artificial neural networks, here is how they work.
To understand an algorithm approach to classification, see here.
Let’s examine our text classifier one section at a time. We will take the following steps:
The code is here, we’re using iPython notebook which is a super productive way of working on data science projects. The code syntax is Python.
We begin by importing our natural language toolkit. We need a way to reliably tokenize sentences into words and a way to stem words.
To read the whole article, with demonstration, click here.