ATLAS NOVA My AtlasVelocer ↗

Technology · Language models

Text classification

Text classification is the task of assigning a document to one or more predefined categories, called labels, on the basis of its content and meaning.⁠[1]

The labels are fixed in advance by whoever sets up the task, and the job of the system is to decide which of them a given piece of text belongs to. A news article might be sorted into sports or business; a customer review might be marked positive, negative, or neutral. The definition is deliberately broad, because the "document" can be almost anything written: an email, a product review, a medical note, a tweet, a company report.⁠[1]

Key facts
80.5Reuters recall/precision breakeven point reached by machine-generated decision rules, Apté and colleagues 1994⁠[2]
0.97F1 score for CNN on hip fracture classification under weak supervision, Wang and colleagues 2019⁠[3]
41Social media datasets used to compare ten classification approaches, Hartmann and colleagues 2019⁠[4]
96Success rate of backdoor attack on LSTM classifier with one percent poisoning, Dai and colleagues 2019⁠[5]

Overview

What text classification is and what it does

A simple example makes the mechanism concrete. Suppose the label is "fruit." A rule-based classifier could be told that any document containing the words "apple," "grapes," or "orange" receives that label.⁠[1] This illustrates the core shape of the problem: some signal in the text is taken as evidence for a category, and a procedure turns that evidence into a decision. What counts as good evidence, and how the decision is made, are the questions the rest of the field is built around.

Two documents flow through apple, grapes, and orange checks into OR decisions, producing fruit for one example and no label for the other.
An expert-written rule checks three fruit keywords and combines the results with logical OR. A matching document receives the fruit label; a document with no matches receives no label from this rule. View full-size image.From Word Matches to Labels by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The task matters because most digital information exists as text, and that text is usually unstructured or semistructured, meaning it does not arrive in neat rows and columns that a computer can tabulate directly. To be useful for decision-making it has to be structured, and the sheer volume makes manual sorting impossible: people cannot read and tag millions of documents by hand.⁠[1] Text classification grew out of that gap. Manual procedures work well up to a few hundred documents, but beyond that they become laborious, slow, and potentially unreliable, with fatigue and disagreement between coders creeping into the labels.⁠[6] An automatic classifier is meant to do the same sorting faster, more cheaply, and more consistently.

Approaches to the problem fall into three groups. Rule-based methods apply a set of predefined rules written by a person with domain knowledge, as in the fruit example; they can work well but are hard to maintain. Data-driven methods instead learn the association between text and labels from examples that have already been labeled, so the rules are inferred from data rather than written by hand. Hybrid methods combine the two, using rules alongside a learned model.⁠[1] The distinction matters because it locates where the effort goes: into an expert's time, or into collecting and labeling examples.

Text classification turns a flood of unstructured documents into labeled categories, either by rules a person writes or by patterns a model learns from labeled examples.

History

From handcrafted rules to learned models

Before any of this was automatic, sorting text was a person's job. Someone read each document and wrote down its category, and for a small collection that works well. The trouble is scale: a person can hold only so many documents in mind before the work slows and the judgments start to drift, and the cost of adding more documents rises with every one added.⁠[6] The first attempts to automate the job kept the human squarely in charge of the logic. An expert studied the texts, worked out what distinguished one category from another, and wrote those distinctions down as rules, often as regular expressions, which are compact patterns that match particular strings of characters.⁠[1] A rule of this kind can be sharp and accurate, and because a person wrote it, its reasoning is visible and can be edited directly.

Dr. Edward A. Feigenbaum.
Dr. Edward A. Feigenbaum. View full-size image.27. Dr. Edward A. Feigenbaum 1994-1997 by United States Air Force. Public domain, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.
Figure 1. F1 scores of four classifiers on three clinical text tasks. F1 score, a combined measure of precision and recall, for a rule-based program and three machine learning models on each of three clinical classification tasks. The source states: “Mayo Clinic Smoking Status Classification Precision Recall F1 Score Rule-based NLP 0.91 0.91 0.91 SVM 0.80 0.79 0.80 RF 0.82 0.81 0.81 MLPNN 0.85 0.85 0.85 CNN 0.93 * 0.92 * 0.92 * Proximal Femur (Hip) Fracture Classification Precision Recall F1 Score Rule-based NLP 0.93 0.92 0.93 SVM 0.95 0.95 0.95 RF 0.93 0.93 0.93 MLPNN 0.95 0.95 0.95 CNN 0.97 * 0.97 * 0.97 * i2b2 2006 Smoking Status Classification Precision Recall F1 Score Rule-based NLP 0.91 0.89 0.88 SVM 0.86 0.84 0.84 RF 0.85 0.84 0.83 MLPNN 0.83 0.82 0.82 CNN 0.76 * 0.81 * 0.77 *” (Wang et al. (2019)).⁠[3]

The weakness is that the rules are only as good as the expert's foresight, and they must be maintained as language and subject matter shift. Writing and keeping them takes substantial manpower, and the resulting system may not be portable beyond the use case for which it was designed.⁠[1][3] A rule set tuned to one kind of document may not be portable beyond the use case for which it was designed.⁠[3]

