Intent Classification API, based on GPT

What is Intent Classification and Why Use GPT?

Intent classification (also known as intent detection, or intent recognition) is about retrieving the intent from a piece of text. This is especially useful in a discussion (i.e. chatbots and conversational AI), in order to understand what a person wants to achieve.

Performing intent classification with modern AI models like GPT-3 GPT-J, and GPT-NeoX, gives very impressive results.

For example, imagine that someone says the following:


I spent some time on your documentation but I could not figure how to add a new credit card.
It is a problem because my current card is going to expire soon and I'm affraid that it will cause a service disruption.
How can I update my credit card?

Thanks in advance,

Looking forward to hearing from you,

John Doe

The intent behind this email is "update credit card".

GPT-J and GPT-NeoX are the most advanced open-source NLP models as of this writing, and they are the best GPT-3 alternatives. These models are so big that they can adapt to many situations, and perfectly sound like a human. For advanced use cases, it is possible to fine-tune GPT (train it with your own data), which is a great way perform paraphrasing that is perfectly tailored to your industry.

Why Use Intent Classification?

In a conversation between an AI and a human, it can be very useful to understand what the person is truly looking for or asking for. Here are a couple of examples:

Triaging Customer Requests

Support teams or sales teams receive tons of customer messages. In order to address them efficiently, it is very useful to first get the intent so one can instantly decide what to do and whether it's important or not.

Product Suggestion

It's sometimes hard for a user to find what he's looking for, especially if there're a lot of products or if the products are complex. In that case, building a chatbot that detects customers' intents and points them to the right product is a very good solution.

Intent Classification with GPT

In order to make the most of GPT, it is crucial to have in mind the so-called few-shot learning technique (see here): by giving only a couple of examples to the AI, it is possible to dramatically improve the relevancy of the results, without even training a dedicated AI.

Sometimes, few-shot learning is not enough (for example if your intent classification relies on very specific situations bound to your industry only). In that case, the best solution is to fine-tune (train) GPT with your own data (see here).

Building an inference API for intent classification based on GPT is a necessary step as soon a you want to use intent classification in production. But building such an API is hard... First because you need to code the API (easy part) but also because you need to build a highly available, fast, and scalable infrastructure to serve your models behind the hood (hardest part). It is especially hard for machine learning models as they consume a lot of resources (memory, disk space, CPU, GPU...).

Such an API is interesting because it is completely decoupled from the rest of your stack (microservice architecture), so you can easily scale it independently, and you can access it using any programming language. Most machine learning frameworks are developed in Python, but it's likely that you want to access them from other languages like Javascript, Go, Ruby...

NLP Cloud's Intent Classification API

NLP Cloud proposes an intent classification API based on GPT that gives you the opportunity to perform detection out of the box, with breathtaking results. If the base GPT model is not enough, you can also fine-tune/train GPT-J on NLP Cloud and automatically deploy the new model to production with only one click.

For more details, see our documentation about text generation with GPT here. Also see our few-shot learning example dedicated to intent classification here. And easily test GPT intent classification on our playground.