Initial model
Browse files- README.md +87 -0
- config.json +63 -0
- eval_results.json +12 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tf_model.h5 +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: is
|
3 |
+
license: apache-2.0
|
4 |
+
widget:
|
5 |
+
- text: "Kristin manneskja getur ekki lagt frásagnir af Jesú Kristi á hilluna vegna þess að hún sé búin að lesa þær ."
|
6 |
+
- text: "Til hvers að kjósa flokk , sem þykist vera Jafnaðarmannaflokkur rétt fyrir kosningar , þegar að það er hægt að kjósa sannnan jafnaðarmannaflokk , sjálfan Jafnaðarmannaflokk Íslands - Samfylkinguna ."
|
7 |
+
- text: "Það sannaðist svo eftirminnilega á plötunni Það þarf fólk eins og þig sem kom út fyrir þremur árum , en á henni hann Fálka úr Keflavík og Gáluna , son sinn , til að útsetja lög hans og spila inn ."
|
8 |
+
- text: "Lögin hafa áður komið út sem aukalög á smáskífum af Hail to the Thief , en á disknum er líka myndband og fleira efni fyrir tölvur ."
|
9 |
+
- text: "Britney gerði honum viðvart og hann ók henni á UCLA-sjúkrahúsið í Santa Monica en það er í nágrenni hljóðversins ."
|
10 |
+
---
|
11 |
+
|
12 |
+
|
13 |
+
# IcelandicNER DistilBERT
|
14 |
+
|
15 |
+
This model was fine-tuned on the MIM-GOLD-NER dataset for the Icelandic language.
|
16 |
+
The [MIM-GOLD-NER](http://hdl.handle.net/20.500.12537/42) corpus was developed at [Reykjavik University](https://en.ru.is/) in 2018–2020 that covered eight types of entities:
|
17 |
+
|
18 |
+
- Date
|
19 |
+
- Location
|
20 |
+
- Miscellaneous
|
21 |
+
- Money
|
22 |
+
- Organization
|
23 |
+
- Percent
|
24 |
+
- Person
|
25 |
+
- Time
|
26 |
+
|
27 |
+
## Dataset Information
|
28 |
+
|
29 |
+
| | Records | B-Date | B-Location | B-Miscellaneous | B-Money | B-Organization | B-Percent | B-Person | B-Time | I-Date | I-Location | I-Miscellaneous | I-Money | I-Organization | I-Percent | I-Person | I-Time |
|
30 |
+
|:------|----------:|---------:|-------------:|------------------:|----------:|-----------------:|------------:|-----------:|---------:|---------:|-------------:|------------------:|----------:|-----------------:|------------:|-----------:|---------:|
|
31 |
+
| Train | 39988 | 3409 | 5980 | 4351 | 729 | 5754 | 502 | 11719 | 868 | 2112 | 516 | 3036 | 770 | 2382 | 50 | 5478 | 790 |
|
32 |
+
| Valid | 7063 | 570 | 1034 | 787 | 100 | 1078 | 103 | 2106 | 147 | 409 | 76 | 560 | 104 | 458 | 7 | 998 | 136 |
|
33 |
+
| Test | 8299 | 779 | 1319 | 935 | 153 | 1315 | 108 | 2247 | 172 | 483 | 104 | 660 | 167 | 617 | 10 | 1089 | 158 |
|
34 |
+
|
35 |
+
|
36 |
+
## Evaluation
|
37 |
+
|
38 |
+
The following tables summarize the scores obtained by model overall and per each class.
|
39 |
+
|
40 |
+
| entity | precision | recall | f1-score | support |
|
41 |
+
|:-------------:|:---------:|:--------:|:--------:|:-------:|
|
42 |
+
| Date | 0.969309 | 0.973042 | 0.971172 | 779.0 |
|
43 |
+
| Location | 0.941221 | 0.946929 | 0.944067 | 1319.0 |
|
44 |
+
| Miscellaneous | 0.848283 | 0.819251 | 0.833515 | 935.0 |
|
45 |
+
| Money | 0.928571 | 0.934641 | 0.931596 | 153.0 |
|
46 |
+
| Organization | 0.874147 | 0.876806 | 0.875475 | 1315.0 |
|
47 |
+
| Percent | 1.000000 | 1.000000 | 1.000000 | 108.0 |
|
48 |
+
| Person | 0.956674 | 0.972853 | 0.964695 | 2247.0 |
|
49 |
+
| Time | 0.965318 | 0.970930 | 0.968116 | 172.0 |
|
50 |
+
| micro avg | 0.926110 | 0.929141 | 0.927623 | 7028.0 |
|
51 |
+
| macro avg | 0.935441 | 0.936807 | 0.936079 | 7028.0 |
|
52 |
+
| weighted avg | 0.925578 | 0.929141 | 0.927301 | 7028.0 |
|
53 |
+
|
54 |
+
|
55 |
+
## How To Use
|
56 |
+
You use this model with Transformers pipeline for NER.
|
57 |
+
|
58 |
+
### Installing requirements
|
59 |
+
|
60 |
+
```bash
|
61 |
+
pip install transformers
|
62 |
+
```
|
63 |
+
|
64 |
+
### How to predict using pipeline
|
65 |
+
|
66 |
+
```python
|
67 |
+
from transformers import AutoTokenizer
|
68 |
+
from transformers import AutoModelForTokenClassification # for pytorch
|
69 |
+
from transformers import TFAutoModelForTokenClassification # for tensorflow
|
70 |
+
from transformers import pipeline
|
71 |
+
|
72 |
+
|
73 |
+
model_name_or_path = "m3hrdadfi/icelandic-ner-distilbert"
|
74 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
75 |
+
model = AutoModelForTokenClassification.from_pretrained(model_name_or_path) # Pytorch
|
76 |
+
# model = TFAutoModelForTokenClassification.from_pretrained(model_name_or_path) # Tensorflow
|
77 |
+
|
78 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
|
79 |
+
example = "Kristin manneskja getur ekki lagt frásagnir af Jesú Kristi á hilluna vegna þess að hún sé búin að lesa þær ."
|
80 |
+
|
81 |
+
ner_results = nlp(example)
|
82 |
+
print(ner_results)
|
83 |
+
```
|
84 |
+
|
85 |
+
|
86 |
+
## Questions?
|
87 |
+
Post a Github issue on the [IcelandicNER Issues](https://github.com/m3hrdadfi/icelandic-ner/issues) repo.
|
config.json
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "distilbert-base-multilingual-cased",
|
3 |
+
"activation": "gelu",
|
4 |
+
"architectures": [
|
5 |
+
"DistilBertForTokenClassification"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"dim": 768,
|
9 |
+
"dropout": 0.1,
|
10 |
+
"finetuning_task": "ner",
|
11 |
+
"hidden_dim": 3072,
|
12 |
+
"id2label": {
|
13 |
+
"0": "O",
|
14 |
+
"1": "B-Date",
|
15 |
+
"2": "B-Location",
|
16 |
+
"3": "B-Miscellaneous",
|
17 |
+
"4": "B-Money",
|
18 |
+
"5": "B-Organization",
|
19 |
+
"6": "B-Percent",
|
20 |
+
"7": "B-Person",
|
21 |
+
"8": "B-Time",
|
22 |
+
"9": "I-Date",
|
23 |
+
"10": "I-Location",
|
24 |
+
"11": "I-Miscellaneous",
|
25 |
+
"12": "I-Money",
|
26 |
+
"13": "I-Organization",
|
27 |
+
"14": "I-Percent",
|
28 |
+
"15": "I-Person",
|
29 |
+
"16": "I-Time"
|
30 |
+
},
|
31 |
+
"initializer_range": 0.02,
|
32 |
+
"label2id": {
|
33 |
+
"B-Date": 1,
|
34 |
+
"B-Location": 2,
|
35 |
+
"B-Miscellaneous": 3,
|
36 |
+
"B-Money": 4,
|
37 |
+
"B-Organization": 5,
|
38 |
+
"B-Percent": 6,
|
39 |
+
"B-Person": 7,
|
40 |
+
"B-Time": 8,
|
41 |
+
"I-Date": 9,
|
42 |
+
"I-Location": 10,
|
43 |
+
"I-Miscellaneous": 11,
|
44 |
+
"I-Money": 12,
|
45 |
+
"I-Organization": 13,
|
46 |
+
"I-Percent": 14,
|
47 |
+
"I-Person": 15,
|
48 |
+
"I-Time": 16,
|
49 |
+
"O": 0
|
50 |
+
},
|
51 |
+
"max_position_embeddings": 512,
|
52 |
+
"model_type": "distilbert",
|
53 |
+
"n_heads": 12,
|
54 |
+
"n_layers": 6,
|
55 |
+
"output_past": true,
|
56 |
+
"pad_token_id": 0,
|
57 |
+
"qa_dropout": 0.1,
|
58 |
+
"seq_classif_dropout": 0.2,
|
59 |
+
"sinusoidal_pos_embds": false,
|
60 |
+
"tie_weights_": true,
|
61 |
+
"transformers_version": "4.7.0.dev0",
|
62 |
+
"vocab_size": 119547
|
63 |
+
}
|
eval_results.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"epoch": 5.0,
|
3 |
+
"eval_accuracy": 0.9920402695963004,
|
4 |
+
"eval_f1": 0.8937531570971544,
|
5 |
+
"eval_loss": 0.04653976112604141,
|
6 |
+
"eval_precision": 0.8916512682681002,
|
7 |
+
"eval_recall": 0.8958649789029536,
|
8 |
+
"eval_runtime": 26.3373,
|
9 |
+
"eval_samples": 7063,
|
10 |
+
"eval_samples_per_second": 268.175,
|
11 |
+
"eval_steps_per_second": 16.782
|
12 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:420497d1b21b5eee71dca7853173c0671c2d21cefc2ed683019e6c6a9926448c
|
3 |
+
size 539031045
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e1e7f8e58759a90db57f579eb6d760d2b750876187cdcf47261e08db31a37d4
|
3 |
+
size 539114912
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
{"do_lower_case": false, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "distilbert-base-multilingual-cased"}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|