The alternative is to let the rules be discovered rather than dictated. In a learned model, the criteria for assigning a label are inferred automatically from a set of documents that have already been labeled, so the system finds the associations between text and category instead of being told them.⁠[1] This shifts the human effort from writing rules to supplying examples, and it pays off because a model can pick up patterns an expert would not think to encode. Early work on decision-rule induction made the point concretely: machine-generated rules for sorting documents were found to be comparable to human performance while using the same rule-based form, and on a standard Reuters benchmark they lifted the recall/precision breakeven point from a previously reported 67 percent to 80.5 percent.⁠[2] The gain came not from a cleverer hand but from letting the patterns be learned from the collection itself.

From there the field moved toward models that learn their own internal representations of text rather than relying on features a person designs, an approach that has surpassed classical machine-learning approaches on tasks such as sentiment analysis, news categorization, and question answering.⁠[7] A recent approach is the pretrained transformer, a large model first trained on large amounts of general text and then adapted to a particular classification job; transfer learning models have been tested on datasets such as COVID-19 fake news and extremist-non-extremist data.⁠[8] Each step in this progression hands more of the work to the machine and asks less of the person writing the rules, though, as later sections show, none of it removes the need for good labeled examples.

Automation moved the human's job from writing the rules to supplying the examples, and then to adapting a model that has already learned from a great deal of text.

How it works

The pipeline: from raw text to predicted label

A text classifier is not a single program but a sequence of stages, each turning the output of the one before it into something the next can use. The order is not arbitrary. A learning algorithm cannot read prose; it needs numbers, and it needs those numbers arranged in a fixed shape. So the raw documents must first be gathered, then cleaned, then converted into a numerical form, then often trimmed down, and only then handed to a classifier that is trained and finally tested. Each stage exists to solve a problem the previous one leaves behind, and a weakness introduced early is hard to repair later.

Blue training and green test branches connect a corpus to preprocessing, vectorization, feature selection, classification, and an evaluation table.
Training and test documents follow separate branches while sharing fitted transformations. A four-document test illustrates accuracy of 75%. View full-size image.Training and Held-Out Evaluation by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The process begins with data collection: assembling a corpus, meaning a body of text documents chosen for the task, from whatever sources fit the research domain. Public collections such as newsgroups, Kaggle datasets, and WebKB are available, and a corpus can also be built from emails, financial reports, medical records, or news events.⁠[1] At this stage the documents also need labels, since a model that learns from examples must be told the right answer for each one. Labeling is the act of assigning each document to its class, and it is usually done by a person with knowledge of the subject.⁠[1] Labeling requires a lot of training documents and expertise, and machine learning models usually require extensive human effort to label a large set of training data.⁠[1][3]

Raw text is messy, and preprocessing is the stage that removes the parts that would obscure patterns rather than reveal them. The first operation is tokenization, which splits a document into individual terms; a term may be a word, a punctuation mark, a number, or a symbol such as an emoticon, and in written English terms are usually separated by spaces.⁠[6] Once the text is broken into tokens, the analyst decides what to discard. Punctuation and numbers are dropped when they carry no information for the task, though an exclamation mark or an emoticon may be kept precisely because it signals sentiment. Stopwords, the words of low information content such as "and," "the," and "of," are typically deleted. When the case of the letters is irrelevant, it is advisable to transform all upper case letters into lower case.⁠[6]

A further step is stemming, the process of reducing a word to its base or stem form by stripping suffixes, on the assumption that words sharing a root carry the same meaning; calculate, calculating, and calculated all collapse to a single form. Stemming belongs to a broader class called normalization, whose aim is to merge terms that express the same idea under one code.⁠[6] These choices are not universally beneficial. The effect of stemming and stopword removal depends on the language, the genre, and the classifier: in classifying English online news the impact of both was found to be negligible, and in some English and Czech applications stemming even appeared to degrade performance, while certain Arabic classifiers benefit from it.⁠[6] Preprocessing is therefore a set of judgment calls rather than a fixed recipe.

Only after cleaning does the text become something a model can use, and that transformation is the subject of the next section. In outline, the cleaned terms are converted into a numerical representation, most simply a count of how often each term appears, and the resulting table of documents against terms is what the classifier actually sees. That representation can be very large, with one column per distinct word in the corpus, so a dimensionality reduction step may follow: features are reduced by applying feature selection techniques, which tends to decrease the dimensions of data required for the learning method.⁠[1] A survey of text classification algorithms covers feature extraction, dimensionality reduction, classification techniques, and evaluation methods.⁠[9]

Training and testing come last, and they are kept deliberately separate. The labeled data is divided so that the majority is used to train the classifier and the remainder, the test data, is held back.⁠[1] The model learns the association between text and label on the training portion, and then the held-back documents are fed in to see what it predicts. During the testing phase, the classification method is executed on test data to define the target class of input text, and the result is evaluated for its accuracy. The output at this stage typically takes the form of weights or probabilities over the possible labels, which are then compared against the true labels to produce a score.⁠[1] That score is what tells the builder whether the pipeline as a whole, and each choice within it, is working.

Every stage of the pipeline exists to make the next one possible, and the final evaluation measures the combined effect of all of them, not any single step.

Representing text as numbers

A learning algorithm cannot read prose. Almost every classifier takes its input as a feature vector, a fixed-length list of numbers, while a document is a string of variable length, so the text has to be converted before any model can touch it.⁠[1] This conversion is called text representation, and the choices made here shape what the classifier is able to notice. Two broad strategies exist. One treats a document as a set of terms with their frequencies, ignoring the order in which the terms appear; the other keeps the text as a sequence of terms, so that order and context survive into the model.⁠[1]

Three documents appear above count and TF-IDF matrices linked by column weights, with apple and orange calculations underneath.
A three-document corpus becomes a term-count matrix and then a TF-IDF matrix using raw counts and unsmoothed inverse document frequency. Worked examples show why apple receives weight about 2.20 in D1 while orange receives zero. View full-size image.From Term Counts to TF-IDF by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The most common representation is the bag-of-words model, which treats every word in a document as a token or feature and ignores word order and context entirely. The simplest way to encode a single word within that scheme is one-hot representation: a vector as long as the whole vocabulary, with a single dimension switched on for the word in question and all others off. Under TF-IDF, the corpus is represented as a document-term matrix, where a column signifies a token and a row signifies a document.⁠[1]

Two problems follow directly from this design. One-hot vectors are extremely sparse, meaning almost every entry is zero, which wastes space and makes computation heavy. And raw counts let very frequent words dominate the model, pulling its decisions toward whatever appears most often rather than whatever distinguishes one class from another.⁠[1]

The standard remedy is to weight each term rather than merely count it. TF-IDF, short for term frequency-inverse document frequency, builds a document-term matrix in which each cell holds a weight combining how often a term occurs in a document with how rare that term is across the corpus.⁠[1] The inverse document frequency assesses the specificity of a term, and terms that occur in too many or too few documents have low discriminatory power and are therefore not useful for classification purposes. The combined weight is the product of the two quantities.⁠[6]

TF-IDF is popular partly for its simplicity, and it has been used to sharpen feature subsets by drawing on both term frequency and document frequency at once.⁠[1] It does not, however, solve the scale problem. Even a modest collection of documents contains a large number of meaningful words, and the resulting matrix grows to a very high number of dimensions, which raises the cost of running time and storage. That high dimensionality also offers opportunities to find effective ways to decrease running time or reduce it.⁠[1]

A different answer to the same problem is the word embedding, a learned representation in which each word becomes a dense vector of real numbers rather than a sparse one-hot column. Embeddings are produced by deep neural networks and are valued for capturing high-level semantic and syntactic properties of words, so that words used in similar ways end up near each other in the vector space. Because the vectors are learned from large amounts of text rather than hand-designed for one task, they remove the need for task-specific feature engineering, and in a clinical classification setting they were found to significantly outperform tf-idf and topic modeling features.⁠[3]

Bag-of-words and TF-IDF count terms and discard order; embeddings replace the counts with learned dense vectors that carry meaning but are harder to interpret.

Classifiers: from naive Bayes to deep networks

Once documents have been turned into vectors, the remaining question is which procedure reads those vectors and produces a label. That procedure is the classifier, the function that maps a document's numerical representation to a predicted category. Classifiers differ in what they assume about the data and in the kind of pattern they can pick up, and the choice among them is one of the practical decisions in building a text classification system.

The simplest family is naive Bayes, a probabilistic classifier built on the assumption that every feature is independent of every other one given the category.⁠[10] In text terms, that means treating each word as contributing evidence for a label without regard to the words around it. The assumption is plainly false for natural language, where meaning depends on combinations of words, and naive Bayes has a history of disappointing results on automatic text classification. It remains useful as a baseline, a simple model against which more elaborate ones are measured, and adjustments to how its parameters are estimated have been shown to bring its performance up to compete with far more complex methods on standard benchmark collections.⁠[11]

Support vector machines take a different route. SVMs are among the common classifiers for text, alongside naive Bayes, KNN, decision trees, and random forests.⁠[1] The intuition is that a boundary with a wide margin around it is more likely to place new, unseen documents on the correct side than one that merely threads between the training examples.

Random forests belong to a family called ensembles, which combine many simple models into one decision. Random forests are among the common classifiers for text, alongside naive Bayes, KNN, decision trees, and SVMs.⁠[1] The ensemble version trades some interpretability for stability, since no single tree's reasoning describes the whole prediction.

These conventional models share a two-step structure: features are extracted from the documents first, and those features are then fed to the classifier to make a prediction.⁠[1] Deep learning models collapse the two steps into one. They learn their own internal representation of the text and perform the classification in an end-to-end fashion, so the features are discovered during training rather than designed in advance.⁠[1] This is what allows them to pick up patterns that a fixed representation like bag-of-words would flatten away.

Two deep architectures dominate the text literature. A convolutional neural network (CNN) uses convolutional layers and maximum pooling layers to extract higher-level features.⁠[12] It is well suited to spotting informative fragments wherever they occur. LSTM models can capture long-term dependencies between word sequences and are better used for text classification.⁠[12] The two are complementary, and a combined model called C-LSTM uses a CNN to extract higher-level phrase representations and feeds them into an LSTM, capturing both local phrase features and the global, temporal semantics of the sentence; on sentiment and question classification it outperformed either architecture alone.⁠[13]

