m3hrdadfi commited on
Commit
54971e5
1 Parent(s): 66b3e48

Initialize

Browse files
README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: fa
3
+ ---
4
+
5
+
6
+ # AlbertNER
7
+
8
+ This model fine-tuned for the Named Entity Recognition (NER) task on a mixed NER dataset collected from [ARMAN](https://github.com/HaniehP/PersianNER), [PEYMA](http://nsurl.org/2019-2/tasks/task-7-named-entity-recognition-ner-for-farsi/), and [WikiANN](https://elisa-ie.github.io/wikiann/) that covered ten types of entities:
9
+
10
+ - Date (DAT)
11
+ - Event (EVE)
12
+ - Facility (FAC)
13
+ - Location (LOC)
14
+ - Money (MON)
15
+ - Organization (ORG)
16
+ - Percent (PCT)
17
+ - Person (PER)
18
+ - Product (PRO)
19
+ - Time (TIM)
20
+
21
+
22
+ ## Dataset Information
23
+
24
+ | | Records | B-DAT | B-EVE | B-FAC | B-LOC | B-MON | B-ORG | B-PCT | B-PER | B-PRO | B-TIM | I-DAT | I-EVE | I-FAC | I-LOC | I-MON | I-ORG | I-PCT | I-PER | I-PRO | I-TIM |
25
+ |:------|----------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|
26
+ | Train | 29133 | 1423 | 1487 | 1400 | 13919 | 417 | 15926 | 355 | 12347 | 1855 | 150 | 1947 | 5018 | 2421 | 4118 | 1059 | 19579 | 573 | 7699 | 1914 | 332 |
27
+ | Valid | 5142 | 267 | 253 | 250 | 2362 | 100 | 2651 | 64 | 2173 | 317 | 19 | 373 | 799 | 387 | 717 | 270 | 3260 | 101 | 1382 | 303 | 35 |
28
+ | Test | 6049 | 407 | 256 | 248 | 2886 | 98 | 3216 | 94 | 2646 | 318 | 43 | 568 | 888 | 408 | 858 | 263 | 3967 | 141 | 1707 | 296 | 78 |
29
+
30
+
31
+ ## Evaluation
32
+
33
+ The following tables summarize the scores obtained by model overall and per each class.
34
+
35
+ **Overall**
36
+
37
+ | Model | accuracy | precision | recall | f1 |
38
+ |:----------:|:--------:|:---------:|:--------:|:--------:|
39
+ | Albert | 0.993405 | 0.938907 | 0.943966 | 0.941429 |
40
+
41
+
42
+ **Per entities**
43
+
44
+ | | number | precision | recall | f1 |
45
+ |:---: |:------: |:---------: |:--------: |:--------: |
46
+ | DAT | 407 | 0.820639 | 0.820639 | 0.820639 |
47
+ | EVE | 256 | 0.936803 | 0.984375 | 0.960000 |
48
+ | FAC | 248 | 0.925373 | 1.000000 | 0.961240 |
49
+ | LOC | 2884 | 0.960818 | 0.960818 | 0.960818 |
50
+ | MON | 98 | 0.913978 | 0.867347 | 0.890052 |
51
+ | ORG | 3216 | 0.920892 | 0.937500 | 0.929122 |
52
+ | PCT | 94 | 0.946809 | 0.946809 | 0.946809 |
53
+ | PER | 2644 | 0.960000 | 0.944024 | 0.951945 |
54
+ | PRO | 318 | 0.942943 | 0.987421 | 0.964670 |
55
+ | TIM | 43 | 0.780488 | 0.744186 | 0.761905 |
56
+
57
+
58
+ ## How To Use
59
+ You use this model with Transformers pipeline for NER.
60
+
61
+ ### Installing requirements
62
+
63
+ ```bash
64
+ pip install sentencepiece
65
+ pip install transformers
66
+ ```
67
+
68
+ ### How to predict using pipeline
69
+
70
+ ```python
71
+ from transformers import AutoTokenizer
72
+ from transformers import AutoModelForTokenClassification # for pytorch
73
+ from transformers import TFAutoModelForTokenClassification # for tensorflow
74
+ from transformers import pipeline
75
+
76
+
77
+ model_name_or_path = "HooshvareLab/albert-fa-zwnj-base-v2-ner" # Albert
78
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
79
+ model = AutoModelForTokenClassification.from_pretrained(model_name_or_path) # Pytorch
80
+ # model = TFAutoModelForTokenClassification.from_pretrained(model_name_or_path) # Tensorflow
81
+
82
+ nlp = pipeline("ner", model=model, tokenizer=tokenizer)
83
+ example = "در سال ۲۰۱۳ درگذشت و آندرتیکر و کین برای او مراسم یادبود گرفتند."
84
+
85
+ ner_results = nlp(example)
86
+ print(ner_results)
87
+ ```
88
+
89
+
90
+ ## Questions?
91
+ Post a Github issue on the [ParsNER Issues](https://github.com/hooshvare/parsner/issues) repo.
config.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "AlbertForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0,
6
+ "bos_token_id": 2,
7
+ "classifier_dropout_prob": 0.1,
8
+ "down_scale_factor": 1,
9
+ "embedding_size": 128,
10
+ "eos_token_id": 3,
11
+ "finetuning_task": "ner",
12
+ "gap_size": 0,
13
+ "hidden_act": "gelu_new",
14
+ "hidden_dropout_prob": 0,
15
+ "hidden_size": 768,
16
+ "id2label": {
17
+ "0": "O",
18
+ "1": "B-DAT",
19
+ "2": "B-EVE",
20
+ "3": "B-FAC",
21
+ "4": "B-LOC",
22
+ "5": "B-MON",
23
+ "6": "B-ORG",
24
+ "7": "B-PCT",
25
+ "8": "B-PER",
26
+ "9": "B-PRO",
27
+ "10": "B-TIM",
28
+ "11": "I-DAT",
29
+ "12": "I-EVE",
30
+ "13": "I-FAC",
31
+ "14": "I-LOC",
32
+ "15": "I-MON",
33
+ "16": "I-ORG",
34
+ "17": "I-PCT",
35
+ "18": "I-PER",
36
+ "19": "I-PRO",
37
+ "20": "I-TIM"
38
+ },
39
+ "initializer_range": 0.02,
40
+ "inner_group_num": 1,
41
+ "intermediate_size": 3072,
42
+ "label2id": {
43
+ "B-DAT": 1,
44
+ "B-EVE": 2,
45
+ "B-FAC": 3,
46
+ "B-LOC": 4,
47
+ "B-MON": 5,
48
+ "B-ORG": 6,
49
+ "B-PCT": 7,
50
+ "B-PER": 8,
51
+ "B-PRO": 9,
52
+ "B-TIM": 10,
53
+ "I-DAT": 11,
54
+ "I-EVE": 12,
55
+ "I-FAC": 13,
56
+ "I-LOC": 14,
57
+ "I-MON": 15,
58
+ "I-ORG": 16,
59
+ "I-PCT": 17,
60
+ "I-PER": 18,
61
+ "I-PRO": 19,
62
+ "I-TIM": 20,
63
+ "O": 0
64
+ },
65
+ "layer_norm_eps": 1e-12,
66
+ "max_position_embeddings": 512,
67
+ "model_type": "albert",
68
+ "net_structure_type": 0,
69
+ "num_attention_heads": 12,
70
+ "num_hidden_groups": 1,
71
+ "num_hidden_layers": 12,
72
+ "num_memory_blocks": 0,
73
+ "pad_token_id": 0,
74
+ "position_embedding_type": "absolute",
75
+ "transformers_version": "4.5.0.dev0",
76
+ "type_vocab_size": 2,
77
+ "vocab_size": 30000
78
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0edc50c4a65288408d25530df7a63bfca9efe75fdd94c40641c4e4ea9bef7caf
3
+ size 44451929
special_tokens_map.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "eos_token": "[SEP]",
4
+ "unk_token": "<unk>",
5
+ "sep_token": "[SEP]",
6
+ "pad_token": "<pad>",
7
+ "cls_token": "[CLS]",
8
+ "mask_token": "[MASK]"
9
+ }
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:903319b1a4a7e58e49383764d33897a7f49784510247d68438e4f3bff25b01f1
3
+ size 857476
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a71db8fd9dfb34333ca5d1f7084d19e27815012e4e1bf5fb57fc7386809ccae
3
+ size 44478676
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_lower_case": false,
3
+ "remove_space": true,
4
+ "keep_accents": false,
5
+ "bos_token": "[CLS]",
6
+ "eos_token": "[SEP]",
7
+ "unk_token": "<unk>",
8
+ "sep_token": "[SEP]",
9
+ "pad_token": "<pad>",
10
+ "cls_token": "[CLS]",
11
+ "mask_token": {
12
+ "content": "[MASK]",
13
+ "single_word": false,
14
+ "lstrip": true,
15
+ "rstrip": false,
16
+ "normalized": true,
17
+ "__type": "AddedToken"
18
+ },
19
+ "model_max_length": 512,
20
+ "special_tokens_map_file": null
21
+ }