Text Classification API

What is Text Classification?

Text classification is the process of categorizing a block of text. As an option, you can ask the AI to choose a category among a list of categories you gave beforehand.

Generative AI models like ChatGPT, GPT-3.5, GPT-4, LLaMA 2, Yi 34B, and Mixtral 8x7B, are very good at performing text classification.

Text Classification

Let's say you have the following block of text:

Perseverance is just getting started, and already has provided some of the most iconic visuals in space exploration history. It reinforces the remarkable level of engineering and precision that is required to build and fly a vehicle to the Red Planet.

Let's also say that you also have the following categories: space, science, and food.

Now the question is: which ones of these categories apply best to this block of text? Answer is space and science of course.

If you don't suggest any candidate categories, the AI will suggest the best category possible based on the data it was trained on.

Why Use Text Classification?

Text classification can be used in many useful situations. Let's give you a couple of examples.

Sort Incoming Messages

Are you flooded with incoming messages at work? Well, properly labelling these messages in advance can definitely make you more productive. You could know in advance which messages are advertising, and which one are customer requests, for example

Detect Urgency

Some customers requests must sometimes be addressed as a priority. If that's the case it can be very interesting to detect them in advance and address them right away.

Leads Qualification

Let's say you are looking for companies in the automotive field. You could scan websites and only keep those who have the "automotive" label applied.

Economic Intelligence

You might want to monitor new content from various sources and categorize it accordingly. Text classification is the right way to do so.

Text Classification with Generative AI Models.

Large language models and generative AI have revolutionized the field of text classification, enabling more accurate and efficient analysis of text data. These models can generate human-like text and recognize patterns in large datasets, allowing them to classify text with a high degree of accuracy. This has had a significant impact on industries such as customer service, marketing, and e-commerce, where accurate text classification is essential for making informed decisions.

As these models continue to improve, they will likely become even more powerful and widely used, transforming the way businesses and organizations approach text classification.

NLP Cloud's Text Classification API

NLP Cloud proposes a text classification API that gives you the opportunity to perform text classification out of the box, based on advanced AI models like Bart Large MNLI Yahoo Answers, Joe Davison's XLM Roberta Large XNLI, LLaMA 2 Dolphin, ChatDolphin... They are veru good alternatives to ChatGPT, GPT-3.5, and GPT-4. You can either use these pre-trained models, or train your own models.

For more details, see our documentation about text classification here. For advanced usage, see the text generation API endpoint here. And easily test text classification on our playground.

Testing text classification locally is one thing, but using it reliably in production is another thing. With NLP Cloud you can just do both!

Frequently Asked Questions

What is text classification?

Text classification is a subfield of Natural Language Processing (NLP) that involves categorizing text into predefined groups. By analyzing the text, an algorithm can predict the most appropriate class for the text based on its content. This is useful in many applications such as spam detection, sentiment analysis, and topic labeling.

Can text classification be used for sentiment analysis?

Yes, sentiment analysis is a subcategory of text classification

How to evaluate the accuracy of AI classification?

To evaluate the accuracy of AI classification, one commonly uses a confusion matrix to calculate metrics such as precision, recall, and the F1 score, which offer insights into how well the AI model distinguishes between classes. Additionally, accuracy can be directly assessed by dividing the number of correct predictions by the total number of predictions made by the model.

Can I try the text classification API for free?

Yes, like all the models on NLP Cloud, the text classification API endpoint can be tested for free

Can I classify text in several languages with your API?

Yes, on NLP Cloud you can classify text in 200 languages

What are some use cases for text classification?

Classification covers a variety of use cases. Here are some examples: sentiment analysis, spam detection, content moderation, support tickets triaging, document labelling...

How does your AI API handle data privacy and security during the text classification process?

NLP Cloud is focused on data privacy by design: we do not log or store the content of the requests you make on our API. NLP Cloud is both HIPAA and GDPR compliant.