Recurrent models can also be strengthened by attention, a mechanism that lets the model weight different parts of the text according to how relevant they are to the decision rather than compressing everything into a single state. An attention-based hybrid combining a bidirectional LSTM with a CNN produced more accurate classification, along with higher recall and F1 scores, than individual multilayer perceptron, CNN, or LSTM models as well as the hybrid models, on movie review data.⁠[12]

The most recent family is the transformer, an architecture built entirely around attention rather than recurrence or convolution. The key idea behind transformers is attention.⁠[8] Large transformers are first pretrained on vast amounts of general text and then fine-tuned, meaning further trained on a smaller labeled set for the specific classification task. Fine-tuning a pretrained transformer has been studied in detail, and a general recipe for it obtained new state-of-the-art results on eight widely studied text classification datasets.⁠[14] Systems built this way have been applied to spotting fake news and flagging hate speech. BERT is trained on BookCorpus, text corpus, and Wikipedia but somewhere lacks domain-related and task-related knowledge.⁠[8]

Conventional classifiers read features a person designed; deep networks learn their own, and transformers learn them from general text before ever seeing the task.

Conventional models extract features before classifying, while deep models learn features during training.

Uses

Applications across domains

Sorting news and opinion

Two white digital clinical thermometers lie side by side on a dark surface, each displaying a body temperature reading of about 36 degrees, with the brand names AFEC and Hartmann visible on them.
Two white digital clinical thermometers lie side by side on a dark surface, each displaying a body temperature reading of about 36 degrees, with the brand names AFEC and Hartmann visible on them. View full-size image.Koortsthermometers-AFEC-0120-Lot240901+Hartmann-0123-Lot3499 by Biol. Public domain, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The most direct use of text classification is to put documents where a reader can find them. News is a natural case: it arrives in enormous volume from many sources, and a monitoring system needs to route each item into subject groups automatically rather than have someone read it first. The same machinery underlies sentiment analysis, the automatic discovery of opinions in text and their sorting into positive, negative, or neutral according to the emotion expressed.⁠[1] A company that wants to know how its products are being received can point a sentiment classifier at reviews and posts instead of reading them one by one, which is why the technique appears wherever organizations face more text than people can read.

The applications spread well beyond news and reviews. Text classification has been used to gather data from news sources for forecasting movements in asset volatility, to survey disease, to analyze travelers' sentiments in tourism, and to predict commercial success by evaluating users' reviews.⁠[1] Each of these is the same task wearing different clothes: a stream of text, a fixed set of categories, and a decision about which category each document belongs to. What changes from one domain to the next is the vocabulary, the balance of the classes, and how much labeled data is available to start from.

Catching what is false or harmful

Some of the most visible applications are defensive. Fake news and fake reviews, sometimes grouped together as opinion spam, are deceptive texts written to mislead, and the difficulty is that even a person often cannot tell a genuine review from a fabricated one.⁠[15] That makes the problem a natural fit for automatic classification: if human judgment struggles, a system trained on many examples may pick up regularities that a reader misses. Work in this area has built an n-gram model, which treats short runs of adjacent words as the features, to detect fake content automatically, comparing feature extraction techniques and several machine learning classifiers on public datasets and a newly introduced fake news collection.⁠[15]

The same shape of problem appears in the detection of hate speech and other harmful content on social media, where large amounts of user-generated posts are produced. Transfer learning classification models have been applied to COVID-19 fake news and extremist-non-extremist datasets. Transfer learning can use information gained from unlabeled data in related tasks with a small labeled dataset.⁠[8]

Reading clinical notes

Medicine offers perhaps the clearest case of text that is both valuable and locked away. When hospitals adopted electronic health records, large amounts of detailed patient information began to accumulate electronically, including laboratory tests, medications, disease status, and treatment outcomes.⁠[3] Much of the most important detail, however, sits inside clinical text such as notes and progress reports rather than in tidy fields. Clinical text classification is the application of the same task to that material, extracting structured information from the narratives, and it has been used for phenotyping algorithms, detection of adverse events, improvement of healthcare quality, and support for genomics research.⁠[3]

The clinical setting also shows why the choice of method is not merely technical. Symbolic approaches, which apply handcrafted expert rules such as regular expressions and logic rules, have proved effective in the clinical domain because clinical language has its own regular sublanguage. The catch is that such applications are labor expensive to develop, requiring collaboration between language experts and healthcare professionals, and the result may not carry over beyond the use case it was designed for.⁠[3]

Labeling topics and other tasks

A quieter but widespread use is topic modeling, an unsupervised method that learns the collection of underlying themes in a batch of documents together with how strongly each document relates to each theme. Because it needs no labeled examples, it can be applied to a batch of documents without predefined labels. Related tasks include question answering, where a system takes a request in ordinary language and returns a brief answer rather than a list of results, and language translation, where classifiers trained on texts in several languages help produce equivalent meaning across them.⁠[1] These sit alongside the sorting tasks above as different questions asked of the same underlying machinery.

The same task, text in and category out, serves newsrooms, marketing teams, moderators, and clinicians; what differs is the vocabulary, the labels, and how the examples are obtained.

