English NER in Flair

This is the fast and small 4-class NER model for English that ships with Flair.

Model Size Type Language Dataset F1 Score (%)
ner-fast ~ 240 mb NER (4-class) English CoNLL-03 92.75

Predicts 4 tags:

tag meaning
PER person name
LOC location name
ORG organization name
MISC other name

Demo: How to use in Flair

Requires: Flair (pip install flair)

from flair.data import Sentence
from flair.models import SequenceTagger

# load tagger
tagger = SequenceTagger.load("acuvity/flair_ner-fast")

# make example sentence
sentence = Sentence("George Washington went to Washington")

# predict NER tags
tagger.predict(sentence)

# print sentence
print(sentence)

# print predicted NER spans
print('The following NER tags are found:')
# iterate over entities and print
for entity in sentence.get_spans('ner'):
    print(entity)

This yields the following output:

Span [1,2]: "George Washington"   [โˆ’ Labels: PER (1.0)]
Span [5]: "Washington"   [โˆ’ Labels: LOC (1.0)]

So, the entities "George Washington" (labeled as a person) and "Washington" (labeled as a location) are found in the sentence "George Washington went to Washington".

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support