Algorithm Search⌘K

Problemcore

Named entity recognition

Also called NER, entity extraction.

Find the spans of a text that name entities such as persons, organizations and places, and label each span with its type.

Named entity recognition (NER) finds the names in a text and says what each one names: a person, an organization, a place, or another type from a fixed list. It is the first step of most information extraction: relation extraction needs the entities whose relations it finds, entity linking needs the mentions it links, and coreference resolution often starts from them. The task took its present form in the Message Understanding Conferences of the 1990s and in the CoNLL-2002 and CoNLL-2003 shared tasks. Since the names form flat spans, it is usually solved as sequence labeling with BIO encoding, and it is scored with the span F1 score.

In plain words

Read a sentence such as "Ekeus met officials of the U.N. in Baghdad" and mark the names: "Ekeus" is a person, "U.N." is an organization and "Baghdad" is a place. A name can be several words long, such as "New York Stock Exchange", and then the whole group must be marked, not only part of it. The same word can be a different type in different places: "Washington" can be a person, a city or the government. A system decides from the word itself, its shape (capital letters, digits), and the words around it. It is right about a name only if it marks exactly the right words and gives the right type.

Definition

Input. A sentence of tokens x1,…,xnx_1, \ldots, x_n and a set TT of entity types.

Output. A set of typed spans (i,j,t)(i, j, t) with 0≤i<j≤n0 \le i < j \le n and t∈Tt \in T. The span (i,j)(i, j) uses fencepost indices: it covers the tokens i+1,…,ji + 1, \ldots, j. In the standard (flat) task, no two spans share a token.

Types. The CoNLL-2003 task uses four types: PER (persons), ORG (organizations), LOC (locations) and MISC (other names, such as nationalities and events). The MUC-6 task marked names of persons, organizations and locations, and also times, dates, money and percentages (Grishman and Sundheim 1996). Larger type sets exist, and domain tasks use their own, such as genes and proteins in biomedical text.

Score. Exact-match span F1: a predicted entity counts only if both its boundaries and its type are right, with precision and recall summed over the whole test set (Tjong Kim Sang and De Meulder 2003).

Variants

  • Flat NER: the spans do not overlap. This is the CoNLL form, and it reduces to tagging.
  • Nested NER: entities can contain entities, as in "[[University of [California]] Press]". Nested data sets exist for news and for biomedical text. Tagging with one tag per token cannot express nesting.
  • Discontinuous entities: in "left and right ventricle", "left ventricle" is an entity whose words are not adjacent. Some medical data sets mark them.
  • Fine-grained typing: types from a large hierarchy, such as "politician" below "person".
  • Cross-lingual and low-resource NER: train on one language, or on few labeled sentences, and tag another.
  • Entity typing given the spans: classify each given mention into a type. It is a classification problem, not span finding.

Examples

The CoNLL-2003 style sentence "U.N. official Ekeus heads for Baghdad ." has the entities (0,1,ORG)(0, 1, \mathrm{ORG}) for "U.N.", (2,3,PER)(2, 3, \mathrm{PER}) for "Ekeus" and (5,6,LOC)(5, 6, \mathrm{LOC}) for "Baghdad". In IOB2 tags: U.N./B-ORG official/O Ekeus/B-PER heads/O for/O Baghdad/B-LOC ./O.

Ambiguity of type: in "Jordan scored 40 points" Jordan is a person, in "Jordan signed the treaty" a country, and a system must decide from the context.

Ambiguity of boundaries: in "Bank of America Corp. said", the organization is "Bank of America Corp.", and a system that marks only "America" as a location makes one false positive and one false negative.

Known algorithms

  • Rules and gazetteers: hand-written patterns over capital letters, titles ("Mr.") and lists of known names. These were common in the MUC systems.
  • Generative taggers: hidden Markov models over BIO tags, decoded by the Viterbi algorithm.
  • Discriminative taggers: the maximum entropy Markov model, the structured perceptron and the conditional random field, with features such as word shape, prefixes and suffixes, and gazetteer matches. Most CoNLL-2003 systems were of this kind; the best English test F1 was 88.76 (a measurement, Tjong Kim Sang and De Meulder 2003).
  • Neural taggers: the BiLSTM-CRF of Lample et al. (2016) reached 90.94 F1 on the English CoNLL-2003 test set without gazetteers (a measurement).
  • Pretrained encoders: fine-tune BERT or another transformer encoder with a tag classifier on each token. Devlin et al. (2019) report 92.8 test F1 on English CoNLL-2003 for BERT-large (a measurement).
  • Span models: score every span up to a length LL and pick a set of non-overlapping spans, as in the semi-Markov CRF; span classifiers can also handle nested entities.

Bounds

  • With k=2∣T∣+1k = 2|T| + 1 BIO tags, Viterbi decoding of a first-order tagger takes O(nk2)=O(n∣T∣2)O(n k^2) = O(n |T|^2) time and O(nk)O(n k) space (a theorem). Forbidden transitions such as O followed by I-X get score −∞-\infty, so the output is always a valid span set.
  • A semi-Markov model with spans of length at most LL decodes in O(nL∣T∣2)O(n L |T|^2) time (a theorem, see semi-Markov CRF).
  • Classifying each token independently takes O(nk)O(n k) after the encoder, but can give invalid tag sequences, which the span reader of the span F1 score still turns into spans.
  • Any system must read each token, so Ω(n)\Omega(n) time is needed.

Reductions

  • Flat NER to sequence labeling: BIO encoding is a bijection between span sets and valid tag sequences, so any tagger solves NER, and the spans are read back exactly.
  • Flat NER to weighted interval selection: if each span has a score and the scores add, the best set of non-overlapping spans is a weighted interval scheduling problem, solved by dynamic programming.
  • Nested NER to span classification: enumerate all O(nL)O(n L) spans and classify each as an entity type or none.
  • NER is a part of entity linking and relation extraction: end-to-end systems for those tasks solve NER on the way.

Applications

  • Information extraction: entities are the slots of events and relations.
  • Search and question answering: index documents by the entities they mention.
  • Anonymization: find and remove names of persons in medical or legal records.
  • Knowledge base building: with entity linking, map mentions to entries and add new facts.

References

  1. Grishman and Sundheim 1996, the named entity task of MUC-6 and its entity, time and number types
  2. Tjong Kim Sang and De Meulder 2003, the four entity types, the English and German data, the exact-match evaluation and the results of the participating systems
  3. Guillaume Lample, Miguel Ballesteros, Sandeep Subramanian, Kazuya Kawakami and Chris Dyer, Neural architectures for named entity recognition, NAACL 2016, the LSTM-CRF model with character-based word representations and its CoNLL-2003 results
  4. Jacob Devlin, Ming-Wei Chang, Kenton Lee and Kristina Toutanova, BERT: pre-training of deep bidirectional transformers for language understanding, NAACL 2019, the CoNLL-2003 named entity experiment

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml