Token classification is a core natural language processing task where a model assigns a predefined label to every atomic unit—typically a word or subword—in an input sequence. Unlike document-level classification, this token-level granularity enables the precise identification of clinical entities such as drug names, dosages, and diseases within a sentence. The process relies on contextual embeddings from transformer models to disambiguate tokens based on surrounding words, making it the foundational step in medical named entity recognition pipelines.
Glossary
Token Classification

What is Token Classification?
Token classification is the natural language processing task of assigning a categorical label to each individual token in a text sequence, forming the fundamental mechanism for extracting structured information from unstructured clinical narratives.
In clinical workflows, token classification models are trained using annotation schemes like BIO tagging, where each token is marked as the Beginning, Inside, or Outside of an entity span. Modern architectures often replace traditional Conditional Random Fields with direct span categorization to handle nested entities. The output feeds downstream tasks including concept normalization to UMLS CUIs and negation detection via algorithms like NegEx, ensuring extracted clinical facts are both structured and contextually accurate for prior authorization automation and clinical decision support.
Key Characteristics of Token Classification
Token classification is the fundamental NLP task that powers medical entity extraction by assigning a label to every atomic unit of text. Understanding its core characteristics is essential for building robust clinical NLP pipelines.
Token-Level Granularity
Operates at the most atomic level of text—individual tokens—rather than on sentences or documents. Each token receives its own label, enabling precise boundary detection for clinical entities.
- A token is typically a word, subword, or punctuation mark
- Enables exact span identification for entities like 'metastatic renal cell carcinoma'
- Contrasts with document-level classification, which assigns a single label to an entire text
- Critical for clinical use cases where the exact mention location matters for audit trails
BIO Tagging Schema
The standard annotation format uses Beginning, Inside, Outside tags to demarcate entity spans. A token labeled B-DRUG starts a medication entity, I-DRUG continues it, and O marks non-entity tokens.
- Enables unambiguous span reconstruction from token-level predictions
- Variants include BIOES (adding End and Single tags) for richer boundary signals
- Example: 'ibuprofen 400 mg' →
B-DRUG I-DRUG B-DOSAGE I-DOSAGE - Invalid sequences (e.g.,
I-DRUGwithout a precedingB-DRUG) are automatically detectable
Contextual Dependency
Token labels depend heavily on surrounding context. The word 'cold' might be labeled as a B-SYMPTOM in 'patient reports cold extremities' but as O in 'apply cold compress'.
- Requires models that capture bidirectional context, such as transformers
- Contextual embeddings like those from BioBERT dynamically represent tokens based on their sentence
- Polysemous clinical terms demand this contextual awareness for accurate disambiguation
- Shortcut learning on spurious correlations (e.g., always labeling 'mg' as dosage) must be guarded against
Sequence-Level Constraints
Valid predictions must respect transition rules between adjacent labels. A CRF decoding layer explicitly models these dependencies, preventing impossible sequences like an I-DISEASE tag directly following an O tag.
- CRFs learn transition probabilities from training data
- Improves structural consistency of predicted entity spans
- Modern span-based approaches bypass this by classifying spans directly
- Ensures output is syntactically valid before downstream clinical processing
Domain-Specific Vocabulary
Clinical text contains highly specialized terminology—drug names, anatomical terms, abbreviations—that general-domain tokenizers and models handle poorly. Subword tokenization like WordPiece mitigates out-of-vocabulary issues.
- 'Hepatosplenomegaly' might be tokenized into ['hepat', '##ospl', '##enome', '##galy']
- Domain-adapted models like BioBERT and PubMedBERT are pre-trained on biomedical corpora
- Custom gazetteers and dictionaries supplement statistical models for rare entities
- Abbreviation expansion (e.g., 'CHF' → 'congestive heart failure') is often a preprocessing step
Evaluation with F1 Score
Performance is measured at the entity level, not the token level. A predicted entity is correct only if both its span boundaries and its type exactly match the ground truth. The F1 score balances precision and recall.
- Strict exact-match evaluation penalizes boundary errors (e.g., missing 'left' in 'left ventricular hypertrophy')
- Relaxed metrics like partial credit or type-only matching exist for specific use cases
- Inter-Annotator Agreement (IAA) establishes the human performance ceiling
- Typical clinical NER systems achieve F1 scores of 0.85–0.95 on well-defined entity types
Token Classification vs. Related NLP Tasks
Distinguishing token-level labeling from other core NLP tasks in clinical text processing.
| Feature | Token Classification | Sequence Classification | Span Categorization |
|---|---|---|---|
Granularity | Token-level | Sequence-level | Span-level |
Output per input | One label per token | One label per sequence | One label per span |
Clinical example | B-Drug, I-Drug, O | Document is a Radiology Report | Span 'metastatic carcinoma' = Diagnosis |
Handles overlapping entities | |||
Handles nested entities | |||
Typical architecture | BiLSTM-CRF, Transformer+Softmax | BERT+[CLS] classifier | SpanBERT, Pointer Networks |
Annotation scheme | BIO/BIOES tags | Single categorical label | Span boundaries + type |
Granularity of error analysis | Per-token misclassification | Document-level misclassification | Per-span boundary error |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about token classification and its foundational role in medical named entity recognition.
Token classification is a natural language processing task that assigns a categorical label to each individual token in a text sequence. In the clinical domain, this mechanism forms the foundational layer for identifying entities like drugs, diseases, and procedures within unstructured medical records. The process begins with a tokenizer (such as WordPiece Tokenization) that segments a sentence like 'The patient was prescribed Metformin 500mg twice daily' into discrete units. A model then processes these tokens through contextual embeddings—dynamic vector representations that capture semantic meaning based on surrounding words. Finally, a classification layer, often a linear classifier or a Conditional Random Field (CRF), predicts a label for each token. The standard annotation scheme is BIO Tagging, where 'B-Medication' marks the beginning of a drug entity, 'I-Medication' marks its continuation, and 'O' marks tokens outside any entity. This token-by-token prediction is the core mechanism enabling downstream tasks like concept normalization and clinical entity linking.
Related Terms
Token classification is the atomic unit of clinical NLP. These related terms define the architectures, encoding schemes, and evaluation frameworks that transform raw token labels into actionable medical intelligence.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us