Skip to content
LiveNext 10:46:08

Definition

What is Text classification?

Text classification is Text classification is the task of assigning a piece of text, such as an email or a message, to one or more predefined labels like spam, urgent or safe, and it is a core job for AI systems.

What it is

Text classification means reading some text and putting it in a bucket. Is this email spam or not? Is this support ticket about billing, a bug or a refund? Is this message safe to show? The labels are decided in advance, and the model's job is to pick the right one, or several.

It is a sorting task, like a mail clerk dropping letters into pigeonholes. The clerk does not write anything new. They choose a slot.

Common uses

  • Moderation. Flag harmful or policy-breaking content.
  • Routing. Send a request to the right team, or to the right model. See model routing.
  • Tagging. Label documents by topic, language or sentiment.
  • Safety checks. Screen inputs and outputs, as part of AI guardrails.
  • Grading. Score an answer against a rubric, as in LLM-as-a-judge.

How it is done

There are three common approaches:

  1. Classic machine learning. Train a small model on labeled examples. Fast and cheap, but it needs a good labeled dataset.
  2. Embeddings plus a simple classifier. Turn text into embeddings, numeric representations of meaning, then train a light model on top. A good middle path.
  3. Prompting a language model. Describe the labels in a prompt and ask. This needs no training data and works well for new categories, though it costs more per item and can be less consistent.

A fine-tuned model sits between the second and third: more consistent than prompting, with less data than training from scratch.

Getting good results

  • Define labels so two people would pick the same one. Vague labels give noisy results.
  • Include an "other" or "unsure" label so the system is not forced into a wrong guess.
  • Use structured output so the label comes back in a fixed format.
  • Look at the confidence score, if there is one, and send low-confidence cases to a person. See model calibration and human-in-the-loop.
  • Measure accuracy on a sample you labeled yourself, and look at the mistakes, not only the average.

The catch

Classifiers inherit the biases and blind spots of their training data, and they can be fooled by text written to trick them, including prompt injection. Class imbalance also hides errors: a system that labels everything "not spam" can look 99% accurate when spam is rare.

The short version

Text classification is sorting text into labels. It is the quiet workhorse behind moderation, routing and tagging, and it works best when the labels are clear and the uncertain cases go to a human.

Questions people ask

What is text classification?

It is assigning text to predefined labels, such as spam or not spam, or billing versus bug report.

Can a language model do text classification?

Yes. You can describe the labels in a prompt, or fine-tune a model for more consistency. Check its accuracy on a sample you labeled yourself.

Text classification in the news

#03

OpenAI opens its Decisions API, and output is free

OpenAI put its Decisions API in public beta on October 6, with gpt-6-luna at $0.10 per million input tokens and no charge for output. If you classify, route or grade at volume through a chat model, this is the endpoint to price against.

#04

OpenAI's Decisions API goes GA with 400 questions a call

OpenAI's Decisions API left beta on Oct. 22, now taking up to 400 typed questions per request, up from 200, at $0.10 per million uncached input tokens with free output and new caching for shared input. The badge is minor. The doubled question count is what cuts your bill.