Book a free call

How to Implement Named Entity Recognition Step by Step

Named entity recognition finds people, organisations, places and dates in text. Here is how to implement it, from types to labelling data and measuring results.

Hertiv engineering teamReviewed by a senior engineer
6 min read
How to Implement Named Entity Recognition Step by Step
On this page

Short answer

To implement named entity recognition, define the entity types you need, gather and label example text, pick a model or rule-based approach, train or configure it, and measure it per entity type on a held-out test set. Start with one text type and a few hundred labelled examples before expanding.

What is named entity recognition?

Named entity recognition is the task of finding and labelling named things in text, such as people, organisations, places, dates and product names. A model reads a sentence and marks which words are a person, which are a company and which are a date.

It matters because most business text is unstructured. Contracts, tickets, emails and reports hold names and dates that software cannot use until something pulls them out. Named entity recognition turns that text into fields a database can store and search.

The output is usually a list of spans: each span has a start, an end and a type. For example, in "Acme Corp signed the deal on 12 March", the model marks "Acme Corp" as an organisation and "12 March" as a date. Everything else in the sentence stays unlabelled.

What does an NER system need?

An NER system needs four things before it can work: a clear list of entity types, labelled example text, a model or rule set, and a way to measure it. Skipping any of the four is the usual reason projects stall.

Part What it is Typical choice
Entity types The labels to find Person, organisation, place, date
Labelled data Text with marked spans A few hundred documents
Model What finds the spans Small transformer or rules
Evaluation set Text kept aside for testing 20 percent of labelled data

Keep the type list short at first. Four to six types that cover most of the value are easier to label well than twenty types that overlap and confuse annotators. You can add types later once the first set works.

For the wider language picture, NLP development covers how extraction fits into a larger pipeline.

How to implement NER in 6 steps

Implement NER in this order, testing each step before moving on. Rushing to a model before the data is ready is the most common way to waste a month.

  1. Define the types. Write down each entity type, give two or three examples, and note the edge cases, such as whether a product name counts as an organisation.
  2. Collect example text. Gather a few hundred real documents of the type you will process, and remove anything you are not allowed to use.
  3. Write a labelling guide. One page that shows how to mark each type, with examples of tricky cases. Two people labelling the same text should agree most of the time.
  4. Label a first batch. Label a few hundred documents by hand, then check agreement between labellers and fix the guide where they disagree.
  5. Train or configure the model. Start with a small pre-trained model and fine-tune it on your labels, or use rules for types that follow a fixed pattern, such as dates.
  6. Measure per type. Test on text the model has never seen, and report precision and recall for each type separately, not just one overall score.

Rules and models can work together. Dates, reference numbers and emails often follow a fixed pattern, so rules handle them well, while people and organisation names need a trained model. Mixing the two is normal, not a compromise.

Labelling: the part that decides quality

Labelling quality decides most NER projects. A model can only learn what the labels show it, so inconsistent labels produce an inconsistent model no matter how good the training setup is.

Start by labelling a small batch with two people and comparing their work. Where they disagree, the guide is unclear, not the people. Fix the guide, relabel the disputed cases and repeat until agreement is high enough to trust.

Label in short sessions with regular checks. Tired labellers drift, and drift shows up as a model that is confident about the wrong spans. A short review of a sample each week catches drift before it spreads through the whole dataset.

Keep a record of every labelling decision that was hard. Those notes become the guide for the next batch and the evidence for why the model behaves the way it does. For the definition and the main approaches, what named entity recognition is is a useful reference.

How to measure whether it works

Measure NER with precision and recall per entity type. Precision is the share of spans the model found that were correct. Recall is the share of true spans it managed to find. Both matter, and the balance between them depends on the job.

A support team that routes tickets can live with lower recall if precision is high, because a missed name just means a human checks. A compliance check that must catch every date cannot live with low recall, because a missed date is a missed obligation.

Always test on text the model has never seen, from the same source as the real work. Testing on the training data flatters the model and hides the mistakes it will make in production. Report the numbers per type, because a model can score well on people and badly on dates, and one average hides that.

Set a threshold before launch, such as a minimum precision per type, and do not ship below it. A model that is wrong about names in a customer-facing product does more damage than a slower manual process.

Example (hypothetical): extracting names from contracts

Example (hypothetical): a legal team wants to pull party names, dates and amounts from 500 contracts. They label 200 contracts by hand, with each contract holding about 12 entities, which gives 2,400 labelled spans to train on.

Labelling takes about 10 minutes per contract, so 200 contracts take about 33 hours of labelling time. They split the work across two reviewers over two weeks, checking agreement on a shared sample of 20 contracts first.

After training, the model finds 85 out of every 100 true entities and gets 90 out of every 100 spans it marks right. On the remaining 300 contracts, that means roughly 3,060 of 3,600 entities found, with a human reviewing the uncertain ones. The team saves the reading time on the clear cases and spends review time only where the model is unsure.

The arithmetic is simple; the hard part is the labelling guide. If two reviewers disagree on what counts as an organisation, the model learns both answers and trusts neither.

Common mistakes when implementing NER

Most NER failures come from data and measurement, not from model choice. Teams pick too many types, label too little data and then cannot tell whether the system is improving.

  • Defining twenty entity types before the first four work
  • Labelling without a written guide, so two people disagree
  • Testing on training data and trusting the flattering score
  • Reporting one average instead of per-type precision and recall
  • Using a large model when rules would handle dates and numbers
  • Skipping the human review step for low-confidence spans
  • Training on news text and deploying on contracts

If you are planning an extraction project and want a clear view of the cost, named entity recognition cost covers the budget side.

Key takeaways

  • Start with four to six entity types that cover most of the value.
  • Labelling quality decides the result more than model choice.
  • Measure precision and recall per type, never as one average.
  • Rules handle dates and numbers well; models handle names better.
  • Test on unseen text from the same source as the real work.

Frequently asked questions

How much labelled data does NER need?

A few hundred documents is a useful start for a narrow text type with four to six entity types. More types and more varied text need more labels. Quality matters more than volume: a small, consistently labelled set beats a large, inconsistent one.

Should I use rules or a trained model for NER?

Use rules for types with a fixed pattern, such as dates, emails and reference numbers. Use a trained model for people and organisation names, which vary too much for rules. Most working systems mix the two.

What is a good precision and recall for NER?

It depends on the job. A routing task can live with lower recall if precision is high, while a compliance check needs high recall so nothing is missed. Set a minimum per type before launch and do not ship below it.

Can I use a large language model instead of NER?

A large model can extract entities, but it is slower and costlier per document and its output needs checking. A small trained NER model is cheaper and more predictable for one repeated extraction job at volume.

Why does my NER model work on news but fail on contracts?

Because the text is different. Models learn the patterns of the text they trained on, so a model trained on news will miss contract language. Train on the same kind of text you will process in production.

How long does it take to implement NER?

A narrow first version typically takes a few weeks when the text is ready: a week for the guide and first labels, a week for training and measurement, and time for review tooling. Messy or restricted data adds the most delay.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning an extraction project and unsure where to start?

A senior engineer replies within one business day. Or see our NLP Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call