đ Danish NER in Flair (default model)
This project provides a standard 4 - class NER model for Danish within the Flair framework. It offers efficient named - entity recognition for Danish texts, with an F1 - Score of 81.78 on the DaNER dataset.
⨠Features
- High Performance: Achieves an F1 - Score of 81.78 on the DaNER dataset.
- 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 Transformer embeddings and LSTM - CRF.
Property |
Details |
Model Type |
4 - class NER model for Danish |
Training Data |
DaNE corpus |
đ Quick Start
Prerequisites
This project requires Flair. You can install it using the following command:
pip install flair
đģ Usage Examples
Basic Usage
from flair.data import Sentence
from flair.models import SequenceTagger
tagger = SequenceTagger.load("flair/ner-danish")
sentence = Sentence("Jens Peter Hansen kommer fra Danmark")
tagger.predict(sentence)
print(sentence)
print('The following NER tags are found:')
for entity in sentence.get_spans('ner'):
print(entity)
This code will yield the following output:
Span [1,2,3]: "Jens Peter Hansen" [â Labels: PER (0.9961)]
Span [6]: "Danmark" [â Labels: LOC (0.9816)]
In the sentence "Jens Peter Hansen kommer fra Danmark", the entities "Jens Peter Hansen" (labeled as a person) and "Danmark" (labeled as a location) are identified.
đ§ Technical Details
The model was trained by the DaNLP project using the DaNE corpus.
The following Flair script can be used to train such a model:
from flair.data import Corpus
from flair.datasets import DANE
from flair.embeddings import WordEmbeddings, StackedEmbeddings, FlairEmbeddings
corpus: Corpus = DANE()
tag_type = 'ner'
tag_dictionary = corpus.make_tag_dictionary(tag_type=tag_type)
embedding_types = [
WordEmbeddings('da'),
FlairEmbeddings('da-forward'),
FlairEmbeddings('da-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-danish',
train_with_dev=True,
max_epochs=150)
đ License
No license information provided in the original document.
đ Documentation
Cite
Please cite the following papers when using this model.
@inproceedings{akbik-etal-2019-flair,
title = "{FLAIR}: An Easy-to-Use Framework for State-of-the-Art {NLP}",
author = "Akbik, Alan and
Bergmann, Tanja and
Blythe, Duncan and
Rasul, Kashif and
Schweter, Stefan and
Vollgraf, Roland",
booktitle = "Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics (Demonstrations)",
year = "2019",
url = "https://www.aclweb.org/anthology/N19-4010",
pages = "54--59",
}
And check the DaNLP project for more information.
Issues?
The Flair issue tracker is available here.