Natural Language Processing

Text Classification

Text classification is the task of assigning a piece of text to one or more predefined categories, such as routing a support email to billing, shipping, or returns.

What is text classification?

Text classification is the task of assigning a piece of text to one or more predefined categories. Spam filtering is the oldest example. Business uses include routing a support email to billing, shipping, or returns, and tagging a contract clause as indemnification or termination. It is classification in the machine learning sense, applied to text.

A classifier can be trained with supervised learning on labeled examples, or a large language model can be prompted with the category definitions and asked to choose. The supervised approach is cheaper to run at volume and easier to measure. The prompted approach needs no labeled data and adapts the moment the categories change. Many teams start with a prompt and move to a trained classifier once production has produced enough labeled examples.

Text classification in practice

A freight brokerage receives thousands of emails a day. A classifier sorts each into quote request, tender, pickup confirmation, invoice, claim, or other, and routes it to the right queue with a confidence score. Messages below the confidence threshold land in a review queue, and corrections made there become new training data. Sentiment analysis and content moderation are specialized forms of the same task.

What to watch for

  • Define categories that are mutually exclusive, or decide explicitly that a message can carry several labels.
  • Check class balance, because a rare but important category such as a legal claim is the one a model is most likely to miss.
  • Review the “other” bucket regularly; it is where new categories first appear.

← Back to AI Glossary