AI Glossary / AI and machine learning / Beginner

Document classification

Definition

Document classification assigns one or more category labels to a document based on its content or other relevant information. It can be performed by people, rules or machine-learning systems to support organization, retrieval and workflow routing.

What it means

A business may need to distinguish invoices from contracts, sort support messages by topic or identify reports relevant to a team. Classification turns those categories into explicit outputs for each document.

Some tasks require one label, while others allow several. A report can concern both procurement and sustainability. The label definitions determine what counts as correct, so category design is part of the task rather than a detail left until after training.

Classification is different from extracting specific fields, summarizing a document or discovering groups without predefined labels. A system may combine these operations, but each needs its own evaluation.

How it works

Documents are prepared for analysis, which may include text extraction or optical character recognition. The system represents content through word features, embeddings, layout information or another suitable form.

A classifier or rule set maps that representation to labels. Scores can support a threshold for automatic assignment or referral to human review.

Evaluation uses representative unseen documents and checks errors by class. Near-duplicate documents, shared templates and metadata can make a random split misleading if they reveal the answer in ways unavailable or unreliable in deployment.

Three practical examples

  • An accounts team routes incoming files into invoice, purchase-order and other-document queues.
  • A knowledge-management team assigns overlapping subject tags to reports for search and browsing.
  • A support operation classifies messages by issue type before sending them to an appropriate reviewer.

Think of it this way

Think of a mailroom sorting envelopes into labeled trays after inspecting their contents and relevant markings.

The analogy has limits. A model can rely on accidental cues, such as a sender signature or template, rather than the intended topic. A familiar tray label does not make its automated assignments trustworthy.

Worked example

Evaluating the class that matters

Suppose a fictional test set contains 900 routine documents and 100 urgent documents. A classifier labels every document routine. It is correct on 900 of 1,000, giving 90% accuracy.

That attractive percentage hides complete failure to identify urgent documents: urgent-class recall is zero. If urgent routing is the main business need, the system is unsuitable despite its overall score.

The team instead examines a confusion matrix and per-class precision and recall. It also measures how many uncertain cases are sent for review and whether reviewers can manage the volume.

The example shows why evaluation must reflect the category distribution and consequences of mistakes. The numbers are invented, and they do not prescribe a universal threshold or acceptable error rate for document processing.

Illustrative case study

A fictional consulting firm builds a classifier for proposal, report and contract documents. Initial results are unusually strong because each category was collected from a different folder and the folder name entered the model as metadata.

New uploads do not have those labels. The team removes the shortcut, separates related document versions across the evaluation design appropriately and tests files from a later period.

Reviewers also resolve ambiguous category definitions, such as reports that include a proposal appendix. The case illustrates that a useful classifier depends on clear labels and realistic inputs, not only the choice of language model or algorithm.

Common misconceptions and mistakes

  • Treating high overall accuracy as sufficient: rare important classes can be missed.
  • Confusing classification with field extraction: assigning “invoice” does not verify the invoice total.
  • Ignoring duplicate or template leakage: evaluation can reward memorized formatting.
  • Forcing every ambiguous document into a confident label: a review or unknown category may be necessary.

Business use

Document classification can reduce manual sorting and improve access to information when labels correspond to useful actions. It is often an entry point for document automation because outputs are easy to inspect.

Start with clear label definitions and a representative review set. Compare a simple baseline with more complex models, including processing cost and latency. Decide what happens when text extraction fails, a document spans several categories or the system encounters a new type. Monitor category-specific errors as templates and business processes change.

People also ask

Must documents be plain text?

No. Systems can use OCR, layout and other signals, depending on the task.

Can one document receive several labels?

Yes. That is a multi-label classification setting.

Is clustering the same thing?

No. Clustering discovers groups, while classification usually assigns predefined categories.

Check your understanding

A classifier achieves 90% accuracy by assigning every document to the majority class. What additional check reveals whether it handles the minority class?

Answer: Inspect the confusion matrix and minority-class recall and precision. Overall accuracy alone can conceal complete failure on that category.

Related terms

  • Text classification
  • Multi-label classification
  • Confusion matrix
  • OCR
  • TF-IDF

Learn next

Read precision and recall. Define the document categories for one workflow and create an evaluation set containing ambiguous, rare and newly formatted examples.

More in AI and machine learning

  • Discriminator - A discriminator is the judging half of a generative adversarial network, the model that learns to tell real examples from fakes while its partner, the...
  • Distributional Soft Actor Critic - Distributional Soft Actor Critic, or DSAC, is a family of off-policy reinforcement-learning methods for continuous control that combines maximum-entropy...
  • Divisive clustering - Divisive clustering is a top-down approach to grouping data: start with everything in one cluster and repeatedly split the least coherent group until each...
  • Domain adaptation - Domain adaptation adjusts a machine-learning system so that knowledge learned from one data setting can be useful in another.
  • Dominance-based rough set approach - The dominance-based rough set approach, or DRSA, analyses decisions involving ordered criteria and ordered outcome classes.
  • Double delta feature - A double delta feature is the change of a change: it measures how quickly a measurement is speeding up or slowing down, rather than how fast it is simply...

Sources

Scikit-learn developers, Classification of text documents using sparse features: https://scikit-learn.org/stable/auto_examples/text/plot_document_classification_20newsgroups.html. Official example sections on confusion matrices, metadata stripping and classifier benchmarking read. The metadata shortcut and evaluation scope were checked against those sections. All business cases and counts are original illustrations; the majority-class calculation was independently checked.

Previous: Document-at-a-time Next: Document clustering

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer