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
28
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.