Picture a reader who automatically highlights, in a news article, every person's name in blue, every city in green and every company in orange. That is precisely the job of Named Entity Recognition (NER): a foundational natural language processing task that locates spans of text and then classifies them into predefined categories.
What NER identifies
NER systems typically detect entities such as:
- PER — people ("Fatima Zahra")
- LOC / GPE — locations and geopolitical entities ("Casablanca", "Morocco")
- ORG — organizations ("OCP", "Tavily")
- MISC — dates, amounts, percentages
For example, in "OCP invests 2 billion in Jorf Lasfar", a NER model tags OCP as ORG, 2 billion as a monetary value and Jorf Lasfar as LOC.
How it works
NER is usually framed as a sequence labeling problem: every token receives a tag following the BIO scheme (Begin, Inside, Outside). Historically conditional random fields (CRFs) were used; today Transformer-based models such as BERT dominate, leveraging bidirectional context.
Evaluation relies on the F1 score, the harmonic mean of precision and recall:
$$F_1 = 2 \cdot \frac{P \cdot R}{P + R}$$
Why it matters
| Domain | Application |
|---|---|
| Media monitoring | Spot companies and figures mentioned |
| Healthcare | Extract drugs and symptoms |
| Finance | Detect firms and amounts |
| Search engines | Understand the user's query |
NER turns raw text into structured data: it is the first building block toward a machine that does not merely read words, but understands who and what is being discussed.