Neural Sync Active
Named Entity Recognition with Sequence Labeling
Registry Synced
Named Entity Recognition with Sequence Labeling
630 words
3 min read
Reading compass
Now · 🎯 Learning Objectives
Named Entity Recognition with Sequence Labeling
🎯 Learning Objectives
- Identify entity types (Person, Location, Organization, etc.)
- Apply BIO tagging scheme for sequence labeling
- Extract features for NER classification
- Implement a CRF-based NER system
📋 Prerequisites
- Sequence labeling concepts
- Feature engineering basics
- POS tagging (helps understand tagging)
1. 📖 Core Content
1.1 What is NER?
Named Entity Recognition identifies and classifies named entities in text:
| Entity Type | Examples |
|---|---|
| Person | "Sachin Tendulkar", "Einstein" |
| Location | "Mumbai", "Mount Everest" |
| Organization | "Google", "UNESCO" |
| Date | "January 2024", "last Tuesday" |
| Money | "$1 billion", "₹500" |
| Percentage | "25%", "half" |
1.2 BIO Tagging
Each token gets a tag:
- B-ORG: Beginning of an Organization entity
- I-ORG: Inside (continuation of) an Organization
- O: Outside (not an entity) Example: "Google was founded in Mountain View"
- Google/B-ORG was/O founded/O in/O Mountain/B-LOC View/I-LOC
1.3 Feature Engineering for CRF
Traditional NER uses Conditional Random Fields (CRF) with features:
| Feature Type | Examples | Context Window |
|---|---|---|
| Word identity | word[i] = "Google" | Current |
| POS tag | POS[i] = NNP | Current |
| Capitalization | is_upper(word[i]) | Current |
| Prefix/Suffix | word[i][:3] = "Goo" | Current |
| Previous tags | tag[i-1] = B-ORG | Previous |
| Word shape | "Xxxxx" for "Google" | Current |
| Gazetteer | is_in_org_list(word[i]) | External |
📝 Practice Questions
</details> * * * ## 🔗 Cross-References - **Next**: [Word Embeddings](/notes/04-degree-electives-bsda5005-nlp-week05-05-word-embeddings) - **Previous**: [Parsing](../week03/03-parsing-syntax.md) - **Video**: BSDA5005 Week 4 transcripts [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**POS Tagging**](/notes/04-degree-electives-bsda5005-nlp-week02-02-pos-tagging)[Next**Word Embeddings**](/notes/04-degree-electives-bsda5005-nlp-week05-05-word-embeddings)Q1: Tag "Barack Obama was the 44th president of the United States" with BIO tags.Barack/B-PER Obama/I-PER was/O the/O 44th/O president/O of/O the/O United/B-LOC States/I-LOCNote: "United States" is a multi-word location entity. "44th" is not an entity (it's a number, but not typically NER). The title "president" is not tagged as an entity type in standard NER. Q2<strong>Q2<strong>Q2</strong>: Why can't we use a standard multiclass classifier for NER instead of sequence labeling (CRF/BiLSTM)?A standard classifier predicts each token independently, missing:
- Label dependencies: I-PER cannot follow B-LOC (violates BIO constraints)
- Long-range context: "Obama" being B-PER affects the tagging of "Barack"
- Consistency: Same word in different positions should relate to each other
CRFs model transition probabilities between tags (e.g., B-PER → I-PER has high probability, I-LOC → I-PER has ~0 probability). Neural models (BiLSTM-CRF, Transformer) learn these dependencies automatically.Independent classification would predict "Barack/O Obama/O" because it doesn't use the constraint that adjacent tags must be consistent. Q3<strong>Q3<strong>Q3<strong>Q3<strong>Q3</strong>: The word "Apple" could be B-ORG (company) or O (fruit). How does context disambiguate?Context features that help:
- Surrounding words: "Apple released" → likely B-ORG (company). "Apple pie" → likely O (fruit)
- Capitalization: Both start with capital, so not distinguishing here
- Domain: Technology news → likely company. Cooking recipes → likely fruit
- Entity density: "Apple, Google, and Microsoft" → all organizations
A good NER model learns these contextual cues from training data. The ambiguity is why NER needs context — looking at "Apple" alone isn't enough. Q4<strong>Q4<strong>Q4<strong>Q4<strong>Q4<strong>Q4</strong>: How does a BiLSTM-CRF model for NER combine LSTM and CRF advantages?BiLSTM: Processes the sequence bidirectionally, capturing rich context from both directions. Outputs a score for each tag at each position.CRF layer: Learns transition constraints between tags (e.g., B-PER → I-PER is valid, O → I-PER is invalid). At inference, Viterbi decoding finds the optimal tag sequence.Combined advantages:
- BiLSTM provides rich contextual features (word-level, character-level)
- CRF ensures globally consistent tag sequences
- End-to-end training jointly optimizes both components
The Viterbi score at training time: score = ∑(emission + transition) — the model learns to maximize the score of the correct tag sequence.