Text Classification
A great many practical language problems reduce to one question: which of these boxes does this piece of text belong in? Text classification is that question, and it is the task most production language systems are actually performing.
Shape of the task
The input is a span of text — a sentence, a review, a whole support ticket — and the output is a label from a fixed set decided in advance. The variants matter in practice:
- Binary — spam or not spam.
- Multi-class — exactly one of several intents for an incoming message.
- Multi-label — an article tagged politics and economics at once.
Two ways to build one
TF-IDF features into a linear model — logistic regression or a linear SVM — stays a fast, cheap and surprisingly strong baseline, and it is interpretable: you can read the weights. Fine-tuning a pre-trained encoder such as BERT with a classification head on its pooled representation wins where wording is subtle, and is a few lines in Hugging Face Transformers.
Where it goes wrong
Accuracy is the wrong headline number whenever the classes are uneven: a filter that calls every message legitimate scores 97% on a realistic inbox and is worthless, so report macro-F1 and per-class recall. The language-specific traps are negation and scope — “I wouldn't call this a bad film” flips a model keying on bad — plus sarcasm, documents longer than the encoder's window, and labels whose meaning drifts as the people applying them change their minds. A benchmark such as SST-2 in GLUE measures the model; it does not measure your label definitions.
Text classification assigns a label from a fixed set to a span of text — binary, multi-class or multi-label — covering spam detection, sentiment, intent routing and topic tagging. It is built either from sparse features such as TF-IDF fed to a linear model, or by fine-tuning a pre-trained encoder with a classification head. It is the workhorse task of applied NLP, and its reported accuracy is unreliable whenever the label distribution is skewed.
Think of sorting the post: bills in one pile, junk in another, personal letters in a third. You glance at each envelope and decide which pile it belongs to.
Text classification is software doing that with writing. It reads a message or a review and puts it into one of a set of boxes chosen in advance: spam or not spam, happy or unhappy customer, which department should handle this. It is behind the junk folder in your email, the automatic routing of a support request, and the dashboards that tell a company how shoppers feel this week. People decide what the boxes are; the software's job is to pick the right one, fast, over and over.