← Back to list

Understanding Token Classification in NLP: From Words to Meaning

1. Introduction to NLP & Token Classification

Sai Kadiravan S · 2026-04-06 09:10 · 0 claps · 4.5 min read
#nlp #bert #token #pos-tagging #chunking
Open on Medium ↗
Wiki topics: ML · Machine Learning

Understanding Token Classification in NLP: From Words to Meaning

1. Introduction to NLP & Token Classification

Natural Language Processing (NLP) is a field of Artificial Intelligence that focuses on enabling machines to understand, interpret, and generate human language. From chatbots to search engines, NLP powers many applications we use daily.

One of the most important tasks in NLP is Token Classification.

1.1 What is Token Classification?

Token classification is the process of assigning labels to individual words (tokens) in a sentence. Instead of understanding the sentence as a whole, the model analyzes each word and determines its role.

For example:

  • Sentence: “Sudeep lives in Bangalore”

Token Classification Output:

  • Sudeep → Person
  • lives → Verb
  • Bangalore → Location

1.2 Why is Token-Level Understanding Important?

Understanding individual words helps machines:

  • Extract meaningful information
  • Understand sentence structure
  • Perform accurate predictions

1.3 Real-World Applications

  • Chatbots: Identify user intent and key entities
  • Search Engines: Improve query understanding
  • Information Extraction: Extract names, dates, locations from text

2. Named Entity Recognition (NER)

2.1 What is NER?

Named Entity Recognition (NER) is a token classification task that identifies and classifies entities in text into predefined categories such as:

  • Person
  • Location
  • Organization
  • Date

2.2 BIO Tagging Concept

NER often uses the BIO tagging format:

  • B (Beginning) — Start of an entity
  • I (Inside) — Continuation of an entity
  • O (Outside) — Not part of any entity

Example:

Sentence: “Virat Kohli lives in India”

Tags:

  • Virat → B-PER
  • Kohli → I-PER
  • lives → O
  • in → O
  • India → B-LOC

2.3 Examples

  1. Cristiano Ronaldo plays for Portugal”
  • Cristiano Ronaldo → Person
  • Portugal → Location
  1. Google is based in California”
  • Google → Organization
  • California → Location

Applications

  • Resume parsing
  • News analysis
  • Healthcare data extraction
  • Financial document processing

3. Part-of-Speech (POS) Tagging

3.1 What is POS Tagging?

POS tagging assigns grammatical labels to each word in a sentence, such as noun, verb, adjective, etc.

3.2 Types of POS Tags

Common POS tags include:

  • Noun (NN)
  • Verb (VB)
  • Adjective (JJ)
  • Adverb (RB)
  • Pronoun (PRP)
  • Preposition (IN)

3.3 Examples

1. “A beautiful girl sings”

  • beautiful → Adjective
  • girl → Noun
  • sings → Verb

**2. **“The smart boy studies”

  • smart → Adjective
  • boy → Noun
  • studies → Verb

3.4 Importance

  • Helps in understanding sentence structure
  • Essential for grammar checking
  • Improves machine translation
  • Aids in syntactic parsing

4. Chunking (Phrase Detection)

4.1 What is Chunking?

Chunking, also known as shallow parsing, groups words into meaningful phrases such as noun phrases (NP) or verb phrases (VP).

Instead of tagging individual words, chunking identifies phrases.

4.2 Examples

  1. The small cat is sleeping on the sofa”
  • [The small cat] → Noun Phrase (NP)
  • [is sleeping] → Verb Phrase (VP)
  • [on the sofa] → Prepositional Phrase (PP)
  1. “She bought a new laptop”
  • [She] → NP
  • [bought] → VP
  • [a new laptop] → NP

4.3 Difference from NER

  • NER identifies entities (like names, places)
  • Chunking identifies phrases (like noun phrases)

4.4 Use Cases

  • Syntax analysis
  • Question answering systems
  • Text summarization
  • Speech recognition

5. Comparison of Techniques

5.1 Part-of-Speech (POS) Tagging

