m3hrdadfi commited on
Commit
1392036
1 Parent(s): e14204b

Initial model

Browse files

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 BERT
14
+
15
+ This repo consists of pretrained models that were 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.969466 | 0.978177 | 0.973802 | 779.0 |
43
+ | Location | 0.955201 | 0.953753 | 0.954476 | 1319.0 |
44
+ | Miscellaneous | 0.867033 | 0.843850 | 0.855285 | 935.0 |
45
+ | Money | 0.979730 | 0.947712 | 0.963455 | 153.0 |
46
+ | Organization | 0.893939 | 0.897338 | 0.895636 | 1315.0 |
47
+ | Percent | 1.000000 | 1.000000 | 1.000000 | 108.0 |
48
+ | Person | 0.963028 | 0.973743 | 0.968356 | 2247.0 |
49
+ | Time | 0.976879 | 0.982558 | 0.979710 | 172.0 |
50
+ | micro avg | 0.938158 | 0.938958 | 0.938558 | 7028.0 |
51
+ | macro avg | 0.950659 | 0.947141 | 0.948840 | 7028.0 |
52
+ | weighted avg | 0.937845 | 0.938958 | 0.938363 | 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-bert"
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,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bert-base-multilingual-cased",
3
+ "architectures": [
4
+ "BertForTokenClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "directionality": "bidi",
8
+ "finetuning_task": "ner",
9
+ "gradient_checkpointing": false,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "O",
15
+ "1": "B-Date",
16
+ "2": "B-Location",
17
+ "3": "B-Miscellaneous",
18
+ "4": "B-Money",
19
+ "5": "B-Organization",
20
+ "6": "B-Percent",
21
+ "7": "B-Person",
22
+ "8": "B-Time",
23
+ "9": "I-Date",
24
+ "10": "I-Location",
25
+ "11": "I-Miscellaneous",
26
+ "12": "I-Money",
27
+ "13": "I-Organization",
28
+ "14": "I-Percent",
29
+ "15": "I-Person",
30
+ "16": "I-Time"
31
+ },
32
+ "initializer_range": 0.02,
33
+ "intermediate_size": 3072,
34
+ "label2id": {
35
+ "B-Date": 1,
36
+ "B-Location": 2,
37
+ "B-Miscellaneous": 3,
38
+ "B-Money": 4,
39
+ "B-Organization": 5,
40
+ "B-Percent": 6,
41
+ "B-Person": 7,
42
+ "B-Time": 8,
43
+ "I-Date": 9,
44
+ "I-Location": 10,
45
+ "I-Miscellaneous": 11,
46
+ "I-Money": 12,
47
+ "I-Organization": 13,
48
+ "I-Percent": 14,
49
+ "I-Person": 15,
50
+ "I-Time": 16,
51
+ "O": 0
52
+ },
53
+ "layer_norm_eps": 1e-12,
54
+ "max_position_embeddings": 512,
55
+ "model_type": "bert",
56
+ "num_attention_heads": 12,
57
+ "num_hidden_layers": 12,
58
+ "pad_token_id": 0,
59
+ "pooler_fc_size": 768,
60
+ "pooler_num_attention_heads": 12,
61
+ "pooler_num_fc_layers": 3,
62
+ "pooler_size_per_head": 128,
63
+ "pooler_type": "first_token_transform",
64
+ "position_embedding_type": "absolute",
65
+ "transformers_version": "4.7.0.dev0",
66
+ "type_vocab_size": 2,
67
+ "use_cache": true,
68
+ "vocab_size": 119547
69
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cef3b8a0f1fc31dcbcf272f4d0edd1aa3812d8068ebbd7d8f24f5a30a933d016
3
+ size 709192247
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
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": "bert-base-multilingual-cased"}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff