How to build your own chatbot intent classifier

  1. (obviously) Create your own chatbots (pairing it up with Xatkit or any other chatbot platform for all the front-end and behaviour processing components)
  2. Learn about natural language processing by playing with the code and executing it with different parameter combinations
  3. Demystify the complexity of building a NLU engine (thanks to the myriad of wonderful open-source libraries and frameworks available) and provide you with a starting point you can use to build your own.

What is an intent classifier?

Does the world really needs yet another NLU chatbot engine?

What makes our NLU engine different?

  1. Xatkit lets you configure almost everything. The data processing, the training of the network, the behaviour of the classifier itself, etc can be configured. Every time we make a design decision we create a parameter for it so that you can choose whether to follow our strategy or not.
  2. Xatkit creates a separate neural network for each bot context. We see bots as having different conversation contexts (e.g. as part of a bot state machine). When in a given context, only the intents that make sense in that context should be evaluated when considering possible matches. A Xatkit bot is composed of contexts where each context may include a number of intents (see the dsl package). During the training phase, a NLP model is trained on those intents’ training sentences and attached to the context for future predictions).
  3. Xatkit understands that a neural network is not always the ideal solution for intent matching. What if the user input text is full of words the NN has never seen before? It’s safe to assume that we can directly determine there is no matching and trigger a bot move to the a default fallback state. Or what if the input text is a perfect literal match to one of the training sentences? Shouldn’t we assume that’s the intent to be returned with maximum confidence? This type of pragmatic decisions are at the core of Xatkit to make it a really useful chatbot-specific intent matching project.

Show me code!

Core Neural Network definition

  • The number of classes depends on the value of len(context.intents). We have as many classes as intents are defined in a given bot context.
  • We use sigmoid function in the last layer as the intents are not always mutually exclusive so we want to get the probabilities for each of them independently

Preparing the data for the training

  • We assign a numeric value to each intent and we use that number when populating the total_labels_training_sentences list
  • We use a tokenizer to create a word index for the words in the training sentences by calling fit_on_texts. This word index is then used (texts_to_sequences to transform words into their index value. At this point training sentences are a set of numeric values, which we call training_sequences
  • Padding ensures that all sequences have the same length. This length, as always, is part of the NLP configuration.
  • The model is finally trained by calling the fit

Predicting the best intent matches

Exposing the chatbot intent classifier as a REST API

Ready to give it a try?

--

--

--

ICREA Research Professor at IN3 (UOC). Talking about software engineering, open source, AI and how the three of them can help each other.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to perform a neural style transfer on a website using ONNX.js and Svelte

Solution to Navigation Project Using Double DQN in UDACITY NanoDegree Programme:

Segmenting Brain Images: A Deep Learning Approach

Cleaning Text Data with Python

Compilation of printed papers

Introduction to Machine Learning in C# with ML.NET

Stereo Vision Based Navigation — Visual Odometry

How to use AWS for your Deep Learning models

Automated ChatBot for College Queries

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jordi Cabot

Jordi Cabot

ICREA Research Professor at IN3 (UOC). Talking about software engineering, open source, AI and how the three of them can help each other.

More from Medium

Autocorrect Using NLP

A chatbot that can help you take care of your Mental Health

Named Entity Recognition (NER)[NLP, Python]

English to Hindi Neural Machine Translation with NVIDIA NeMo toolkit