POS Tagging is the most granular level of token classification. Its primary objective is to assign a functional category to every single word in a sentence based on its relationship with adjacent words. It doesn’t care about “what” a thing is in the real world, but rather “how” it functions within the rules of a language. This is crucial for resolving ambiguity; for example, the word “record” can be a noun (a physical disc) or a verb (the act of capturing sound), and POS tagging uses surrounding context to decide which it is.

  • Example: In the sentence “She will present (VB) the present (NN) now,” POS tagging identifies the first “present” as a verb and the second as a noun.

5.2 Named Entity Recognition (NER)

NER moves beyond the mechanics of grammar to identify specific “entities” that have a distinct identity in the real world. While POS tagging identifies a word as a “Proper Noun,” NER goes a step further to specify if that noun represents a person, a multi-national corporation, a geographic location, or a specific value of currency. This is generally more complex than POS tagging because it often requires looking at multiple tokens together and understanding the broader context to distinguish between entities with the same name.

  • Example: In the sentence Steve Jobs (PER) founded Apple (ORG) in California (LOC),” NER classifies the specific people, companies, and places rather than just labeling them as nouns.

5.3 Chunking

Chunking, or “Shallow Parsing,” sits between POS tagging and full dependency parsing. Instead of looking at individual words or specific named entities, it seeks to group tokens into meaningful phrases or “chunks.” Its goal is to find the logical clusters in a sentence, such as Noun Phrases (NP) or Verb Phrases (VP), without necessarily worrying about the internal grammatical details of every word. It is particularly useful for identifying the “subject” and “action” of a sentence quickly, which is often more useful for text summarization than knowing every individual part of speech.

  • Example: In the sentence “The large, red balloon floated away,” chunking would group [The large, red balloon] into a single Noun Phrase (NP) and [floated away] into a Verb Phrase (VP).

5.4 Key Differences

  • NER focuses on what the word represents
  • POS Tagging focuses on how the word functions
  • Chunking focuses on grouping words into phrases

6. Code Implementation (Bonus)

Here’s a simple example using spaCy:

import spacy
# Load model
nlp = spacy.load("en_core_web_sm")
text = "Apple is looking at buying a startup in India"
doc = nlp(text)
# NER
print("Named Entities:")
for ent in doc.ents:
    print(ent.text, ent.label_)
# POS Tagging
print("\nPOS Tags:")
for token in doc:
    print(token.text, token.pos_)
# Chunking
print("\nNoun Chunks:")
for chunk in doc.noun_chunks:
    print(chunk.text)

7. Transformer-Based Approach (BERT)

Traditional NLP methods relied on rules or statistical models. However, modern systems use transformers like BERT (Bidirectional Encoder Representations from Transformers).

7.1 How BERT Works for Token Classification

  • BERT processes the entire sentence context simultaneously
  • Each token gets a contextual embedding
  • A classification layer predicts the label for each token

7.2 Advantages

  • Understands context better (e.g., “bank” as riverbank vs financial bank)
  • Handles long dependencies
  • Improves accuracy in NER, POS, and chunking tasks

7.3 Example

Sentence: “Amazon released a new product”

  • BERT understands “Amazon” as an organization, not a river

Conclusion

Token classification is a fundamental concept in NLP that allows machines to understand language at a deeper level. Tasks like NER, POS tagging, and chunking each play a unique role in processing text, from identifying entities to understanding grammar and sentence structure.

With the rise of transformer models like BERT, token classification has become more accurate and powerful, enabling smarter applications such as chatbots, recommendation systems, and intelligent search engines.


메타데이터
post_id
6c17ea06add8
slug
understanding-token-classification-in-nlp-from-words-to-meaning-6c17ea06add8
url
https://medium.com/@saikadiravan11/understanding-token-classification-in-nlp-from-words-to-meaning-6c17ea06add8
canonical_url
https://medium.com/@saikadiravan11/understanding-token-classification-in-nlp-from-words-to-meaning-6c17ea06add8
author_url
https://medium.com/@saikadiravan11
status
ok
fetched_at
2026-07-30 07:28:10