Flair: Train a NER using BILOU tags

Created on 10 Nov 2019  路  6Comments  路  Source: flairNLP/flair

Hi,
I'm evaluating Flair and so far it's very cool!
I have a dataset which is already annotated as BILOU. I can technically translate it to BIO but was wondering if it should or shouldn't work off the shelf with BILOU tags.

Thanks!

question wontfix

Most helpful comment

Thanks @djstrong

I have just confirmed that using BIO works as well.
I hope this info could be useful as reference for future user.

Here is the summary to train NER with BILOU tags using Flair:

  • you could convert BILOU to BIEOS
annotations = [a.replace('L-', 'E-') for a in annotations]
annotations = [a.replace('U-', 'S-') for a in annotations]
  • you could convert BILOU to BIO
annotations = [a.replace('L-', 'I-') for a in annotations]
annotations = [a.replace('U-', 'B-') for a in annotations]

We can close the thread now.

All 6 comments

You can replace BIEOS which is managed by Flair

        annotations = [a.replace('L-', 'E-') for a in annotations]
        annotations = [a.replace('U-', 'S-') for a in annotations]

(for Spacy annotations)

Thanks.
If I train a SequenceTagger with pretrained embeddings, does it matter which annotation scheme I use? Does the model use any external data to the training data I provide it with?

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.

Hi @pommedeterresautee
I have confirmed that BIEOS works.

In the other hand, would it be a problem if someone uses BIO scheme?

No problem with other schemes, but some may achieve better results.

Thanks @djstrong

I have just confirmed that using BIO works as well.
I hope this info could be useful as reference for future user.

Here is the summary to train NER with BILOU tags using Flair:

  • you could convert BILOU to BIEOS
annotations = [a.replace('L-', 'E-') for a in annotations]
annotations = [a.replace('U-', 'S-') for a in annotations]
  • you could convert BILOU to BIO
annotations = [a.replace('L-', 'I-') for a in annotations]
annotations = [a.replace('U-', 'B-') for a in annotations]

We can close the thread now.

Was this page helpful?
0 / 5 - 0 ratings