Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Combining two different Models? #3415

Open
Tinnnitus opened this issue Mar 1, 2024 · 1 comment
Open

[Question]: Combining two different Models? #3415

Tinnnitus opened this issue Mar 1, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Tinnnitus
Copy link

Question

Hello,

I am a complete freshman in the whole NLP/NER topic and unfortunately don't have much knowledge of python. I am experimenting with NER with Flair and was happy to get the NER with Flair up and running (with good results using the NER-German-large model). Now there are a few entities like dates or even languages in the english model or the 18-Entities Ontonotes model I want to extract as well. I was wondering if it is possible to combine the german model and for example the english one and extract certain entities of both models?
Due to my lacking knowledge of Python I am hesitant to training a new model and would rather rely on already existing models.

How could a code could look like? I would highly apreciate if someone could help and enlighten me!
Thanks in advance.

Here is my code so far:

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

tagger = Classifier.load("flair/ner-german-large")

txt_file_path = …

with open(txt_file_path, 'r', encoding='utf-8') as file:
text_content = file.read()

sentence = Sentence(text_content)

tagger.predict(sentence)

for label in sentence.get_labels('ner'):
print(label)

@Tinnnitus Tinnnitus added the question Further information is requested label Mar 1, 2024
@helpmefindaname
Copy link
Collaborator

Hi @tinnitus
to run multiple models, you can just use multiple predictions:

model_a.predict(sentence)
model_b.predict(sentence)

@stefan-it stefan-it changed the title [Question]: Combing two different Models? [Question]: Combining two different Models? Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants