Skip to content

[Bug]: How to change entities in the predict function #3675

@JINO-ROHIT

Description

@JINO-ROHIT

Describe the bug

I need to detect only PERSON AND EMAIL instead of all the 2o entities.how to change this?

Loading model from flair/ner-english-large
2025-06-16 22:55:27,369 SequenceTagger predicts: Dictionary with 20 tags: , O, S-ORG, S-MISC, B-PER, E-PER, S-LOC, B-ORG, E-ORG, I-PER, S-PER, B-MISC, I-MISC, E-MISC, I-ORG, B-LOC, E-LOC, I-LOC, ,

To Reproduce

from flair.data import Sentence
from flair.nn import Classifier

# make a sentence
sentence = Sentence('George Washington went to Washington.')

# load the NER tagger
tagger = Classifier.load('ner-large')

# run NER over sentence
tagger.predict(sentence)

# print the sentence with all annotations
print(sentence)

Expected behavior

NA

Logs and Stack traces


Screenshots

No response

Additional Context

No response

Environment

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions