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

Update HunFlair tutorial to Flair 0.12 #3137

Merged
merged 4 commits into from
Mar 10, 2023
Merged

Update HunFlair tutorial to Flair 0.12 #3137

merged 4 commits into from
Mar 10, 2023

Conversation

alanakbik
Copy link
Collaborator

This PR updates the HunFlair tutorial to the changed syntax in Flair 0.12:

  • there is now a separate module for sentence splitting, changing the import statement (from flair.splitter import SciSpacySentenceSplitter instead of from flair.tokenization import SciSpacySentenceSplitter )
  • the tagger is now implemented as a MultitaskModel, and all taggers are now initialized using Classifier by default, meaning you init and print labels like this:
from flair.data import Sentence
from flair.nn import Classifier

# make a sentence 
sentence = Sentence("Behavioral abnormalities in the Fmr1 KO2 Mouse Model of Fragile X Syndrome")

# load biomedical tagger
tagger = Classifier.load("hunflair")

# tag sentence
tagger.predict(sentence)

# print labels
for entity in sentence.get_labels():
    print(entity)

Open Issue: SciSpacy instructions

However, I am unable to get the scispacy tokenizer to run - I think this is because Flair now requires Python 3.7.

@mariosaenger @leonweber @piamarlene @sg-wbi @WangXII: could one of you check how the pip install instructions need to be changed so that the SciSpacy example works? The current instructions are as follows and no longer work:

Current install instructions:

pip install scispacy==0.2.5
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.5/en_core_sci_sm-0.2.5.tar.gz

Current tag instructions:

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

# make a sentence and tokenize with SciSpaCy
sentence = Sentence("Behavioral abnormalities in the Fmr1 KO2 Mouse Model of Fragile X Syndrome",
                    use_tokenizer=SciSpacyTokenizer())

# load biomedical tagger
tagger = Classifier.load("hunflair")

# tag sentence
tagger.predict(sentence)

@alanakbik
Copy link
Collaborator Author

@mariosaenger @leonweber @piamarlene @sg-wbi @WangXII merging this now for the hotfix release, let me know if you figure the issue with scispacy out.

@alanakbik alanakbik merged commit 8b3568e into master Mar 10, 2023
@alanakbik alanakbik deleted the bioner-tutorial branch March 10, 2023 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant