Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
<table>
|
| 6 |
+
<tr>
|
| 7 |
+
<td width="80">
|
| 8 |
+
<img src="assets/ner_logo.png" alt="NER Logo" width="80"/>
|
| 9 |
+
</td>
|
| 10 |
+
<td>
|
| 11 |
+
<h1 style="margin: 0; padding: 0;">German Named Entity Recognition (GERMANER)</h1>
|
| 12 |
+
</td>
|
| 13 |
+
</tr>
|
| 14 |
+
</table>
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
<p align="center">
|
| 18 |
+
<em>Robust 7-class NER model for the German language, built on <code>xlm-roberta-large</code> with LoRA optimization.</em>
|
| 19 |
+
</p>
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## 🔍 Overview
|
| 24 |
+
|
| 25 |
+
**GermanER** is a high-performance Named Entity Recognition (NER) model tailored for the German language. It combines the multilingual power of `xlm-roberta-large` with **Parameter-Efficient Fine-Tuning (PEFT)** using **LoRA**, delivering strong results on both in-domain and out-of-domain German datasets.
|
| 26 |
+
|
| 27 |
+
This model is fine-tuned on a hybrid dataset composed of:
|
| 28 |
+
|
| 29 |
+
- [GermEval 2014](https://www.kaggle.com/datasets/rtatman/germaneval2014-ner)
|
| 30 |
+
- [WikiANN (de)](https://huggingface.co/datasets/wikiann)
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## 🏷️ Label Schema
|
| 35 |
+
|
| 36 |
+
The model uses a standard BIO tagging format with 7 labels:
|
| 37 |
+
|
| 38 |
+
| Tag | Entity Type |
|
| 39 |
+
|--------|----------------------------------------|
|
| 40 |
+
| B-PER | Beginning of a person entity |
|
| 41 |
+
| I-PER | Inside a person entity |
|
| 42 |
+
| B-ORG | Beginning of an organization entity |
|
| 43 |
+
| I-ORG | Inside an organization entity |
|
| 44 |
+
| B-LOC | Beginning of a location entity |
|
| 45 |
+
| I-LOC | Inside a location entity |
|
| 46 |
+
| O | Outside any named entity |
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## 📈 Performance
|
| 51 |
+
|
| 52 |
+
Evaluated on a combined test set (GermEval + WikiANN):
|
| 53 |
+
|
| 54 |
+
| Metric | Value |
|
| 55 |
+
|---------------------|-----------|
|
| 56 |
+
| **F1 Score** | 0.8062 |
|
| 57 |
+
| **Accuracy** | 95.28% |
|
| 58 |
+
| **Validation Loss** | 0.1841 |
|
| 59 |
+
| **Training Samples**| 44,000 |
|
| 60 |
+
| **Epochs** | 1 |
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## 🧠 Model Architecture
|
| 65 |
+
|
| 66 |
+
- **Base Model**: [`xlm-roberta-large`](https://huggingface.co/xlm-roberta-large)
|
| 67 |
+
- **Fine-Tuning Strategy**: PEFT with LoRA
|
| 68 |
+
- **LoRA Details**:
|
| 69 |
+
- `r=16`, `alpha=32`, `dropout=0.1`
|
| 70 |
+
- Applied to: Query, Key, and Value projection layers
|
| 71 |
+
- **Sequence Length**: 128 tokens
|
| 72 |
+
- **Precision**: Mixed-precision (fp16)
|
| 73 |
+
|
| 74 |
+
---
|
| 75 |
+
|
| 76 |
+
## 🔗 Usage
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
| 80 |
+
from transformers import pipeline
|
| 81 |
+
|
| 82 |
+
model_id = "zamal/GermaNER"
|
| 83 |
+
|
| 84 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 85 |
+
model = AutoModelForTokenClassification.from_pretrained(model_id)
|
| 86 |
+
|
| 87 |
+
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
| 88 |
+
|
| 89 |
+
text = "Angela Merkel war die Bundeskanzlerin von Deutschland."
|
| 90 |
+
entities = ner_pipeline(text)
|
| 91 |
+
print(entities)
|