Upload folder using huggingface_hub
Browse files- README.md +62 -0
- config.json +67 -0
- dane_test_results.json +30 -0
- model.safetensors +3 -0
- special_tokens_map.json +41 -0
- tokenizer.json +0 -0
- tokenizer_config.json +73 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- da
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- token-classification
|
| 7 |
+
- ner
|
| 8 |
+
- danish
|
| 9 |
+
- modernbert
|
| 10 |
+
datasets:
|
| 11 |
+
- alexandrainst/dane
|
| 12 |
+
metrics:
|
| 13 |
+
- f1
|
| 14 |
+
- precision
|
| 15 |
+
- recall
|
| 16 |
+
pipeline_tag: token-classification
|
| 17 |
+
widget:
|
| 18 |
+
- text: "Jens Peter Hansen bor i København og arbejder hos Novo Nordisk."
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# ModernBERT Danish NER (Base)
|
| 22 |
+
|
| 23 |
+
Danish Named Entity Recognition model fine-tuned from [`AI-Sweden-Models/ModernBERT-base`](https://huggingface.co/AI-Sweden-Models/ModernBERT-base) on the [DaNE](https://huggingface.co/datasets/alexandrainst/dane) dataset.
|
| 24 |
+
|
| 25 |
+
## Benchmark: DaNE Test Set
|
| 26 |
+
|
| 27 |
+
| Entity | Precision | Recall | F1 | Support |
|
| 28 |
+
|--------|-----------|--------|----|---------|
|
| 29 |
+
| PER | 0.8962 | 0.9061 | 0.9011 | 181 |
|
| 30 |
+
| ORG | 0.6929 | 0.6299 | 0.6599 | 154 |
|
| 31 |
+
| LOC | 0.7500 | 0.8969 | 0.8169 | 97 |
|
| 32 |
+
| MISC | 0.4878 | 0.6316 | 0.5505 | 95 |
|
| 33 |
+
| **micro avg** | **0.7260** | **0.7742** | **0.7493** | |
|
| 34 |
+
|
| 35 |
+
## Entity Types
|
| 36 |
+
|
| 37 |
+
- **PER**: Person names
|
| 38 |
+
- **ORG**: Organizations
|
| 39 |
+
- **LOC**: Locations
|
| 40 |
+
- **MISC**: Miscellaneous entities
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from transformers import pipeline
|
| 46 |
+
|
| 47 |
+
ner = pipeline("ner", model="thomasbeste/modernbert-da-ner-base", aggregation_strategy="simple")
|
| 48 |
+
results = ner("Jens Peter Hansen bor i København og arbejder hos Novo Nordisk.")
|
| 49 |
+
for entity in results:
|
| 50 |
+
print(f"{entity['word']}: {entity['entity_group']} ({entity['score']:.3f})")
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Training Details
|
| 54 |
+
|
| 55 |
+
- **Base model**: AI-Sweden-Models/ModernBERT-base
|
| 56 |
+
- **Dataset**: DaNE (alexandrainst/dane) — 4,383 train / 564 val / 565 test sentences
|
| 57 |
+
- **Epochs**: 10
|
| 58 |
+
- **Learning rate**: 2e-5
|
| 59 |
+
- **Batch size**: 16
|
| 60 |
+
- **Optimizer**: AdamW (weight decay 0.01, warmup ratio 0.1)
|
| 61 |
+
- **Precision**: bf16
|
| 62 |
+
- **Max sequence length**: 256
|
config.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForTokenClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_activation": "silu",
|
| 9 |
+
"classifier_bias": false,
|
| 10 |
+
"classifier_dropout": 0.0,
|
| 11 |
+
"classifier_pooling": "mean",
|
| 12 |
+
"cls_token_id": 50281,
|
| 13 |
+
"decoder_bias": true,
|
| 14 |
+
"deterministic_flash_attn": false,
|
| 15 |
+
"dtype": "float32",
|
| 16 |
+
"embedding_dropout": 0.0,
|
| 17 |
+
"eos_token_id": null,
|
| 18 |
+
"global_attn_every_n_layers": 3,
|
| 19 |
+
"global_rope_theta": 160000.0,
|
| 20 |
+
"gradient_checkpointing": false,
|
| 21 |
+
"hidden_activation": "gelu",
|
| 22 |
+
"hidden_size": 768,
|
| 23 |
+
"id2label": {
|
| 24 |
+
"0": "O",
|
| 25 |
+
"1": "B-PER",
|
| 26 |
+
"2": "I-PER",
|
| 27 |
+
"3": "B-ORG",
|
| 28 |
+
"4": "I-ORG",
|
| 29 |
+
"5": "B-LOC",
|
| 30 |
+
"6": "I-LOC",
|
| 31 |
+
"7": "B-MISC",
|
| 32 |
+
"8": "I-MISC"
|
| 33 |
+
},
|
| 34 |
+
"initializer_cutoff_factor": 2.0,
|
| 35 |
+
"initializer_range": 0.02,
|
| 36 |
+
"intermediate_size": 1152,
|
| 37 |
+
"label2id": {
|
| 38 |
+
"B-LOC": 5,
|
| 39 |
+
"B-MISC": 7,
|
| 40 |
+
"B-ORG": 3,
|
| 41 |
+
"B-PER": 1,
|
| 42 |
+
"I-LOC": 6,
|
| 43 |
+
"I-MISC": 8,
|
| 44 |
+
"I-ORG": 4,
|
| 45 |
+
"I-PER": 2,
|
| 46 |
+
"O": 0
|
| 47 |
+
},
|
| 48 |
+
"layer_norm_eps": 1e-05,
|
| 49 |
+
"local_attention": 128,
|
| 50 |
+
"local_rope_theta": 10000.0,
|
| 51 |
+
"max_position_embeddings": 8192,
|
| 52 |
+
"mlp_bias": false,
|
| 53 |
+
"mlp_dropout": 0.0,
|
| 54 |
+
"model_type": "modernbert",
|
| 55 |
+
"norm_bias": false,
|
| 56 |
+
"norm_eps": 1e-05,
|
| 57 |
+
"num_attention_heads": 12,
|
| 58 |
+
"num_hidden_layers": 22,
|
| 59 |
+
"pad_token_id": 5,
|
| 60 |
+
"position_embedding_type": "absolute",
|
| 61 |
+
"repad_logits_with_grad": false,
|
| 62 |
+
"sep_token_id": 50282,
|
| 63 |
+
"sparse_pred_ignore_index": -100,
|
| 64 |
+
"sparse_prediction": false,
|
| 65 |
+
"transformers_version": "4.57.6",
|
| 66 |
+
"vocab_size": 50368
|
| 67 |
+
}
|
dane_test_results.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"LOC": {
|
| 3 |
+
"precision": 0.75,
|
| 4 |
+
"recall": 0.8969072164948454,
|
| 5 |
+
"f1": 0.8169014084507044,
|
| 6 |
+
"number": 97.0
|
| 7 |
+
},
|
| 8 |
+
"MISC": {
|
| 9 |
+
"precision": 0.4878048780487805,
|
| 10 |
+
"recall": 0.631578947368421,
|
| 11 |
+
"f1": 0.5504587155963302,
|
| 12 |
+
"number": 95.0
|
| 13 |
+
},
|
| 14 |
+
"ORG": {
|
| 15 |
+
"precision": 0.6928571428571428,
|
| 16 |
+
"recall": 0.6298701298701299,
|
| 17 |
+
"f1": 0.6598639455782312,
|
| 18 |
+
"number": 154.0
|
| 19 |
+
},
|
| 20 |
+
"PER": {
|
| 21 |
+
"precision": 0.8961748633879781,
|
| 22 |
+
"recall": 0.9060773480662984,
|
| 23 |
+
"f1": 0.9010989010989011,
|
| 24 |
+
"number": 181.0
|
| 25 |
+
},
|
| 26 |
+
"overall_precision": 0.7259786476868327,
|
| 27 |
+
"overall_recall": 0.7741935483870968,
|
| 28 |
+
"overall_f1": 0.7493112947658401,
|
| 29 |
+
"overall_accuracy": 0.9662182912597507
|
| 30 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f11228e598204cf04f36f0f8da3f4dacf11681e62fc81529630d1e02e3a7fd9
|
| 3 |
+
size 598461316
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|padding|>",
|
| 4 |
+
"<|endoftext|>"
|
| 5 |
+
],
|
| 6 |
+
"cls_token": {
|
| 7 |
+
"content": "[CLS]",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false
|
| 12 |
+
},
|
| 13 |
+
"mask_token": {
|
| 14 |
+
"content": "[MASK]",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false
|
| 19 |
+
},
|
| 20 |
+
"pad_token": {
|
| 21 |
+
"content": "[PAD]",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false
|
| 26 |
+
},
|
| 27 |
+
"sep_token": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false
|
| 33 |
+
},
|
| 34 |
+
"unk_token": {
|
| 35 |
+
"content": "[UNK]",
|
| 36 |
+
"lstrip": false,
|
| 37 |
+
"normalized": false,
|
| 38 |
+
"rstrip": false,
|
| 39 |
+
"single_word": false
|
| 40 |
+
}
|
| 41 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "<|padding|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<|endoftext|>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "[UNK]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "[CLS]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"4": {
|
| 36 |
+
"content": "[SEP]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"5": {
|
| 44 |
+
"content": "[PAD]",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"6": {
|
| 52 |
+
"content": "[MASK]",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"additional_special_tokens": [
|
| 61 |
+
"<|padding|>",
|
| 62 |
+
"<|endoftext|>"
|
| 63 |
+
],
|
| 64 |
+
"clean_up_tokenization_spaces": false,
|
| 65 |
+
"cls_token": "[CLS]",
|
| 66 |
+
"extra_special_tokens": {},
|
| 67 |
+
"mask_token": "[MASK]",
|
| 68 |
+
"model_max_length": 8192,
|
| 69 |
+
"pad_token": "[PAD]",
|
| 70 |
+
"sep_token": "[SEP]",
|
| 71 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 72 |
+
"unk_token": "[UNK]"
|
| 73 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a854acade4c13a56793e29242ac351ee2134cd05c84043363a5b9cfe70d98471
|
| 3 |
+
size 5841
|