1 of 32

Information Extraction and Named Entity Recognition

Introducing the tasks:

Getting simple structured information out of text

Christopher Manning

2 of 32

Information Extraction

  • Information extraction (IE) systems
    • Find and understand limited relevant parts of texts
    • Gather information from many pieces of text
    • Produce a structured representation of relevant information:
      • relations (in the database sense), a.k.a.,
      • a knowledge base
    • Goals:
      1. Organize information so that it is useful to people
      2. Put information in a semantically precise form that allows further inferences to be made by computer algorithms

Christopher Manning

3 of 32

Information Extraction (IE)

  • IE systems extract clear, factual information
    • Roughly: Who did what to whom when?
  • E.g.,
    • Gathering earnings, profits, board members, headquarters, etc. from company reports
      • The headquarters of BHP Billiton Limited, and the global headquarters of the combined BHP Billiton Group, are located in Melbourne, Australia.
      • headquarters(“BHP Biliton Limited”, “Melbourne, Australia”)
    • Learn drug-gene product interactions from medical research literature

Christopher Manning

4 of 32

Low-level information extraction

  • Is now available – and I think popular – in applications like Apple or Google mail, and web indexing

​

​

​

​

  • Often seems to be based on regular expressions and name lists

Christopher Manning

5 of 32

Low-level information extraction

Christopher Manning

6 of 32

Named Entity Recognition (NER)

  • A very important sub-task: find and classify names in text, for example:

​

    • The decision by the independent MP Andrew Wilkie to withdraw his support for the minority Labor government sounded dramatic but it should not further threaten its stability. When, after the 2010 election, Wilkie, Rob Oakeshott, Tony Windsor and the Greens agreed to support Labor, they gave just two guarantees: confidence and supply.

Christopher Manning

7 of 32

Named Entity Recognition (NER)

  • A very important sub-task: find and classify names in text, for example:

​

    • The decision by the independent MP Andrew Wilkie to withdraw his support for the minority Labor government sounded dramatic but it should not further threaten its stability. When, after the 2010 election, Wilkie, Rob Oakeshott, Tony Windsor and the Greens agreed to support Labor, they gave just two guarantees: confidence and supply.

Christopher Manning

8 of 32

Named Entity Recognition (NER)

  • A very important sub-task: find and classify names in text, for example:

​

    • The decision by the independent MP Andrew Wilkie to withdraw his support for the minority Labor government sounded dramatic but it should not further threaten its stability. When, after the 2010 election, Wilkie, Rob Oakeshott, Tony Windsor and the Greens agreed to support Labor, they gave just two guarantees: confidence and supply.

Person

Date

Location

Organi-

zation

​

​

Christopher Manning

9 of 32

Named Entity Recognition (NER)

  • The uses:
    • Named entities can be indexed, linked off, etc.
    • Sentiment can be attributed to companies or products
    • A lot of IE relations are associations between named entities
    • For question answering, answers are often named entities.

​

  • Concretely:
    • Many web pages tag various entities, with links to bio or topic pages, etc.
      • Reuters’ OpenCalais, Evri, AlchemyAPI, Yahoo’s Term Extraction, …
    • Apple/Google/Microsoft/… smart recognizers for document content

Christopher Manning

10 of 32

Information Extraction and Named Entity Recognition

Introducing the tasks:

Getting simple structured information out of text

Christopher Manning

11 of 32

Evaluation of Named Entity Recognition

The extension of Precision, Recall, and the F measure to sequences

Christopher Manning

12 of 32

The Named Entity Recognition Task

Task: Predict entities in a text

​

Foreign ORG

Ministry ORG

spokesman O

Shen PER

Guofang PER

told O

Reuters ORG

: :

}

Standard evaluation

is per entity, not per token

Christopher Manning

13 of 32

Precision/Recall/F1 for IE/NER

  • Recall and precision are straightforward for tasks like IR and text categorization, where there is only one grain size (documents)
  • The measure behaves a bit funnily for IE/NER when there are boundary errors (which are common):
    • First Bank of Chicago announced earnings …
  • This counts as both a fp and a fn
  • Selecting nothing would have been better
  • Some other metrics (e.g., MUC scorer) give partial credit (according to complex rules)

Christopher Manning

14 of 32

Evaluation of Named Entity Recognition

The extension of Precision, Recall, and the F measure to sequences

Christopher Manning

15 of 32

Sequence Models for Named Entity Recognition

Christopher Manning

16 of 32

The ML sequence model approach to NER

Training

  1. Collect a set of representative training documents
  2. Label each token for its entity class or other (O)
  3. Design feature extractors appropriate to the text and classes
  4. Train a sequence classifier to predict the labels from the data

​

Testing

  1. Receive a set of testing documents
  2. Run sequence model inference to label each token
  3. Appropriately output the recognized entities

​

​

Christopher Manning

17 of 32

Encoding classes for sequence labeling

IO encoding IOB encoding

​

Fred PER B-PER

showed O O

Sue PER B-PER

Mengqiu PER B-PER

Huang PER I-PER

‘s O O

new O O

painting O O

Christopher Manning

18 of 32

Features for sequence labeling

  • Words
    • Current word (essentially like a learned dictionary)
    • Previous/next word (context)
  • Other kinds of inferred linguistic classification
    • Part-of-speech tags
  • Label context
    • Previous (and perhaps next) label

18

Christopher Manning

19 of 32

Features: Word substrings

Cotrimoxazole

Wethersfield

Alien Fury: Countdown to Invasion

oxa

:

field

Christopher Manning

20 of 32

Features: Word shapes

  • Word Shapes
    • Map words to simplified representation that encodes attributes such as length, capitalization, numerals, Greek letters, internal punctuation, etc.

​

​

​

​

​

​

Varicella-zoster

Xx-xxx

mRNA

xXXX

CPA1

XXXd

Christopher Manning

21 of 32

Sequence Models for Named Entity Recognition

Christopher Manning

22 of 32

Maximum entropy sequence models

Maximum entropy Markov models (MEMMs) or Conditional Markov models

Christopher Manning

23 of 32

Sequence problems

  • Many problems in NLP have data which is a sequence of characters, words, phrases, lines, or sentences …
  • We can think of our task as one of labeling each item

VBG

NN

IN

DT

NN

IN

NN

Chasing

opportunity

in

an

age

of

upheaval

POS tagging

B

B

I

I

B

I

B

I

B

B

而

相

对

于

这

些

品

牌

的

价

Word segmentation

PERS

O

O

O

ORG

ORG

Murdoch

discusses

future

of

News

Corp.

Named entity recognition

Text segmen-tation

Q

A

Q

A

A

A

Q

A

Christopher Manning

24 of 32

MEMM inference in systems

  • For a Conditional Markov Model (CMM) a.k.a. a Maximum Entropy Markov Model (MEMM), the classifier makes a single decision at a time, conditioned on evidence from observations and previous decisions
  • A larger space of sequences is usually explored via search

-3

-2

-1

0

+1

DT

NNP

VBD

???

???

The

Dow

fell

22.6

%

Local Context

Features

W0

22.6

W+1

%

W-1

fell

T-1

VBD

T-1-T-2

NNP-VBD

hasDigit?

true

…

…

(Ratnaparkhi 1996; Toutanova et al. 2003, etc.)

Decision Point

Christopher Manning

25 of 32

Example: POS Tagging

  • Scoring individual labeling decisions is no more complex than standard classification decisions
    • We have some assumed labels to use for prior positions
    • We use features of those and the observed data (which can include current, previous, and next words) to predict the current label

-3

-2

-1

0

+1

DT

NNP

VBD

???

???

The

Dow

fell

22.6

%

Local Context

Features

W0

22.6

W+1

%

W-1

fell

T-1

VBD

T-1-T-2

NNP-VBD

hasDigit?

true

…

…

Decision Point

(Ratnaparkhi 1996; Toutanova et al. 2003, etc.)

Christopher Manning

26 of 32

Example: POS Tagging

  • POS tagging Features can include:
    • Current, previous, next words in isolation or together.
    • Previous one, two, three tags.
    • Word-internal features: word types, suffixes, dashes, etc.

-3

-2

-1

0

+1

DT

NNP

VBD

???

???

The

Dow

fell

22.6

%

Local Context

Features

W0

22.6

W+1

%

W-1

fell

T-1

VBD

T-1-T-2

NNP-VBD

hasDigit?

true

…

…

(Ratnaparkhi 1996; Toutanova et al. 2003, etc.)

Decision Point

Christopher Manning

27 of 32

Inference in Systems

Sequence Level

Local Level

Local

Data

Feature

Extraction

Features

Label

Optimization

Smoothing

Classifier Type

Features

Label

Sequence

Data

Maximum Entropy Models

Quadratic

Penalties

Conjugate

Gradient

Sequence Model

Inference

Local

Data

Local

Data

Christopher Manning

28 of 32

Greedy Inference

  • Greedy inference:
    • We just start at the left, and use our classifier at each position to assign a label
    • The classifier can depend on previous labeling decisions as well as observed data
  • Advantages:
    • Fast, no extra memory requirements
    • Very easy to implement
    • With rich features including observations to the right, it may perform quite well
  • Disadvantage:
    • Greedy. We make commit errors we cannot recover from

Sequence Model

Inference

Best Sequence

Christopher Manning

29 of 32

Beam Inference

  • Beam inference:
    • At each position keep the top k complete sequences.
    • Extend each sequence in each local way.
    • The extensions compete for the k slots at the next position.
  • Advantages:
    • Fast; beam sizes of 3–5 are almost as good as exact inference in many cases.
    • Easy to implement (no dynamic programming required).
  • Disadvantage:
    • Inexact: the globally best sequence can fall off the beam.

Sequence Model

Inference

Best Sequence

Christopher Manning

30 of 32

Viterbi Inference

  • Viterbi inference:
    • Dynamic programming or memoization.
    • Requires small window of state influence (e.g., past two states are relevant).
  • Advantage:
    • Exact: the global best sequence is returned.
  • Disadvantage:
    • Harder to implement long-distance state-state interactions (but beam inference tends not to allow long-distance resurrection of sequences anyway).

Sequence Model

Inference

Best Sequence

Christopher Manning

31 of 32

CRFs [Lafferty, Pereira, and McCallum 2001]

  • Another sequence model: Conditional Random Fields (CRFs)
  • A whole-sequence conditional model rather than a chaining of local models.

​

​

​

  • The space of c’s is now the space of sequences
    • But if the features fi remain local, the conditional sequence likelihood can be calculated exactly using dynamic programming
  • Training is slower, but CRFs avoid causal-competition biases
  • These (or a variant using a max margin criterion) are seen as the state-of-the-art these days … but in practice usually work much the same as MEMMs.

Christopher Manning

32 of 32

Maximum entropy sequence models

Maximum entropy Markov models (MEMMs) or Conditional Markov models

Christopher Manning