🚀 NER for German Legal Text in Flair (default model)
This model is a legal NER model for German, which is included in Flair. It aims to accurately identify named entities in German legal texts, providing valuable support for legal information extraction.
F1-Score: 96.35 (LER German dataset)
It predicts 19 tags as follows:
tag |
meaning |
AN |
Lawyer |
EUN |
European Norm |
GS |
Law |
GRT |
Court |
INN |
Institution |
LD |
State |
LDS |
Landscape |
LIT |
Literature |
MRK |
Brand |
ORG |
Organization |
PER |
Person |
RR |
Judge |
RS |
Jurisprudence |
ST |
City |
STR |
Street |
UN |
Company |
VO |
Regulation |
VS |
Provision |
VT |
Contract |
This model is based on Flair embeddings and LSTM - CRF.
For more details on the Legal NER dataset, please refer here.
🚀 Quick Start
✨ Features
- This is a pre - trained legal NER model for German in Flair.
- It can predict 19 different tags related to legal entities.
- Achieves a high F1 - Score of 96.35 on the LER German dataset.
📦 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-german-legal")
sentence = Sentence("Herr W. verstieß gegen § 36 Abs. 7 IfSG.", use_tokenizer=False)
tagger.predict(sentence)
print(sentence)
print('The following NER tags are found:')
for entity in sentence.get_spans('ner'):
print(entity)
This code will output:
Span [2]: "W." [− Labels: PER (0.9911)]
Span [5,6,7,8,9]: "§ 36 Abs. 7 IfSG." [− Labels: GS (0.5353)]
🔧 Technical Details
The model is trained using the following Flair script:
from flair.data import Corpus
from flair.datasets import LER_GERMAN
from flair.embeddings import WordEmbeddings, StackedEmbeddings, FlairEmbeddings
corpus: Corpus = LER_GERMAN()
tag_type = 'ner'
tag_dictionary = corpus.make_tag_dictionary(tag_type=tag_type)
embedding_types = [
WordEmbeddings('de'),
FlairEmbeddings('de-forward'),
FlairEmbeddings('de-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-german-legal',
train_with_dev=True,
max_epochs=150)
📄 License
No license information is provided in the original document.
📚 Documentation
Cite
Please cite the following papers when using this model.
@inproceedings{leitner2019fine,
author = {Elena Leitner and Georg Rehm and Julian Moreno-Schneider},
title = {{Fine-grained Named Entity Recognition in Legal Documents}},
booktitle = {Semantic Systems. The Power of AI and Knowledge
Graphs. Proceedings of the 15th International Conference
(SEMANTiCS 2019)},
year = 2019,
pages = {272--287},
pdf = {https://link.springer.com/content/pdf/10.1007%2F978-3-030-33220-4_20.pdf}}
@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.