Research

Evidence on performance and comparisons

Comparing methods on the same task

Clinical documents branch into rule-generated labels and embedding features that feed CNN training, beside an inference chain and a two-row F1 results table.
Rules generate noisy labels while pretrained embeddings provide features for CNN training. The reported study achieved F1 scores of 0.92 and 0.97 on two clinical tasks, with benefits dependent on training size and task complexity. View full-size image.Weak Supervision for Clinical Classification by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Claims that one classifier is better than another mean little on their own, because performance depends on the data, the labels, and what counts as success. The useful evidence comes from studies that hold the task fixed and vary the method. Even then, the results tend to be conditional rather than universal, and reading them well means asking which conditions produced which winner.

A clear example comes from marketing research, where automated classification is used to sort social media text into categories such as sentiment. One comparison set ten approaches against each other, five lexicon-based and five machine learning algorithms, across 41 social media datasets that varied in platform, sample size, and language.⁠[4] A lexicon-based method here means one that assigns categories by looking words up in a predefined dictionary of sentiment or meaning, rather than learning from labeled examples. The finding was not a single champion.

Either a random forest or a naive Bayes classifier performed best at reproducing human judgment, with random forest consistently strong for three-class sentiment and naive Bayes holding up on small samples, while the support vector machine never beat the remaining methods. The lexicon-based approaches, and one widely used dictionary in particular, performed poorly next to the machine learning methods, in some applications reaching accuracies only slightly above chance.⁠[4] The practical lesson is that the choice of method interacts with the shape of the task: how many classes there are, and how much labeled data exists.

Pretrained transformers against conventional models

The arrival of pretrained transformers raised the question of whether the older feature-based pipeline is still worth building. A transformer is a network built around attention, which lets it relate every word in a text to every other word at once; BERT is a well-known pretrained transformer of this kind. One study tested BERT directly against the traditional approach of turning text into TF-IDF vectors and feeding those to machine learning models, across a suite of scenarios designed to vary the conditions of the problem. BERT came out ahead, and its advantage held independently of features of the problem such as the language of the text.⁠[16] That independence is the interesting part: a conventional pipeline needs its features and preprocessing tuned to the language and domain, whereas a pretrained model arrives having already absorbed a great deal of general language.

The comparison is not settled in every setting, though, and the exceptions are instructive. A separate line of work asked whether a transformer could handle clinical documents several thousand words long, since BERT by default can only take input sequences of roughly 400 words. The researchers introduced four methods for scaling it to longer documents and compared them against two much simpler architectures, a word-level convolutional neural network and a hierarchical self-attention network, on discharge summaries and cancer pathology reports. BERT often could not beat those simpler baselines. The likely reason is that in these tasks the correct label may depend on spotting a few key words or phrases rather than on understanding the meaning of long stretches of text, which is where the transformer's pretraining and its word-splitting tokenization may work against it.⁠[17] A method that wins on general benchmarks can lose on a task whose signal is narrow and local.

Learned rules against written rules

The clinical domain also offers a direct test of learning versus handcrafting. In one paradigm, a rule-based language processing algorithm was used to generate labels automatically for the training data, and pretrained word embeddings supplied the features, so that a machine learning model was trained on labels a program had produced rather than ones a person had written.⁠[3] This is called weak supervision, because the training labels are noisy approximations rather than careful human judgments.

On two institutional tasks at Mayo Clinic, smoking status classification and hip fracture classification, a convolutional neural network trained this way reached F1 scores of 0.92 and 0.97 respectively, and it outperformed the rule-based algorithm that had generated its labels. The interpretation is that the network learned patterns beyond the rules, picking up on semantically similar words that the rules never listed. The same study found the advantage conditional: the network was more sensitive to the size of the training data than the rule-based algorithm and the conventional models, and the approach was less effective on a complex multiclass task.⁠[3] How training size changes the picture is taken up later.

What the input itself can carry

One assumption worth testing is that words are the right unit to classify. A character-level convolutional network takes raw characters as input rather than whole words, so it can exploit spelling, punctuation, and word fragments. When such networks were built and tested on several large datasets constructed for the purpose, they achieved state-of-the-art or competitive results, and the comparisons were run against bag-of-words, n-gram and TF-IDF variants as well as word-based networks and recurrent models.⁠[18] The result shows that the choice of representation, not only the choice of classifier, can decide how well a task is solved.

Domain can also invert an expected ranking. A study of literary texts compared naive Bayes and support vector machines on two tasks, classifying Dickinson's poems by eroticism and chapters of early American novels by sentimentalism. Outside the literary domain, SVMs had generally been found better than naive Bayes, but here SVMs were not the winners on both: the two algorithms both did well on the sentimental chapters, while naive Bayes outperformed the SVM on the erotic poem classification. The study also found that arbitrary feature-reduction steps such as stemming and stopword removal should be applied cautiously, since some stopwords turned out to be highly discriminative for that poem task.⁠[19] A preprocessing choice treated as routine can erase exactly the signal a particular collection depends on.

Comparisons between classifiers hold only for the task, data, and metric that produced them; the same method can win on one collection and lose on another.

