Practical and Effective Neural NER
Practical and Effective Neural NER
Effective Neural
Entity Recognition
in spaCy v2.0 and beyond
Ines Montani
CO-FOUNDER
import spacy
nlp = spacy.load('en')
doc = nlp(u"Apple is looking at buying U.K. startup for $1 billion")
alpha.spacy.io
’s English models
alpha.spacy.io
What’s so hard about
Named Entity Recognition?
Entity recognition is not a great thesis topic.
This makes progress slow.
Embed. Encode.
Attend. Predict.
Think of data shapes,
not application details.
integer vector
category label single meaning
embed_word = (
(norm | prefix | suffix | shape)
>> Maxout(128, pieces=3)
)
EMBED
embed_word = (
(norm | prefix | suffix | shape)
>> Maxout(128, pieces=3)
)
ENCODE
trigram_cnn = (
ExtractWindow(nW=1) >> Maxout(128, pieces=3)
)
encode_context = (
embed_word
>> Residual(trigram_cnn)
>> Residual(trigram_cnn)
>> Residual(trigram_cnn)
>> Residual(trigram_cnn)
)
ATTEND
state2vec = (
tensor[state.buffer(0)]
| tensor[state.buffer(-1)]
| tensor[state.buffer(1)]
| tensor[state.entities(0)]
| tensor[state.entities(-1)]
| tensor[state.entities(1)]
)
>> Maxout(128)
PREDICT
tensor = trigram_cnn(embed_word(doc))
state_weights = state2vec(tensor)
state = initialize_state(doc)
while not state.is_finished:
features = get_features(state, state_weights)
probs = mlp(features)
action = (probs * valid_actions(state)).argmax()
state = action(state)
Advantages of the
transition-based approach
We need annotations.
Correct 164
Incorrect 46
Baseline 0.005
Accuracy 0.781
What’s next?
📲 Follow us on Twitter
@honnibal
@_inesmontani
@explosion_ai