- Type
- NLP sequence-labelling task
What does it do?
Named entity recognition (NER) is a natural-language-processing task that detects and labels entities in text, such as people, organisations, locations, and dates.
It turns running text into tagged spans that downstream tools can use. Nadeau and Sekine (2007) present a survey of the field, and Lample et al. (2016) present neural architectures for NER.
The intuition behind the method
A document mentions names, places, and dates in ordinary prose, but a machine sees only a stream of words. The goal of NER is to find the spans that refer to real-world entities and attach the right type label to each one. Instead of a person reading and highlighting names by hand, the method scans the text, decides which words form an entity, and tags it as a person, an organisation, a location, a date, and so on.
History
Nadeau and Sekine (2007), 'A survey of named entity recognition', is an overview of the field. Lample et al. (2016), 'Neural Architectures for Named Entity Recognition', published at NAACL, is the reference for the neural sequence-labelling approach to NER covered on this page.
When to use it
Choose NER when the question is which spans of digitised running text refer to typed entities such as people, organisations, locations, or dates. With very little labelled data, a rule-based or dictionary approach is often a practical starting point. It returns matches of listed terms rather than learned entity boundaries, so its recall depends on how complete the lists are. Rule-based grammars can be very effective, but they require experienced computational linguists to write and maintain, and they are often domain-specific. Trained or neural taggers need labelled examples, and statistical models in particular need a significant amount of training data. A model fitted to very few examples may not generalise. If you need relations between entities, use relation extraction, and if you need document-level labels, use text classification. If no language model covers the language of your text, expect poor recognition.
Limitations and considerations
- On a very small corpus a trained model's performance drops, and a rule-based or dictionary approach may be the more practical option.
- Recognition quality depends on whether the language model covers the language of the text.
- Entity boundaries depend on tokenisation and sentence splitting, so noisy text with poor segmentation produces wrong spans even when the tagger itself is sound.
- Entity types can be ambiguous: the same string may be a place name in one context and an organisation in another, so the type label can be wrong even when the span is found.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The output is a list of typed text spans, which can be passed directly to indexing, relation extraction, or other downstream steps.
- Three approaches are available on one task: rule-based matching for narrow vocabularies, machine-learning sequence labelling when labelled examples exist, and neural sequence labelling for larger corpora.
- Many taggers label several entity classes in one pass, but accuracy can differ between classes, so report each class separately.
Applications
- Extracting people, organisations, and locations from news and reports for indexing.
- Identifying named entities in clinical or biomedical text for structured records.
- Mining mentions of companies, places, and dates from large document collections.
- Feeding tagged entities into downstream information- and relation-extraction pipelines.
How it works
How it works
The raw text is cleaned and segmented into analysable units: sentences are split and words are tokenised, so that entity boundaries are located against consistent units. Noisy or poorly tokenised text makes boundaries unreliable, so this step cannot be skipped.
Each token is converted into features the model can read. Depending on the approach this means hand-written rules and gazetteers, classic feature vectors, or contextual embeddings from a neural model. Each gives the tagger the signal it needs to recognise whether a token belongs to an entity.
The model assigns an entity-type label to each token span. A rule-based approach matches patterns and dictionaries, a machine-learning approach uses a trained sequence labeller, and a neural approach applies an architecture that captures context. The output is a set of text spans tagged with types such as person, organisation, location, and date.
The tagged spans are scored against labelled gold-standard annotations using precision, recall, and F1. Precision is the number of correct predicted spans divided by the number of all predicted spans. Recall is the number of correct predicted spans divided by the number of all gold spans. F1 is the harmonic mean of the two, F1 = 2PR / (P + R). A predicted span counts as correct only under a stated matching rule: either both boundaries and the type must match exactly, or a relaxed rule accepts partial overlap. The two rules give different scores, so state which one you use. Overall scores can hide a tagger that never detects one entity class, so report scores per class and inspect incorrect and missed entities before relying on the model.
Common pitfalls
- Training or fine-tuning a model on a very small corpus, where it may underperform; a rule-based or dictionary approach is often the more practical starting point in that case.
- Applying a model that does not cover the language of the corpus, which degrades recognition.
- Skipping preprocessing, so that noisy or poorly tokenised text breaks entity boundaries.
- Judging the tagger by overall accuracy alone when an entire entity class is missed; report precision, recall, and F1 per class and inspect missed entities.
- Mismatching the tagging scheme. Span boundaries depend on the label scheme, for example BIO/IOB, in which each token is marked as beginning, inside, or outside an entity. Use the same scheme for training, prediction, and evaluation, or boundaries will be scored inconsistently.
- Applying a model trained on one domain, such as news, to another, such as clinical or social-media text, without checking. Performance often drops under this domain shift. Test on a held-out sample from the target domain before use.
Frequently asked questions
Rule-based, machine learning, or neural: which approach should I use?
A rule-based approach matches patterns and dictionaries and does not require labelled data to start. Grammar rules are effective, but they need experienced computational linguists to write and are often domain-specific. A machine-learning sequence labeller learns from labelled examples and adapts to your domain, but it needs a significant amount of training data. A neural approach uses contextual architectures, as in Lample et al. (2016), and can perform strongly when enough labelled data is available, at higher computational cost. Compare the options on your own labelled sample before choosing.
What happens if my corpus is very small?
With a very small corpus, a trained NER model may perform poorly because it has too few examples to learn from. In that case a rule-based or dictionary approach is a practical starting point, but its recall depends on how complete your term lists are.
Does NER work in languages other than English?
Yes, but the chosen language model must support the target language of the text. A model that does not cover the corpus language is a common cause of poor recognition.
How is NER evaluated?
Tagged spans are compared against labelled data using precision, recall, and F1, which combines the two. Inspect missed and incorrect entities, because a tagger can quietly fail to detect an entire entity class while still looking accurate overall.
Related methods
Sources
Nadeau, D. & Sekine, S. (2007). A survey of named entity recognition. Lingvisticae Investigationes.
Open publication referenceLample, G. et al. (2016). Neural Architectures for Named Entity Recognition. NAACL.
Open DOI reference2015_Book_DataMining, p. ?