Risks and limits

Limits, risks, and failure modes

A text classifier is only as good as the examples it learns from, and those examples are the most expensive part of the whole enterprise. Labeling a document requires someone who understands the subject to read it and record the right answer, and doing that at the scale a modern model needs takes extensive human effort.⁠[3] The problem sharpens in domains where the text is sensitive. Clinical notes are hard to share because of privacy, so few public collections exist, and annotating them accurately requires medical knowledge, which rules out the usual shortcut of hiring crowds of general workers to do the tagging.⁠[3] A system can be built and still be unusable in practice if the labeled material it needs cannot be obtained.

The same scarcity shows up as class imbalance, the situation in which one category vastly outnumbers another in the training data. Combining training data from several compatible sources may be particularly useful where data sets are heavily imbalanced.⁠[20] Imbalance is not a flaw in the algorithm so much as a mismatch between the data's shape and the question being asked.

Overfitting is the related failure in which a model learns the particular documents it was trained on rather than the general pattern behind them. Adversarial training, which perturbs the input slightly during learning, has been extended to text by perturbing word embeddings rather than the raw words, and the resulting models were found to be less prone to overfitting while their learned embeddings improved in quality.⁠[21]

How much data a model needs is itself a limit, and it varies sharply by method. A deep model is not simply better; it is better once it has enough examples, and below that threshold the older methods hold their ground.

Interpretability is the limit that bites when a classifier's decision has to be explained. A rule-based system states its reasoning in rules a person can read, add to, and correct. A deep network does not, and the same study that showed a network beating its own generating rules also noted that deep models inherently lack interpretability compared with rule-based algorithms.⁠[3]

Domain shift is the failure that appears when a model meets text unlike what it was trained on. Clinical practice and workflow vary across institutions, so a language system that performs well in one hospital may need its rules redesigned for the next, while a learned model may not need extra modification because it learns its rules automatically.⁠[3] Whether that portability holds in practice is still an open question.

Deliberate manipulation is a further risk. In a backdoor attack, an adversary poisons a small portion of the training data so that the trained model misclassifies any input containing a specific trigger while behaving normally otherwise. Against an LSTM-based text classifier, poisoning just one percent of the training data produced roughly a 96 percent success rate at forcing triggered samples into the attacker's chosen category, and the injected backdoor had little effect on the model's ordinary performance, which is what makes it hard to notice.⁠[5]

Privacy closes the list. Homomorphic encryption allows computation on data while it stays encrypted, and a system built on it performed inference on encrypted inputs with no loss of prediction accuracy compared with the unencrypted version, at a running time of 0.17 seconds per inference, though training a model on encrypted data took 5.04 days.⁠[22] The protection is real; so is the cost.

The limits of a classifier trace back to its examples: too few, too skewed, too unlike the real world, or too easy to poison.

Later developments

Current directions and open problems

Doing more with less labeled text

A black background with rows of colored circles in blue, green, and red arranged in a pattern of clusters.
A black background with rows of colored circles in blue, green, and red arranged in a pattern of clusters. View full-size image.GNN representational limits by NickDiCicco. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The cost of labeled examples has pushed research toward methods that squeeze more out of fewer of them. Transfer learning is the general strategy of taking what a model learned on one task or corpus and reusing it on another, so that a small labeled set can be handled with knowledge already acquired elsewhere. The intuition is familiar: a system already trained to recognize apples can, with modest adjustment, be turned to recognizing pears, needing less data and less training time than starting fresh.⁠[8] Pretrained transformers are the most prominent instance, and the review literature now treats deep models that learn their own representations as the dominant approach to classification tasks such as sentiment analysis and news categorization.⁠[7]

Few-shot learning takes the idea further, aiming at settings where only a handful of labeled instances exist per class. A review of this work in the medical domain found 51 relevant articles, all published after 2018 and most since 2020, with concept extraction the most frequently addressed task and text classification second. The same review reported that benchmarking experiments showed few-shot methods underperforming on biomedical language tasks relative to what might be hoped, a shortfall the authors attributed in part to the rarity of specialized data and the lack of standardized evaluation.⁠[23] Few-shot learning is thus promising and unfinished at once: the need is real wherever annotated text is scarce, but the methods have not yet reliably delivered on it.

Data augmentation attacks the same shortage from the data side, creating additional training examples artificially by transforming existing ones. A survey of the area divides more than 100 methods into twelve groupings and relates them to one another, noting that augmentation can serve goals beyond sheer volume, including regularizing the model and limiting how much data is used in order to protect privacy.⁠[24] The appeal is that a transformation costs computation rather than annotation time.

Structure beyond the sequence

Most classifiers treat a document as a sequence of words, or as a bag of them. Graph neural networks offer a different frame: text can be cast as a graph whose nodes are words, documents, or corpus-level features and whose edges capture relations among them, letting a model exploit global structure rather than only local order. A survey of this line of work covers both corpus-level and document-level graph networks, describing how the graphs are constructed and how learning proceeds over them, and reports published performance on public benchmarks.⁠[25] The approach matters because some regularities in a collection are relational rather than sequential, and a graph is a natural way to represent them.

Making the decision legible

As models grow more capable, the difficulty of explaining their decisions grows with them. A broad survey of the field identifies explainable AI as one of the directions requiring further innovation, alongside hybrid methodologies and scalable approaches for low-resource languages.⁠[26] The concern is practical rather than abstract: a classifier whose reasoning cannot be inspected is hard to audit, hard to correct, and hard to trust in settings where a decision carries consequences. The same survey frames the challenges of class imbalance and overfitting as persistent, and points to hybrid methods that combine learned models with other techniques as a promising direction.⁠[26]

Languages and settings with little data

The final open problem is coverage. Much of the published work concerns English, and the tools and datasets that make classification easy in one language do not automatically exist in another. The survey above singles out scalable approaches for low-resource languages as an area needing work, and the medical review reaches a compatible conclusion from a different angle: creating publicly available, specialized datasets may aid method development by making comparative analyses possible.⁠[26][23] In both cases the bottleneck is not an algorithm but the material an algorithm needs, which is why the field's progress on the hardest settings depends as much on collecting and sharing data as on inventing new models.

The frontier is less about new architectures than about needing less: fewer labels, less data, fewer languages left out, and more of the decision explained.

Key studies

YearStudySampleDesignFinding
1994Apté et al.⁠[2]the Reuters document collectionoptimized rule-based induction on large document collectionsMachine-generated decision rules raised the recall/precision breakeven point from a previously reported 67% to 80.5%.
2008Yu⁠[19]Dickinson's poems and chapters of early American novelscomparison of naive Bayes and support vector machines with three preprocessing toolsNaive Bayes outperformed the support vector machine on erotic poem classification, while both reached high accuracy on sentimental chapter classification.
2015Sarker & Gonzalez⁠[20]three annotated datasets, one from clinical reports and two from social mediafeature-rich classification with multi-corpus trainingADR F-scores were 0.812, 0.538, and 0.678, and combining corpora raised the in-house scores to 0.597 and 0.704.
2019Hartmann et al.⁠[4]41 social media datasets covering major platforms, various sample sizes, and languagescomparison of ten text classification methodsRandom forest or naive Bayes performed best on every task, and support vector machines never outperformed the remaining methods.
2019Wang et al.⁠[3]two Mayo Clinic tasks and the i2b2 2006 smoking status shared taskweak supervision with rule-generated labels and deep representationA convolutional network reached F1 scores of 0.92 and 0.97 on the institutional tasks but only 0.77 on the small public task.
2019Dai et al.⁠[5]IMDB movie reviewsblack-box backdoor attack by data poisoning against an LSTM classifierThe attack achieved around 96% success rate with 1% poisoning rate and little impact on clean-data performance.
2020Badawi et al.⁠[22]various public natural language processing datasetstext classification on fully homomorphic encrypted dataInference took 0.17 seconds per item with zero loss to prediction accuracy, and training on an encrypted dataset took 5.04 days.
2021Gao et al.⁠[17]comparison of scaled BERT methods against simpler architecturesBERT often could not beat a word-level convolutional network or a hierarchical self-attention network on long clinical documents.
2023Garrido-Merchan et al.⁠[16]four text classification scenarios in English, Portuguese, and Chineseempirical comparison of BERT against TF-IDF features fed to machine learning modelsBERT reached accuracy of 0.9381 on Chinese hotel reviews against 0.7399 for the best traditional model.
2023Ge et al.⁠[23]51 articles published after 2018review of few-shot learning for medical textText classification was addressed in 16 of 51 articles, and benchmarking showed relative underperformance of few-shot methods on biomedical tasks.

See also

