🚀 French NER in Flair (default model)
This project provides a standard 4 - class NER model for French, which comes with Flair. It offers an effective solution for named - entity recognition in French texts, with a high F1 - Score of 90.61 on WikiNER.
✨ Features
- High Performance: Achieves an F1 - Score of 90.61 on WikiNER.
- Four - Tag Prediction: Predicts four types of named entities: person names (PER), location names (LOC), organization names (ORG), and other names (MISC).
- Advanced Architecture: Based on Flair embeddings and LSTM - CRF.
Property |
Details |
Model Type |
4 - class NER model for French |
Training Data |
conll2003, WIKINER_FRENCH |
Tag |
Meaning |
PER |
person name |
LOC |
location name |
ORG |
organization name |
MISC |
other name |
📦 Installation
Requires: Flair (pip install flair
)
💻 Usage Examples
Basic Usage
from flair.data import Sentence
from flair.models import SequenceTagger
tagger = SequenceTagger.load("flair/ner-french")
sentence = Sentence("George Washington est allé à Washington")
tagger.predict(sentence)
print(sentence)
print('The following NER tags are found:')
for entity in sentence.get_spans('ner'):
print(entity)
This yields the following output:
Span [1,2]: "George Washington" [− Labels: PER (0.7394)]
Span [6]: "Washington" [− Labels: LOC (0.9161)]
So, the entities "George Washington" (labeled as a person) and "Washington" (labeled as a location) are found in the sentence "George Washington est allé à Washington".
Advanced Usage
from flair.data import Corpus
from flair.datasets import WIKINER_FRENCH
from flair.embeddings import WordEmbeddings, StackedEmbeddings, FlairEmbeddings
corpus: Corpus = WIKINER_FRENCH()
tag_type = 'ner'
tag_dictionary = corpus.make_tag_dictionary(tag_type=tag_type)
embedding_types = [
WordEmbeddings('fr'),
FlairEmbeddings('fr-forward'),
FlairEmbeddings('fr-backward'),
]
embeddings = StackedEmbeddings(embeddings=embedding_types)
from flair.models import SequenceTagger
tagger = SequenceTagger(hidden_size=256,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type)
from flair.trainers import ModelTrainer
trainer = ModelTrainer(tagger, corpus)
trainer.train('resources/taggers/ner-french',
train_with_dev=True,
max_epochs=150)
📚 Documentation
Cite
Please cite the following paper when using this model.
@inproceedings{akbik2018coling,
title={Contextual String Embeddings for Sequence Labeling},
author={Akbik, Alan and Blythe, Duncan and Vollgraf, Roland},
booktitle = {{COLING} 2018, 27th International Conference on Computational Linguistics},
pages = {1638--1649},
year = {2018}
}
Issues?
The Flair issue tracker is available here.