Named entity recognition (NER) is a natural language processing (NLP) task that finds names in text and labels each one with a type. Typical types are people, organizations, places, dates, and money amounts.
NER is a subtask of information extraction, the wider field of pulling structured facts out of free text. An NER system returns a list of spans: a span is the exact stretch of characters that holds an entity. Each span comes with a label and character offsets, so unstructured text becomes structured records your code can store, filter, and join.
The "named entity" task was defined for the Sixth Message Understanding Conference (MUC-6), with the formal evaluation held in September 1995. The MUC-6 conference history reports that "the highest-scoring system had a recall of 96% and a precision of 97%." Those scores came from Wall Street Journal text, and 15 teams took part in the task.
A Named Entity Recognition Example
A named entity recognition example makes the output concrete. Take this sentence:
Apple hired Jane Doe in Berlin on 3 March 2026 for $2 million.
Annotated inline, an NER model marks five entities:
[ORG Apple] hired [PERSON Jane Doe] in [GPE Berlin] on [DATE 3 March 2026] for [MONEY $2 million].
GPE stands for geopolitical entity, a label for countries, cities, and states. A developer usually receives the same result as JSON:
[
{ "text": "Apple", "label": "ORG", "start": 0, "end": 5 },
{ "text": "Jane Doe", "label": "PERSON", "start": 12, "end": 20 },
{ "text": "Berlin", "label": "GPE", "start": 24, "end": 30 },
{ "text": "3 March 2026", "label": "DATE", "start": 34, "end": 46 },
{ "text": "$2 million", "label": "MONEY", "start": 51, "end": 61 }
]The start and end fields are character offsets. start is the index of the first character, and end is the index just after the last one, so text[0:5] returns "Apple".
Offsets matter more than the label for many pipelines. They let you highlight entities in a UI and check that each entity really exists in the source. They also let you link an entity back to the exact passage it came from.
What Types of Entities Does NER Recognize?
NER recognizes whatever types its training data defines. Most models start from one of two public label sets, and teams add custom labels when their domain needs them.
The CoNLL-2003 shared task paper says the task concentrated on "four types of named entities: persons, locations, organizations and names of miscellaneous entities." OntoNotes 5.0 is larger. A study of OntoNotes 5.0 reports that "The English NER portion of this corpus consists of 3,637 documents, covering 2 million tokens, annotated with 18 named entity types."
The example above uses OntoNotes-style labels, so Berlin is tagged GPE rather than LOC. The table below shows illustrative labels and examples; exact definitions vary by dataset and model.
| Label | Meaning | Example | Label set |
|---|---|---|---|
| PER / PERSON | People, including fictional ones | Jane Doe | CoNLL-2003 / OntoNotes 5.0 |
| ORG | Companies, agencies, institutions | Apple | CoNLL-2003 / OntoNotes 5.0 |
| LOC | Non-political places, such as mountains and rivers | the Alps | CoNLL-2003 / OntoNotes 5.0 |
| GPE | Countries, cities, states | Berlin | OntoNotes 5.0 |
| MISC | Names outside the other CoNLL types | German (nationality) | CoNLL-2003 |
| DATE | Absolute or relative dates | 3 March 2026 | OntoNotes 5.0 |
| MONEY | Monetary values with units | $2 million | OntoNotes 5.0 |
| PERCENT | Percentages | 12% | OntoNotes 5.0 |
| PRODUCT | Objects, vehicles, software | iPhone 15 | OntoNotes 5.0 |
| EVENT | Named events | CES 2026 | OntoNotes 5.0 |
Custom labels cover what public datasets skip. A pharmacy app may need DRUG and DOSAGE. A web-data project may need COMPANY, JOB_TITLE, SKU, or PRICE pulled from product and team pages.
How Does Named Entity Recognition Work?
Named entity recognition works in three stages. An NER system splits raw text into tokens, labels each token, and groups labeled tokens into entity spans. The model that does the labeling is called an NER model.
Tokenization and BIO Tagging
Tokenization splits text into tokens, which are words, numbers, and punctuation marks. The model then gives each token one tag from a scheme called BIO tagging.
BIO stands for Begin, Inside, and Outside. B- marks the first token of an entity, and I- marks each following token of that entity. O marks tokens outside any entity.
| Token | Tag | Why |
|---|---|---|
| Apple | B-ORG | First token of an organization |
| hired | O | Not an entity |
| Jane | B-PERSON | First token of a person |
| Doe | I-PERSON | Continues the same person |
| in | O | Not an entity |
| Berlin | B-GPE | First token of a place |
| on | O | Not an entity |
| 3 | B-DATE | First token of a date |
| March | I-DATE | Continues the date |
| 2026 | I-DATE | Continues the date |
| for | O | Not an entity |
| $ | B-MONEY | First token of an amount |
| 2 | I-MONEY | Continues the amount |
| million | I-MONEY | Continues the amount |
| . | O | Not an entity |
BIO handles multi-word names. Without the B-/I- split, "Jane Doe" and two separate people standing side by side would get the same tags.
Classification and Span Assembly
The model classifies each token by reading the words around it as well as the token itself. "Apple" next to "hired" looks like a company, while "apple" next to "ate" does not.
Span assembly comes next. Code joins each B- tag with the I- tags that follow it into one entity. It then records the start and end offsets.
Post-processing cleans the result. Common steps include merging broken spans, fixing stray I- tags with no B- before them, and normalizing values. For example, "3 March 2026" can become 2026-03-03.
Approaches to Building an NER System
NER systems have gone through four generations. Each one trades some control for more flexibility.
Rule-Based and Dictionary Methods
Rule-based NER uses hand-written patterns and lists. Regular expressions catch fixed formats, and gazetteers, which are lists of known names, catch entities like country or brand names.
Rules are precise, cheap, and easy to debug. They break when text drifts from the pattern, so they work best for emails, SKUs, phone numbers, and dates.
Statistical and Deep Learning Models
Statistical and deep learning models learn tagging from labeled examples instead of rules. Conditional random fields (CRFs) came first, then neural BiLSTM-CRF models, and then transformers such as BERT.
Fine-tuning means further training a pretrained model on labeled NER data. Fine-tuned models, including large generative models trained on labeled NER data, score in the low-to-mid 90s F1 on the CoNLL-2003 English news benchmark. In the GNER benchmark paper, on CoNLL-2003, fine-tuned GNER-LLaMA-7B scored 93.60 F1 versus 52.5 F1 for zero-shot ChatGPT.
spaCy NER is a common starting point for named entity recognition in Python. This snippet runs the small English model on the example sentence:
# pip install spacy
# python -m spacy download en_core_web_sm
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple hired Jane Doe in Berlin on 3 March 2026 for $2 million.")
entities = [
{"text": ent.text, "label": ent.label_, "start": ent.start_char, "end": ent.end_char}
for ent in doc.ents
]
print(entities)The output has the same shape as the JSON above. The small model can still miss or mislabel entities, so compare its results against hand-labeled samples from your own data.
Large Language Models and Zero-Shot NER
Large language models (LLMs) can tag entities from a prompt with no training data. You list the labels you want, paste the text, and ask for JSON. This is called zero-shot NER, and adding a few worked examples to the prompt makes it few-shot.
Studies from 2023 and 2024 found that LLMs of that period trailed fine-tuned models. Of LLMs, the GPT-NER study says "its performance on NER is still significantly below supervised baselines." Its best few-shot GPT-3 setup reached 90.91 F1 on CoNLL-2003, against 94.6 for the supervised state of the art.
That setup retrieved its examples with a fine-tuned NER model, so it was not plain prompting. The same study found the opposite result with tiny datasets. With only 8 labeled sentences, few-shot GPT-3 scored about 60 F1, while the supervised model scored about 0.
GLiNER sits between the two. It is a small encoder model, published at NAACL 2024, that takes your label names as input and tags matching spans without retraining. The GLiNER paper reports that "even our smallest model, with only 50M parameters, outperforms general-purpose models such as ChatGPT and Vicuna."
That result covers zero-shot average F1 on a 7-dataset out-of-domain benchmark: 52.7 for the 50M model versus 47.5 for ChatGPT (2023). GLiNER does not match fine-tuned models on CoNLL-2003, where its largest version scored 64.6 F1 zero-shot. The English-only GLiNER model also trailed ChatGPT on a multilingual benchmark average (23.6 vs 29.9 F1).
LLM output has a practical risk. An LLM can return an entity that does not appear in the text, or cut a name at the wrong boundary. Check that each returned string exists in the source and recompute its offsets in code.
How to Choose an NER Approach
Choose an NER approach by how much labeled data you have, how often your labels change, and what each request can cost. No single option wins on every criterion.
| Approach | Labeled data needed | Label flexibility | Cost per request | Latency | Typical failure |
|---|---|---|---|---|---|
| Rule-based | None; you write patterns | Low; each label needs new rules | Lowest | Lowest | Misses text that breaks the pattern |
| Fine-tuned model (spaCy, BERT) | Labeled examples for every label | Low; new labels need retraining | Low | Low | Drops in F1 on text unlike its training data |
| GLiNER | None for zero-shot | High; labels are passed at run time | Low; a small model you host | Low to moderate | Lower F1 than fine-tuned models on standard benchmarks |
| LLM prompting | None to a few examples | Highest; labels live in the prompt | Highest | Highest | Invented entities and wrong span boundaries |
The cost and latency ratings are relative, general estimates, not measured benchmarks.
Cost and latency evidence comes from a neighboring task. A 2026 cost-aware model selection study examined text classification, not NER. It found "fine-tuned encoder-based models from the BERT family achieve competitive, and often superior, classification performance while operating at one to two orders of magnitude lower cost and latency."
A practical path follows from the table:
- Stable labels and steady volume: Fine-tune a spaCy or BERT model, and use rules for fixed formats like SKUs.
- Changing or custom labels: Start with GLiNER and fine-tune later once you have labeled data.
- Prototypes and tiny datasets: Prompt an LLM, verify spans in code, and use its output as draft training labels.
How NER Is Measured: Precision, Recall, and F1
NER is measured with precision, recall, and F1 at the entity level. Under exact-match scoring, a predicted entity counts as correct only if both its span and its label match the gold label.
The gold labels are the human-annotated answers. The three metrics compare the model's entities against them:
- Precision: The share of predicted entities that are correct.
- Recall: The share of gold entities the model found.
- F1: The harmonic mean of precision and recall, which drops sharply if either one is low.
Here is a worked example. A sentence has 4 gold entities, and the model predicts 5, of which 3 match exactly.
| Metric | Formula | Result |
|---|---|---|
| Precision | 3 correct / 5 predicted | 0.60 |
| Recall | 3 correct / 4 gold | 0.75 |
| F1 | 2 × 0.60 × 0.75 / (0.60 + 0.75) | 0.67 |
Exact match is strict. Predicting "Jane" when the gold span is "Jane Doe" counts as one false positive and one false negative.
Benchmark scores come from clean news text like CoNLL-2003. Your data will differ, so hand-label a sample of your own sentences and score each candidate model on it before you commit.
Running NER on Web Pages
Running NER on web pages starts with cleaning the page, because tagging models were trained on clean prose and raw HTML is not. Entity extraction quality on the web depends on the input text as much as on the model.
Raw HTML mixes article text with navigation menus, scripts, cookie banners, and ads. A model tags "Home", "Login", and footer company names as if they were content. JavaScript-heavy pages may also need browser rendering before the main text exists in the HTML at all.
A web NER pipeline has five steps:
- Fetch the page, rendering JavaScript where the page needs it.
- Strip boilerplate and convert the main content to clean Markdown or plain text.
- Run the NER model on the cleaned text.
- Store the source URL and fetch timestamp with every entity.
- Deduplicate entities that repeat across pages.
Step 4 is provenance, the record of where each fact came from. It lets you re-check an entity, refresh it when the page changes, and show users the source.
Olostep handles the input side of this pipeline and does not provide an NER model. Its scrape endpoint renders JavaScript-heavy pages and returns clean Markdown. Its batches process large URL lists asynchronously, so your NER model receives clean text.
The guide to preparing LLM-ready web data covers the cleaning step in depth. When you need fields instead of free text, you can convert HTML into structured JSON before any tagging happens.
NER vs. Entity Linking vs. Schema-Based Extraction
NER, entity linking, and schema-based extraction produce different outputs. NER finds and labels spans, entity linking decides which real-world thing a span refers to, and schema-based extraction fills predefined fields.
Entity linking maps a span to one record in a knowledge base, such as Wikidata or your CRM. It resolves "Apple" to the company, not the fruit. Schema-based extraction takes a schema, such as name, price, and release_date, and returns typed JSON from a page.
| Criterion | NER | Entity linking | Schema-based extraction |
|---|---|---|---|
| Output | Labeled spans with offsets | Spans mapped to unique IDs | Typed JSON fields |
| Question answered | "What names are in this text?" | "Which exact entity is this?" | "What is the value of each field?" |
| Required input | Text and a label set | NER spans and a knowledge base | A page and a schema |
| Handles ambiguity | No | Yes | Partly, through field definitions |
| Typical use | Tagging, search filters, analytics | Deduplication, knowledge graphs | Product data, lead records, prices |
Use NER when you need every mention of a type across free text. Add entity linking when one name can mean different things. Choose schema extraction when you know the exact fields you want from each page.
Within schema extraction, the choice is between parsers versus LLM extraction. Parsers suit recurring runs on stable page layouts, while LLM extraction suits one-off schemas and fuzzy structure.
Where Named Entity Recognition Is Used
Named entity recognition is used wherever text needs to become filterable records. Most production uses fall into five groups:
- Search and RAG: NER tags chunks with companies, people, and dates, so retrieval can filter by entity before ranking.
- Lead enrichment: NER pulls company names, people, and roles from prospect websites into CRM records.
- Content tagging and news monitoring: NER tags articles by the organizations and places they mention, which supports alerts and topic pages.
- Healthcare and legal review: NER flags drug names, conditions, parties, and dates in long documents for human reviewers.
- E-commerce attributes: NER and schema extraction pull brands, materials, and sizes from product pages.
Teams building sales lead enrichment pipelines combine entity extraction from prospect pages with structured fields like headcount or location. The data is only as current as the last crawl, so the fetch timestamp matters.
For e-commerce, the Merchkit catalog enrichment case study is a vendor-published example of structured attribute extraction from retailer pages. Merchkit reported 94% faster enrichment, 5× more SKUs optimized per month, and a 10× cost reduction after moving to Olostep.
Common NER Challenges
NER models fail most often on ambiguous names, nested entities, new domains, non-English text, and noisy input.
- Ambiguity: "Jordan" can be a person, a country, or a brand, and the model must decide from context.
- Nested entities: "Bank of America Tower" is a building that contains an organization, and flat BIO tags can mark only one.
- Domain shift: A model trained on news may miss gene names, legal citations, or product codes it never saw.
- Non-English text: Multilingual models exist, but scores can be lower than on English benchmarks, and some languages have little labeled data.
- Noisy input: Messy text lowers scores; the same GNER benchmark paper reports supervised scores of about 67 F1 on the TweetNER7 tweet dataset.
Frequently Asked Questions About Named Entity Recognition
What Are the Main Types of Named Entities?
The main types are person, organization, and location, plus value types such as dates, money, and percentages. Many projects also add custom labels, such as SKU or job title.
What Is the Best Model for Named Entity Recognition?
The best model depends on your labeled data, label stability, and budget. Fine-tuned models such as spaCy or BERT suit stable labels, while GLiNER or LLM prompting suit labels that change often.
Is Named Entity Recognition the Same as Entity Extraction?
The two terms are often used interchangeably. Entity extraction can also include entity linking and normalization, while NER strictly means finding and labeling spans.
Does NER Work in Languages Other Than English?
Yes, multilingual models and language-specific models handle NER in many languages. Results may be lower than on English benchmarks such as CoNLL-2003, depending on the language and available training data.
How Much Labeled Data Do I Need to Train an NER Model?
The amount depends on your labels and domain, and zero-shot or few-shot options like GLiNER and LLM prompting need little or none. Fine-tuning still improves with more labeled examples, especially for custom labels.
Can I Use an LLM for Named Entity Recognition?
Yes, an LLM can tag entities from a prompt and return JSON. Verify that each entity appears in the source text, and compare its cost and latency with a smaller model before scaling up.