References

  1. Dogra, V., Verma, S., Kavita, Chatterjee, P., Shafi, J., Choi, J., & Ijaz, M. F. (2022). A Complete Process of Text Classification System Using State-of-the-Art NLP Models. Computational Intelligence and Neuroscience, 2022, 1-26. doi:10.1155/2022/1883698
  2. Apté, C., Damerau, F., & Weiss, S. M. (1994). Automated learning of decision rules for text categorization. ACM Transactions on Information Systems, 12(3), 233-251. doi:10.1145/183422.183423
  3. Wang, Y., Sohn, S., Liu, S., Shen, F., Wang, L., Atkinson, E. J., Amin, S., & Liu, H. (2019). A clinical text classification paradigm using weak supervision and deep representation. BMC Medical Informatics and Decision Making, 19(1). doi:10.1186/s12911-018-0723-6
  4. Hartmann, J., Huppertz, J., Schamp, C., & Heitmann, M. (2019). Comparing automated text classification methods. International Journal of Research in Marketing, 36(1), 20-38. doi:10.1016/j.ijresmar.2018.09.009
  5. Dai, J., Chen, C., & Li, Y. (2019). A Backdoor Attack Against LSTM-Based Text Classification Systems. IEEE Access, 7, 138872-138878. doi:10.1109/access.2019.2941376
  6. Kobayashi, V. B., Mol, S. T., Berkers, H. A., Kismihók, G., & Den Hartog, D. N. (2018). Text Classification for Organizational Researchers: A Tutorial. Organizational Research Methods, 21(3), 766-799. doi:10.1177/1094428117719322
  7. Minaee, S., Kalchbrenner, N., Cambria, E., Nikzad, N., Chenaghlu, M., & Gao, J. (2022). Deep Learning--based Text Classification: A Comprehensive Review. ACM Computing Surveys, 54(3), 1-40. doi:10.1145/3439726
  8. Qasim, R., Bangyal, W. H., Alqarni, M. A., & Ali Almazroi, A. (2022). A Fine-Tuned BERT-Based Transfer Learning Approach for Text Classification. Journal of Healthcare Engineering, 2022, 1-17. doi:10.1155/2022/3498123
  9. Kowsari, K., Jafari Meimandi, K., Heidarysafa, M., Mendu, S., Barnes, L., & Brown, D. (2019). Text Classification Algorithms: A Survey. Information, 10(4), 150. doi:10.3390/info10040150
  10. Xu, S. (2018). Bayesian Naïve Bayes classifiers to text classification. Journal of Information Science, 44(1), 48-59. doi:10.1177/0165551516677946
  11. Sang-Bum Kim, Kyoung-Soo Han, Hae-Chang Rim, & Sung Hyon Myaeng (2006). Some Effective Techniques for Naive Bayes Text Classification. IEEE Transactions on Knowledge and Data Engineering, 18(11), 1457-1466. doi:10.1109/tkde.2006.180
  12. Jang, B., Kim, M., Harerimana, G., Kang, S. u., & Kim, J. W. (2020). Bi-LSTM Model to Increase Accuracy in Text Classification: Combining Word2vec CNN and Attention Mechanism. Applied Sciences, 10(17), 5841. doi:10.3390/app10175841
  13. Zhou, C., Sun, C., Liu, Z., & Lau, F. C. M. (2015). A C-LSTM Neural Network for Text Classification. arXiv. doi:10.48550/arxiv.1511.08630 Free full text
  14. Sun, C. C., Qiu, X., Xu, Y., & Huang, X. (2019). How to Fine-Tune BERT for Text Classification? arXiv. doi:10.48550/arxiv.1905.05583 Free full text
  15. Ahmed, H., Traore, I., & Saad, S. (2018). Detecting opinion spams and fake news using text classification. SECURITY AND PRIVACY, 1(1). doi:10.1002/spy2.9
  16. Garrido-Merchan, E. C., Gozalo-Brizuela, R., & Gonzalez-Carvajal, S. (2023). Comparing BERT Against Traditional Machine Learning Models in Text Classification. Journal of Computational and Cognitive Engineering, 2(4), 352-356. doi:10.47852/bonviewjcce3202838
  17. Gao, S., Alawad, M., Young, M. T., Gounley, J., Schaefferkoetter, N., Yoon, H. J., Wu, X. C., Durbin, E. B., Doherty, J., Stroup, A., Coyle, L., & Tourassi, G. (2021). Limitations of Transformers on Clinical Text Classification. IEEE Journal of Biomedical and Health Informatics, 25(9), 3596-3607. doi:10.1109/jbhi.2021.3062322
  18. Zhang, X., Zhao, J., & LeCun, Y. (2015). Character-level Convolutional Networks for Text Classification. arXiv. doi:10.48550/arxiv.1509.01626 Free full text
  19. Yu, B. (2008). An evaluation of text classification methods for literary study. Literary and Linguistic Computing, 23(3), 327-343. doi:10.1093/llc/fqn015
  20. Sarker, A., & Gonzalez, G. (2015). Portable automatic text classification for adverse drug reaction detection via multi-corpus training. Journal of Biomedical Informatics, 53, 196-207. doi:10.1016/j.jbi.2014.11.002
  21. Miyato, T., Dai, A. M., & Goodfellow, I. (2016). Adversarial Training Methods for Semi-Supervised Text Classification. arXiv. doi:10.48550/arxiv.1605.07725 Free full text
  22. Badawi, A. A., Hoang, L., Mun, C. F., Laine, K., & Aung, K. M. M. (2020). PrivFT: Private and Fast Text Classification With Homomorphic Encryption. IEEE Access, 8, 226544-226556. doi:10.1109/access.2020.3045465
  23. Ge, Y., Guo, Y., Das, S., Al-Garadi, M. A., & Sarker, A. (2023). Few-shot learning for medical text: A review of advances, trends, and opportunities. Journal of Biomedical Informatics, 144, 104458. doi:10.1016/j.jbi.2023.104458
  24. Bayer, M., Kaufhold, M. A., & Reuter, C. (2023). A Survey on Data Augmentation for Text Classification. ACM Computing Surveys, 55(7), 1-39. doi:10.1145/3544558
  25. Wang, K., Ding, Y., & Han, S. C. (2024). Graph neural networks for text classification: a survey. Artificial Intelligence Review, 57(8). doi:10.1007/s10462-024-10808-0
  26. Allam, H., Makubvure, L., Gyamfi, B., Graham, K. N., & Akinwolere, K. (2025). Text Classification: How Machine Learning Is Revolutionizing Text Categorization. Information, 16(2), 130. doi:10.3390/info16020130

Cite this page: Atlas Nova editors. (2026). Text classification. Atlas Nova. https://velocer.io/atlas/text-classification/