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]: Additional granularity in relation extraction #3169

Closed
hyshandler opened this issue Mar 29, 2023 · 2 comments
Closed

[Question]: Additional granularity in relation extraction #3169

hyshandler opened this issue Mar 29, 2023 · 2 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@hyshandler
Copy link

Question

I have a corpus that contains brief one paragraph bios from thousands of people. I'm hoping to extract more granular relations from it. For instance, with the text "Tim Cook is the president and CEO of Apple", the relation output is "Tim Cook -> Apple" → employee_of and "Apple -> Tim Cook" → works_for (0.9953). I want this to extract "Tim Cook -> Apple" → president and CEO. I understand I can hand label this sentence (and others) and train an additional layer, but I'm wondering if there's another (hopefully less manual) way to extract the relation. Thanks!

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

text = "Tim Cook is the president and CEO of Apple"

# load the model
tagger = Classifier.load('ner')

# make a sentence
sentence = Sentence(text)

# predict NER tags
tagger.predict(sentence)

# load relation extractor
extractor = Classifier.load('relations')

# predict relations
extractor.predict(sentence)

# check which relations have been found
relations = sentence.get_labels('relation')
for relation in relations:
    print(relation)

Relation[0:2][6:7]: "Tim Cook -> Apple" → employee_of (1.0)
Relation[6:7][0:2]: "Apple -> Tim Cook" → works_for (0.9953)

@hyshandler hyshandler added the question Further information is requested label Mar 29, 2023
@alanakbik
Copy link
Collaborator

Hello @hyshandler, I think an OpenIE model could do what you are looking for. We don't currently have one in Flair, but we are building one that will likely be added in a future release.

@stale
Copy link

stale bot commented Aug 12, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants